Skip to content

Commit

Permalink
set bit glyphs
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rc1e committed Apr 14, 2022
1 parent 19b62cd commit b329879
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ build: build.stamp sources/config.yaml $(SOURCES)
venv: venv/touchfile

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

.init.stamp: venv
. venv/bin/activate; python3 scripts/first-run.py
Expand Down
29 changes: 29 additions & 0 deletions scripts/set_bit6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os
from fontTools.ttLib import TTFont


CWD = os.path.dirname(__file__)


def set_overlap_flag(varfont):
glyf = varfont["glyf"]
for glyph_name in glyf.keys():
glyph = glyf[glyph_name]
if glyph.isComposite():
# Set OVERLAP_COMPOUND bit for compound glyphs
glyph.components[0].flags |= 0x400
elif glyph.numberOfContours > 0:
# Set OVERLAP_SIMPLE bit for simple glyphs
glyph.flags[0] |= 0x40


def main():
font_path = os.path.join(CWD, "..", "fonts", "variable", "RobotoFlex[GRAD,XOPQ,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght].ttf")
ttFont = TTFont(font_path)
set_overlap_flag(ttFont)
print("Glyph bits set!")
ttFont.save(ttFont.reader.file.name)


if __name__ == "__main__":
main()

0 comments on commit b329879

Please sign in to comment.