How to use the fontmake.font_project.FontProject function in fontmake

To help you get started, we’ve selected a few fontmake 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 / fontmake / test / test_arguments.py View on Github external
def test_build_otfs(self, mock_build_ttfs, mock_build_otfs):
        project = FontProject()
        self.assertFalse(mock_build_otfs.called)
        self.assertFalse(mock_build_ttfs.called)
        project.run_from_ufos("path to ufo", output=("otf", "ttf"))
        self.assertTrue(mock_build_ttfs.called)
        self.assertTrue(mock_build_otfs.called)
github googlefonts / fontmake / test / test_arguments.py View on Github external
def test_variable_output_filename(
        self,
        mock_DesignSpaceDocument_fromfile,
        mock_TTFont_save,
        mock_compileVariableTTF,
    ):
        project = FontProject()
        path = "path/to/designspace.designspace"
        doc = DesignSpaceDocument()
        doc.path = path
        mock_DesignSpaceDocument_fromfile.return_value = doc
        mock_compileVariableTTF.return_value = TTFont()
        project.build_variable_font(path)
        self.assertTrue(mock_TTFont_save.called)
        self.assertTrue(mock_TTFont_save.call_count == 1)
        self.assertEqual(
            mock_TTFont_save.call_args, mock.call("variable_ttf/designspace-VF.ttf")
        )
github google / roboto / scripts / roboto_font_project.py View on Github external
import ConfigParser
import os

from defcon import Font
from fontmake.font_project import FontProject
from mutatorMath.ufo.document import DesignSpaceDocumentReader
from robofab.world import OpenFont
from ufo2ft.kernFeatureWriter import KernFeatureWriter
from ufo2ft.makeotfParts import FeatureOTFCompiler

from fontbuild.italics import italicizeGlyph


class RobotoFontProject(FontProject):

    # glyphs with inconsistent components between masters
    decompose_pre_interpolate = set(['pipedbl', 'pipedblbar', 'uni1AB5'])

    def __init__(self, basedir):
        FontProject.__init__(self)
        config = ConfigParser.RawConfigParser()
        config.read(os.path.join(basedir, 'res', 'roboto.cfg'))
        self.no_italic = config.get('glyphs', 'noitalic').split()
        self.less_italic = config.get('glyphs', 'lessitalic').split()
        stem_widths = config.get('params', 'stem_widths').splitlines()
        self.stem_widths = dict(l.split() for l in stem_widths if l)

    def __del__(self):
        # restore masters if some exception occurs
        self._restore_masters()
github source-foundry / fontmake-mp / fmp.py View on Github external
def build_fonts(ufo_path):
    try:
        fp = FontProject()
        fp.run_from_ufos(ufo_path, output=BUILD_FILE_TYPE)
    except Exception as e:
        lock.acquire()
        print(" ")
        print("[ERROR] The fontmake compile for " + ufo_path + " failed with the following error"
              ":" + os.linesep)
        sys.stdout.flush()
        traceback.print_exc()
        print(str(e))
        sys.stdout.flush()
        lock.release()
github TypeNetwork / Roboto-Delta / src / build.py View on Github external
font = Font(source_path)
	if fileName not in ['RobotoDelta-opszmax.ufo', 'RobotoDelta-wghtmin.ufo', 'RobotoDelta-wghtmax.ufo', 'RobotoDelta-wdthmax.ufo', 'RobotoDelta-wdthmin.ufo']:
	    accentFonts.append(font)
	fonts.append(font)
	
buildGlyphSet(dflt, fonts)
allfonts = [dflt]+fonts
buildComposites(composites, accentFonts)
setGlyphOrder(glyphOrder, allfonts)
clearAnchors(allfonts)
saveMasters(allfonts)

# build Variable Font

ufos = [font.path for font in allfonts]
project = FontProject()
project.run_from_ufos(
	ufos, 
	output=("ttf-interpolatable"), # FIXME this also build master_ttf and should not.
	remove_overlaps=False, 
	reverse_direction=False, 
	use_production_names=False)

outfile = "../fonts/RobotoDelta-VF.ttf"
finder = lambda s: s.replace("master_ufo", "master_ttf_interpolatable").replace(".ufo", ".ttf")
varfont, _, _ = build(designSpace, finder)
print "Saving Variable Font..."
varfont.save(outfile)

print "DONE!"
github googlefonts / fontmake / Lib / fontmake / __main__.py View on Github external
)
    else:
        exclude_args(parser, args, ["optimize_gvar"], "static output", positive=False)

    if args.get("use_mutatormath"):
        for module in ("defcon", "mutatorMath"):
            try:
                __import__(module)
            except ImportError:
                parser.error(
                    f"{module} module not found; reinstall fontmake with the "
                    "[mutatormath] extra"
                )

    try:
        project = FontProject(
            timing=args.pop("timing"),
            verbose=args.pop("verbose"),
            validate_ufo=args.pop("validate_ufo"),
        )

        if glyphs_path:
            with _make_tempdirs(parser, args):
                project.run_from_glyphs(glyphs_path, **args)
            return

        exclude_args(
            parser,
            args,
            [
                "family_name",
                "mti_source",