Add pdf-invoice module: one invoice in OpenPDF 3.0.5, iText Core 9.8.0 and Flying Saucer 10.7.0, Devanagari shaping checked by rendering, streamed vs buffered download, subset sizes and timings
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6Kg9RWSTJzyz6KP9X
This commit is contained in:
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Cut static Regular and Bold instances out of the Noto Sans Devanagari variable font.
|
||||
|
||||
Source (SIL OFL 1.1, copyright The Noto Project Authors; OFL.txt next to the output files):
|
||||
https://cdn.jsdelivr.net/gh/google/fonts@main/ofl/notosansdevanagari/NotoSansDevanagari%5Bwdth%2Cwght%5D.ttf
|
||||
(a jsDelivr mirror of github.com/google/fonts; raw.githubusercontent.com was blocked in the sandbox this was built in)
|
||||
|
||||
Why static instances: OpenPDF and iText read a variable font's default master only, and Flying Saucer
|
||||
picks weights by file. Two small static files make "regular" and "bold" mean the same thing in all three.
|
||||
Needs: pip install fonttools
|
||||
"""
|
||||
import sys
|
||||
from fontTools.ttLib import TTFont
|
||||
from fontTools.varLib import instancer
|
||||
|
||||
src, outdir = sys.argv[1], sys.argv[2]
|
||||
for name, wght in (("Regular", 400), ("Bold", 700)):
|
||||
font = TTFont(src)
|
||||
inst = instancer.instantiateVariableFont(font, {"wght": wght, "wdth": 100}, updateFontNames=True)
|
||||
inst.save(f"{outdir}/NotoSansDevanagari-{name}.ttf")
|
||||
print("wrote", name)
|
||||
Reference in New Issue
Block a user