This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Use FontTools subsetter's prune_lookup method to remove all unreferenced lookups from GPOS and GSUB tables.""" | |
import sys | |
from fontTools.misc.cliTools import makeOutputFileName | |
from fontTools.ttLib import TTFont | |
# importing this dynamically adds a prune_lookups method to GPOS/GSUB classes | |
from fontTools import subset | |
input_file = sys.argv[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ufo2ft.featureWriters.markFeatureWriter import MarkFeatureWriter | |
from fontTools.feaLib.ast import FeatureFile | |
from ufoLib2 import Font | |
fea = FeatureFile() | |
font = Font() | |
a = font.newGlyph("a") | |
a.appendAnchor({"name": "top", "x": 500, "y": 600}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import argparse | |
import logging | |
from fontTools.ttLib import TTFont | |
from fontTools.ttLib.tables._f_v_a_r import Axis | |
from fontTools.varLib.builder import buildVarRegionAxis | |
log = logging.getLogger("add_fvar_axis.py") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
The contours from https://gist.github.com/rsheeter/cef6cf71fa9e519c94f9f0d23906e5de are in fact not compatible | |
and this even before we attempt to reverse them. | |
See https://github.com/fonttools/fonttools/issues/3093 | |
""" | |
from ufoLib2 import Font | |
from ufo2ft import compileInterpolatableTTFs | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Print all the glyph 'master' locations from a variable TTF (user-scale coordinates). | |
A 'master' along a given axis is where a delta-set region peaks. | |
""" | |
from fontTools.varLib.models import piecewiseLinearMap | |
def map_axis_values(axis_mappings, location): | |
return { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import shutil | |
import os | |
from fontTools.misc.loggingTools import Timer | |
import orjson | |
from ufoLib2.converters import json_converter as c | |
from ufoLib2.objects import Font |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Similar to pip freeze, but only listing the installed dependencies for the selected package. | |
E.g.: | |
$ python freeze_requirements.py fonttools[ufo] | |
# Installed requirements for 'fonttools[ufo]' (5 in total): | |
appdirs==1.4.4 | |
fonttools==4.24.4 | |
fs==2.4.13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Copyright 2020 Google LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# Example script to remove overlaps in TTF using skia-pathops | |
import sys | |
from fontTools.ttLib import TTFont | |
from fontTools.pens.recordingPen import DecomposingRecordingPen | |
from fontTools.pens.ttGlyphPen import TTGlyphPen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import glob | |
from lxml import etree | |
svg_directory = sys.argv[1] | |
noid_files = set() | |
id_files = set() | |
for filename in glob.glob(f"{svg_directory}/*.svg"): | |
tree = etree.parse(filename) |
NewerOlder