How to use the uharfbuzz.Buffer.create function in uharfbuzz

To help you get started, we’ve selected a few uharfbuzz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github harfbuzz / uharfbuzz / tests / test_uharfbuzz.py View on Github external
def test_create(self):
        buf = hb.Buffer.create()
github googlefonts / fontdiffenator / Lib / diffenator / visualize.py View on Github external
hb_face = hb.Face.create(open(font.path, 'rb').read())
    hb_font = hb.Font.create(hb_face)
    hb_upem = upm_size

    hb_font.scale = (hb_upem, hb_upem)
    if font.is_variable:
        hb_font.set_variations(font.axis_locations)
    hb.ot_font_set_funcs(hb_font)

    # Draw glyphs
    x, y, baseline = 20, 200, 0
    x_pos = 20
    y_pos = 200
    for row in diff_table[:item_limit]:

        buf = hb.Buffer.create()
        buf.add_str(row['string'])

        buf.guess_segment_properties()
        try:
            features = {f: True for f in row['features']}
            hb.shape(hb_font, buf, features)
        except KeyError:
            hb.shape(hb_font, buf)

        char_info = buf.glyph_infos
        char_pos = buf.glyph_positions
        for info, pos in zip(char_info, char_pos):
            gid = info.codepoint            
            ft_font.load_glyph(gid, flags=6)
            bitmap = slot.bitmap
github googlefonts / fontdiffenator / Lib / diffenator / __init__.py View on Github external
def _shape_string(self, font, string, ot_features):
        buf = hb.Buffer.create()
        buf.add_str(string)
        buf.guess_segment_properties()
        try:
            features = {f: True for f in ot_features}
            hb.shape(font.hbfont, buf, features)
        except KeyError:
            hb.shape(font.hbfont, buf)
        return buf