Exemple #1
0
def update_layout(cairo_context: cairocffi.Context,
                  layout: pangocffi.Layout) -> None:
    """
    Updates the private Pango ``Context`` of a Pango ``Layout`` created with
    :meth:`create_layout()` to match the current transformation and target
    surface of a Cairo context.

    :param cairo_context:
        a Cairo context
    :param layout:
        a Pango layout
    """
    cairo_t_pointer = _get_cairo_t_from_cairo_ctx(cairo_context)
    pangocairo.pango_cairo_update_layout(cairo_t_pointer, layout.get_pointer())
Exemple #2
0
def show_layout(cairo_context: cairocffi.Context,
                layout: pangocffi.Layout) -> None:
    """
    Draws a Pango Layout in the specified cairo context. The top-left corner
    of the PangoLayout will be drawn at the current point of the cairo context.

    :param cairo_context:
        a Cairo context
    :param layout:
        a Pango layout
    """
    cairo_context_pointer = _get_cairo_t_from_cairo_ctx(cairo_context)
    pangocairo.pango_cairo_show_layout(cairo_context_pointer,
                                       layout.get_pointer())
Exemple #3
0
def layout_path(cairo_context: cairocffi.Context,
                layout: pangocffi.Layout) -> None:
    """
    Adds the text in a ``Pango.Layout`` to the current path in the specified
    cairo context. The top-left corner of the ``Pango.Layout`` will be at the
    current point of the cairo context.

    :param cairo_context:
        a Cairo context
    :param layout:
        a Pango layout
    """
    cairo_context_pointer = _get_cairo_t_from_cairo_ctx(cairo_context)
    pangocairo.pango_cairo_layout_path(cairo_context_pointer,
                                       layout.get_pointer())
Exemple #4
0
 def test_layout_get_pointer_returns_identical_layout():
     context = Context()
     layout = Layout(context)
     identical_layout = Layout.from_pointer(layout.get_pointer())
     assert identical_layout.get_pointer() == layout.get_pointer()