Ejemplo n.º 1
0
#
if False:
    # If you do not care about cluster values reflecting Python
    # string indices, then this is quickest way to add text to
    # buffer:
    hb.buffer_add_utf8 (buf, text.encode('utf-8'), 0, -1)
    # Otherwise, then following handles both narrow and wide
    # Python builds (the first item in the array is BOM, so we skip it):
elif sys.maxunicode == 0x10FFFF:
    hb.buffer_add_utf32 (buf, array.array('I', text.encode('utf-32'))[1:], 0, -1)
else:
    hb.buffer_add_utf16 (buf, array.array('H', text.encode('utf-16'))[1:], 0, -1)


hb.buffer_guess_segment_properties (buf)
if ((hb.buffer_get_script(buf) == hb.script_t.MONGOLIAN) or (hb.buffer_get_script(buf) == hb.script_t.PHAGS_PA)):
    wantRotate = True
if (hb.buffer_get_script(buf) == hb.script_t.HAN):
    hb.buffer_set_direction(buf, hb.direction_t.TTB)
    wantTTB = True

hb.shape (font, buf, [])
font_extents = hb.font_get_extents_for_direction(font, hb.buffer_get_direction(buf))
font_height = font_extents.ascender - font_extents.descender + font_extents.line_gap

infos = hb.buffer_get_glyph_infos (buf)
positions = hb.buffer_get_glyph_positions (buf)

x = 0
y = 0
glyph_extents = list()