Skip to content

Instantly share code, notes, and snippets.

@m4rc1e
Last active August 6, 2021 12:45
Show Gist options
  • Select an option

  • Save m4rc1e/131670c91aee6b216150c88be65b4ed2 to your computer and use it in GitHub Desktop.

Select an option

Save m4rc1e/131670c91aee6b216150c88be65b4ed2 to your computer and use it in GitHub Desktop.
gf draft rearchitecture
@condition
...
def gf_family(ttFont):
from gfcore.font import family_name
from gfcore.site import download_family, family_exists
name = family_name(ttFont)
if family_exists(name):
return download_family(name)
return None
@condition
...
def expected_name_table(ttFont):
from gfcore.font import build_name_table
return build_name_table(ttFont)
@condition
...
def expected_metadata(family_dir):
return gfcore.addfont.MakeMetadata(family_dir)
@check
...
def check_nametable(ttFont, expected_name_table):
current = ttFont['name']
expected = expected_name_table
# Simply compare them. No need for 400 checks
@check
...
def check_metadata(metadata, expected_metadata):
...
## FIXING
# For fixing we use the constants and helper funcs from the gfcore.font
from gfcore.font import *
def fix_fstype(ttFont):
ttFont['OS/2'].fsType = GF_FS_TYPE
def fix_nametable(ttFont):
from gftools.font import family_name, style_name
ttFont['name'] = build_name_table(family_name(ttFont), style_name(ttFont)
# QA
# for gftools QA we can use gfcore.site to fetch fonts from fonts.google.com
from gfcore.site import download_family, family_exists
if family_exists("Comfortaa"):
existing_family = download_family("Comfortaa")
@m4rc1e

m4rc1e commented Aug 6, 2021

Copy link
Copy Markdown
Author

It would be interesting to see how you'd tackle tables which do not have constants such as the name table.

@simoncozens

Copy link
Copy Markdown

Sure. I don't imagine you would be able to do this for everything. But what you could do it for, you should. I think this is what Dave is getting at here:

...in a way the googlefonts profile is a coded version of the GF Spec...
Given topically-unrelated efforts... - to make better structured docs for the font format spec... - perhaps there's something we can do to deduplicate and pattern things so there's a common approach that makes contribution skills more transferrable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment