How to use the uharfbuzz.Font.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 googlefonts / fontdiffenator / Lib / diffenator / font.py View on Github external
self._src_ttfont['fvar'].axes}
            for axis in axes:
                if axis in self.instance_coordinates:
                    self.instance_coordinates[axis] = axes[axis]
                else:
                    logger.info("font has no axis called {}".format(axis))
            self.recalc_tables()

            coords = []
            for name in self.axis_order:
                coord = FT_Fixed(int(self.instance_coordinates[name]) << 16)
                coords.append(coord)
            ft_coords = (FT_Fixed * len(coords))(*coords)
            FT_Set_Var_Design_Coordinates(self.ftfont._FT_Face, len(ft_coords), ft_coords)
            self.hbface = hb.Face.create(self._fontdata)
            self.hbfont = hb.Font.create(self.hbface)
            self.hbfont.set_variations(self.instance_coordinates)
            self.hbfont.scale = (self.size, self.size)
        else:
            logger.info("Not vf")
github googlefonts / fontdiffenator / Lib / diffenator / visualize.py View on Github external
ctx.move_to(20, 50)
    if title:
        ctx.show_text("{}: {}".format(title, len(diff_table)))
    ctx.move_to(20, 100)
    if font_position:
        ctx.show_text("Font Set: {}".format(font_position))
    if len(diff_table) > item_limit:
        ctx.set_font_size(20)
        ctx.move_to(20, 150)
        ctx.show_text("Warning: {} different items. Only showing most serious {}".format(
            len(diff_table), item_limit)
        )

    # HB font
    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'])
github googlefonts / fontdiffenator / Lib / diffenator / font.py View on Github external
self.instance_coordinates = self._get_dflt_instance_coordinates()
        self.instances_coordinates = self._get_instances_coordinates()
        self.glyphs = self.marks = self.mkmks = self.kerns = \
            self.glyph_metrics = self.names = self.attribs = None

        self.ftfont = freetype.Face(self.path)
        self.ftslot = self.ftfont.glyph

        self.size = size
        if self.ftfont.is_scalable:
            self.ftfont.set_char_size(self.size)

        with open(self.path, 'rb') as fontfile:
            self._fontdata = fontfile.read()
        self.hbface = hb.Face.create(self._fontdata)
        self.hbfont = hb.Font.create(self.hbface)

        self.hbfont.scale = (self.size, self.size)

        if not lazy:
            self.recalc_tables()
github trufont / trufont / src / trufont / objects / layoutEngine.py View on Github external
def __init__(self, font, tables):
        self._font = font
        self._tables = tables
        upem = font.unitsPerEm

        face = hb.Face.create_for_tables(_get_layout_table, tables)
        face.upem = upem
        font = hb.Font.create(face)
        font.scale = (upem, upem)

        funcs = hb.FontFuncs.create()
        funcs.set_nominal_glyph_func(_get_nominal_glyph, self)
        funcs.set_glyph_h_advance_func(_get_glyph_h_advance, self)
        # TODO: vertical advance
        funcs.set_glyph_name_func(_get_glyph_name_func, self)
        font.funcs = funcs

        self._hbFont = font