예제 #1
0
def _show_layout_baseline(
        context: cairocffi.Context,
        layout: pangocffi.Layout
):
    layout_iter = layout.get_iter()
    context.set_line_width(0.5)
    context.set_dash([1, 1])
    while True:
        extents = layout_iter.get_line_extents()
        baseline = layout_iter.get_baseline()
        y_ranges = layout_iter.get_line_yrange()

        context.set_source_rgba(1, 0, 0, 0.9)
        context.move_to(
            pangocffi.units_to_double(extents[0].x),
            pangocffi.units_to_double(y_ranges[0])
        )
        context.line_to(
            pangocffi.units_to_double(extents[0].x + extents[0].width),
            pangocffi.units_to_double(y_ranges[0])
        )
        context.stroke()

        context.set_source_rgba(0, 1, 0, 0.9)
        context.stroke()
        context.move_to(
            pangocffi.units_to_double(extents[0].x),
            pangocffi.units_to_double(baseline)
        )
        context.line_to(
            pangocffi.units_to_double(extents[0].x + extents[0].width),
            pangocffi.units_to_double(baseline)
        )
        context.stroke()

        context.set_source_rgba(0, 0, 1, 0.9)
        context.move_to(
            pangocffi.units_to_double(extents[0].x),
            pangocffi.units_to_double(y_ranges[1])
        )
        context.line_to(
            pangocffi.units_to_double(extents[0].x + extents[0].width),
            pangocffi.units_to_double(y_ranges[1])
        )
        context.stroke()

        if not layout_iter.next_run():
            break
예제 #2
0
def _show_layout_line_logical_extents(
        context: cairocffi.Context,
        layout: pangocffi.Layout
):
    layout_iter = layout.get_iter()
    context.set_line_width(0.5)
    context.set_dash([1, 1])
    alternate = True
    while True:
        alternate = not alternate
        extents = layout_iter.get_line_extents()
        context.set_source_rgba(0, 0, 1 if alternate else 0.5, 0.9)
        _rectangle_path(context, extents[1])
        context.stroke()
        _coordinate_path(context, (extents[1].x, extents[1].y))
        context.fill()

        if not layout_iter.next_run():
            break
예제 #3
0
def _show_layout_y_ranges(
        context: cairocffi.Context,
        layout: pangocffi.Layout
):
    layout_iter = layout.get_iter()
    context.set_line_width(0.5)
    context.set_dash([1, 1])
    alternate = True
    while True:
        alternate = not alternate
        extents = layout_iter.get_line_extents()
        y_ranges = layout_iter.get_line_yrange()

        context.set_source_rgba(0, 0, 1 if alternate else 0.5, 0.9)
        context.move_to(
            pangocffi.units_to_double(extents[0].x),
            pangocffi.units_to_double(y_ranges[0])
        )
        context.line_to(
            pangocffi.units_to_double(extents[0].x + extents[0].width),
            pangocffi.units_to_double(y_ranges[0])
        )
        context.stroke()

        context.move_to(
            pangocffi.units_to_double(extents[0].x),
            pangocffi.units_to_double(y_ranges[1])
        )
        context.line_to(
            pangocffi.units_to_double(extents[0].x + extents[0].width),
            pangocffi.units_to_double(y_ranges[1])
        )
        context.stroke()

        if not layout_iter.next_run():
            break