Skip to content

Commit

Permalink
Change coverage calculation on Latin_Core>Latin_Kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
yanone committed Nov 22, 2024
1 parent a817ee0 commit 3749d08
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Lib/glyphsets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,12 @@ def add_language(code):
return code


def get_unicodes_unique_in_glyphset(glyphset_name, compare_against_glyphset):
unicodes_in_glyphset = set(unicodes_per_glyphset(glyphset_name))
unicodes_in_compare_against = set(unicodes_per_glyphset(compare_against_glyphset))
return unicodes_in_glyphset.difference(unicodes_in_compare_against)


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.
Expand Down Expand Up @@ -836,16 +842,19 @@ def get_glyphsets_fulfilled(ttFont):
# - Subtract Latin Core from the covered Unicodes
# - Calculate percentage covered based on that

if glyphset == "GF_Latin_Core":
if glyphset in ("GF_Latin_Kernel", "GF_Latin_Core"):
if unicodes_in_glyphset:
has = res[glyphset]["has"]
res[glyphset]["percentage"] = len(has) / len(unicodes_in_glyphset)
else:
res[glyphset]["percentage"] = 0
else:
unicodes_unique_in_glyphset = list(
set(unicodes_per_glyphset(glyphset)).difference(set(unicodes_per_glyphset("GF_Latin_Core")))
)
if get_unicodes_unique_in_glyphset(glyphset, "GF_Latin_Core") > get_unicodes_unique_in_glyphset(
glyphset, "GF_Latin_Kernel"
):
unicodes_unique_in_glyphset = list(get_unicodes_unique_in_glyphset(glyphset, "GF_Latin_Core"))
else:
unicodes_unique_in_glyphset = list(get_unicodes_unique_in_glyphset(glyphset, "GF_Latin_Kernel"))

if unicodes_unique_in_glyphset:

Expand Down

0 comments on commit 3749d08

Please sign in to comment.