diff --git a/Makefile b/Makefile index 99e610c9..8a827a9a 100644 --- a/Makefile +++ b/Makefile @@ -70,15 +70,15 @@ ${DFONT}: ${FONT} ${TESTDIR}/%.json: ${TESTDIR}/%.yaml ${FONT} $(info   GEN $(@F)) - ${PYTHON} ${SCRIPTDIR}/update-shaping-tests.py $< $@ ${FONT} + ${PYTHON} -m alifTools.shaping.update $< $@ ${FONT} ${TESTDIR}/shaping.html: ${FONT} ${TESTDIR}/shaping-config.yml $(info   SHAPE $(= 2.30.0 -blackrenderer fontmake -fonttools axisregistry -vharfbuzz -pyyaml +alifTools[shaping,sample] @ git+https://github.com/aliftype/tools.git@604c296c02d3015ed5d80c3970e86ec22f690a5a diff --git a/requirements.txt b/requirements.txt index 0f3dbdf8..82c59f51 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,10 @@ # # pip-compile requirements.in # +aliftools[sample,shaping] @ git+https://github.com/aliftype/tools.git@604c296c02d3015ed5d80c3970e86ec22f690a5a + # via + # -r requirements.in + # aliftools appdirs==1.4.4 # via fs attrs==24.2.0 @@ -11,7 +15,7 @@ attrs==24.2.0 axisregistry==0.4.11 # via -r requirements.in blackrenderer==0.6.0 - # via -r requirements.in + # via aliftools booleanoperations==0.9.0 # via ufo2ft cffsubr==0.3.0 @@ -26,7 +30,6 @@ fontmath==0.9.4 # ufo2ft fonttools[lxml,ufo,unicode]==4.53.1 # via - # -r requirements.in # axisregistry # blackrenderer # booleanoperations @@ -37,10 +40,9 @@ fonttools[lxml,ufo,unicode]==4.53.1 # glyphslib # ufo2ft # ufolib2 - # vharfbuzz fs==2.4.16 # via fonttools -glyphslib==6.8.2 +glyphslib==6.9.0 # via fontmake lxml==5.3.0 # via fonttools @@ -51,10 +53,10 @@ protobuf==3.20.3 pyclipper==1.3.0.post5 # via booleanoperations pyyaml==6.0.2 - # via -r requirements.in + # via aliftools six==1.16.0 # via fs -ufo2ft[compreffor]==3.2.8 +ufo2ft[compreffor]==3.3.0 # via # -r requirements.in # fontmake @@ -62,14 +64,12 @@ ufolib2==0.16.0 # via # fontmake # glyphslib -uharfbuzz==0.39.5 +uharfbuzz==0.40.1 # via + # aliftools # blackrenderer - # vharfbuzz unicodedata2==15.1.0 # via fonttools -vharfbuzz==0.3.1 - # via -r requirements.in # The following packages are considered to be unsafe in a requirements file: # setuptools diff --git a/scripts b/scripts deleted file mode 160000 index 66126a6e..00000000 --- a/scripts +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 66126a6eb1efeec9a64270360662471a54fe9eda diff --git a/scripts/dist.py b/scripts/dist.py new file mode 100644 index 00000000..108b1394 --- /dev/null +++ b/scripts/dist.py @@ -0,0 +1,75 @@ +import argparse + +from fontTools import subset +from fontTools.ttLib import TTFont, newTable +from fontTools.ttLib.tables import ttProgram + + +def fix_unhinted_font(font): + gasp = newTable("gasp") + # Set GASP so all sizes are smooth + gasp.gaspRange = {0xFFFF: 15} + + program = ttProgram.Program() + assembly = ["PUSHW[]", "511", "SCANCTRL[]", "PUSHB[]", "4", "SCANTYPE[]"] + program.fromAssembly(assembly) + + prep = newTable("prep") + prep.program = program + + font["gasp"] = gasp + font["prep"] = prep + + +def main(): + parser = argparse.ArgumentParser(description="Post process font for distribution.") + parser.add_argument("input", metavar="FILE", help="input font to process") + parser.add_argument("output", metavar="FILE", help="output font to save") + parser.add_argument("version", metavar="VERSION", help="Font version") + + args = parser.parse_args() + + font = TTFont(args.input) + + version = args.version.split("-")[0] + if args.version[0] == "v": + version = version[1:] + + font["head"].fontRevision = float(version) + + font["name"].names = [n for n in font["name"].names if n.platformID == 3] + for name in font["name"].names: + if name.nameID == 5: + v = f"Version {version}" + name.string = v + if name.nameID == 3: + parts = [version] + str(name).split(";")[1:] + name.string = ";".join(parts) + + if "fvar" in font: + from axisregistry import build_stat + + build_stat(font, []) + fix_unhinted_font(font) + + unicodes = set(font.getBestCmap().keys()) + options = subset.Options() + options.set( + layout_features="*", + layout_scripts="*", + name_IDs="*", + name_languages="*", + notdef_outline=True, + glyph_names=False, + recalc_average_width=True, + drop_tables=[], + ) + subsetter = subset.Subsetter(options=options) + subsetter.populate(unicodes=unicodes) + subsetter.subset(font) + + font.save(args.output) + + +if __name__ == "__main__": + main()