Skip to content

Commit

Permalink
Update requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledhosny committed Sep 23, 2024
1 parent 7ff18ee commit fc3a984
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $(<F))
${PYTHON} ${SCRIPTDIR}/check-shaping.py $< ${TESTDIR}/shaping-config.yml $@
${PYTHON} -m alifTools.shaping.check $< ${TESTDIR}/shaping-config.yml $@

${SVG}: ${FONT}
$(info   SVG $(@F))
${PYTHON} ${SCRIPTDIR}/make-sample.py -t "${SAMPLE}" -o $@ $<
${PYTHON} -m alifTools.sample -t "${SAMPLE}" -o $@ $<

dist: ${DFONT} ${SVG}
$(info   DIST ${DIST}.zip)
Expand Down
5 changes: 1 addition & 4 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
ufo2ft >= 2.30.0
blackrenderer
fontmake
fonttools
axisregistry
vharfbuzz
pyyaml
alifTools[shaping,sample] @ git+https://github.com/aliftype/tools.git@604c296c02d3015ed5d80c3970e86ec22f690a5a
20 changes: 10 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
#
# 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
# via ufolib2
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
Expand All @@ -26,7 +30,6 @@ fontmath==0.9.4
# ufo2ft
fonttools[lxml,ufo,unicode]==4.53.1
# via
# -r requirements.in
# axisregistry
# blackrenderer
# booleanoperations
Expand All @@ -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
Expand All @@ -51,25 +53,23 @@ 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
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
1 change: 0 additions & 1 deletion scripts
Submodule scripts deleted from 66126a
75 changes: 75 additions & 0 deletions scripts/dist.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit fc3a984

Please sign in to comment.