def render_sample(ctx, text, family, fontsize): ctx.new_path() ctx.move_to(0, 0) layout = _libpango.create_layout(ctx) _set_sample_layout(layout, text, family, fontsize) _libpango.layout_path(ctx, layout) #---Font sampling end
def get_glyphs(ctx, layout_data, text, width, text_style, attributes): glyphs = [] i = -1 for item in text: i += 1 if item in NONPRINTING_CHARS: glyphs.append(None) continue ctx.new_path() ctx.move_to(0, 0) layout = _libpango.create_layout(ctx) _set_layout(layout, item, width, text_style, attributes) _libpango.layout_path(ctx, layout) cpath = ctx.copy_path() matrix = cairo.Matrix(1.0, 0.0, 0.0, -1.0, layout_data[i][0], layout_data[i][1]) libcairo.apply_cmatrix(cpath, matrix) glyphs.append(cpath) return glyphs
def get_rtl_glyphs(ctx, layout_data, byte_dict, text, width, text_style, attributes): glyphs = [] for item in layout_data: try: txt = text[byte_dict[item[5]]] except:continue if txt in NONPRINTING_CHARS: glyphs.append(None) continue ctx.new_path() ctx.move_to(0, 0) layout = _libpango.create_layout(ctx) _set_layout(layout, txt, width, text_style, attributes) _libpango.layout_path(ctx, layout) cpath = ctx.copy_path() matrix = cairo.Matrix(1.0, 0.0, 0.0, -1.0, item[0], item[1]) libcairo.apply_cmatrix(cpath, matrix) glyphs.append(cpath) return glyphs
def layout_path(ctx=CTX, layout=PANGO_LAYOUT): _libpango.layout_path(ctx, layout)
def render_sample(ctx, text, family, fontsize): ctx.new_path() ctx.move_to(0, 0) layout = _libpango.create_layout(ctx) _set_sample_layout(layout, text, family, fontsize) _libpango.layout_path(ctx, layout)