Skip to content

Commit b329879

Browse files
committed
set bit glyphs
1 parent 19b62cd commit b329879

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ build: build.stamp sources/config.yaml $(SOURCES)
1919
venv: venv/touchfile
2020

2121
build.stamp: venv .init.stamp
22-
. venv/bin/activate; rm -rf fonts/; gftools builder sources/config.yaml && touch build.stamp
22+
. venv/bin/activate; rm -rf fonts/; gftools builder sources/config.yaml; python scripts/set_bit6.py && touch build.stamp
2323

2424
.init.stamp: venv
2525
. venv/bin/activate; python3 scripts/first-run.py

scripts/set_bit6.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
from fontTools.ttLib import TTFont
3+
4+
5+
CWD = os.path.dirname(__file__)
6+
7+
8+
def set_overlap_flag(varfont):
9+
glyf = varfont["glyf"]
10+
for glyph_name in glyf.keys():
11+
glyph = glyf[glyph_name]
12+
if glyph.isComposite():
13+
# Set OVERLAP_COMPOUND bit for compound glyphs
14+
glyph.components[0].flags |= 0x400
15+
elif glyph.numberOfContours > 0:
16+
# Set OVERLAP_SIMPLE bit for simple glyphs
17+
glyph.flags[0] |= 0x40
18+
19+
20+
def main():
21+
font_path = os.path.join(CWD, "..", "fonts", "variable", "RobotoFlex[GRAD,XOPQ,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght].ttf")
22+
ttFont = TTFont(font_path)
23+
set_overlap_flag(ttFont)
24+
print("Glyph bits set!")
25+
ttFont.save(ttFont.reader.file.name)
26+
27+
28+
if __name__ == "__main__":
29+
main()

0 commit comments

Comments
 (0)