Skip to content

Commit

Permalink
New glyphsets==0.6.13 API
Browse files Browse the repository at this point in the history
  • Loading branch information
yanone authored and felipesanches committed Feb 21, 2024
1 parent 111fb8f commit cf42942
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
7 changes: 3 additions & 4 deletions Lib/fontbakery/profiles/googlefonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ def com_google_fonts_check_glyph_coverage(
"""Check Google Fonts glyph coverage."""

import unicodedata2
from .googlefonts_conditions import get_glyphsets_fulfilled
from glyphsets import get_glyphsets_fulfilled

glyphsets_fulfilled = get_glyphsets_fulfilled(ttFont)

Expand Down Expand Up @@ -3531,8 +3531,7 @@ def com_google_fonts_check_glyphsets_shape_languages(ttFont, config):
"""Shapes languages in all GF glyphsets."""
from shaperglot.checker import Checker
from shaperglot.languages import Languages
from .googlefonts_conditions import get_glyphsets_fulfilled
from glyphsets.definitions import glyphset_definitions
from glyphsets import languages_per_glyphset, get_glyphsets_fulfilled

shaperglot_checker = Checker(ttFont.reader.file.name)
shaperglot_languages = Languages()
Expand All @@ -3548,7 +3547,7 @@ def com_google_fonts_check_glyphsets_shape_languages(ttFont, config):

fails_table = []
warns_table = []
for language_code in glyphset_definitions[glyphset]["language_codes"]:
for language_code in languages_per_glyphset(glyphset):
reporter = shaperglot_checker.check(shaperglot_languages[language_code])
if reporter.warns:
for n, warn in enumerate(reporter.warns):
Expand Down
24 changes: 0 additions & 24 deletions Lib/fontbakery/profiles/googlefonts_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,30 +740,6 @@ def is_icon_font(ttFont, config):
)


def get_glyphsets_fulfilled(ttFont):
"""Returns a dictionary of glyphsets that are fulfilled by the font,
and the percentage of glyphs in the font that are in the glyphset.
This is following the new glyphset definitions in glyphsets.definitions
"""
from glyphsets.definitions import unicodes_per_glyphset, glyphset_definitions

res = {}
unicodes_in_font = set(ttFont.getBestCmap().keys())
for glyphset in glyphset_definitions:
unicodes_in_glyphset = unicodes_per_glyphset(glyphset)
if glyphset not in res:
res[glyphset] = {"has": [], "missing": [], "percentage": 0}
for unicode in unicodes_in_glyphset:
if unicode in unicodes_in_font:
res[glyphset]["has"].append(unicode)
else:
res[glyphset]["missing"].append(unicode)
res[glyphset]["percentage"] = len(res[glyphset]["has"]) / len(
unicodes_in_glyphset
)
return res


_tags_cache = None


Expand Down

0 comments on commit cf42942

Please sign in to comment.