Skip to content

Commit

Permalink
update shaperglot dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
felipesanches committed Jan 16, 2025
1 parent 7b75e1f commit d3e4539
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 64 deletions.
64 changes: 7 additions & 57 deletions Lib/fontbakery/checks/soft_dotted.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import itertools

from beziers.path import BezierPath
from fontTools import unicodedata
from vharfbuzz import Vharfbuzz

from fontbakery.prelude import check, Message, PASS, WARN, SKIP
from fontbakery.utils import exit_with_install_instructions


@check(
Expand All @@ -25,18 +30,10 @@
def check_soft_dotted(ttFont):
"""Ensure soft_dotted characters lose their dot when combined with marks that
replace the dot."""
try:
from vharfbuzz import Vharfbuzz
except ImportError:
exit_with_install_instructions("shaping")

import itertools
from beziers.path import BezierPath
from fontTools import unicodedata

cmap = ttFont["cmap"].getBestCmap()

# Soft dotted strings know to be used in orthographies.
# Soft dotted strings known to be used in orthographies.
ortho_soft_dotted_strings = set(
"i̋ i̍ i᷆ i᷇ i̓ i̊ i̐ ɨ́ ɨ̀ ɨ̂ ɨ̋ ɨ̏ ɨ̌ ɨ̄ ɨ̃ ɨ̈ ɨ̧́ ɨ̧̀ ɨ̧̂ ɨ̧̌ ɨ̱́ ɨ̱̀ ɨ̱̈ "
"į́ į̀ į̂ į̄ į̄́ į̄̀ į̄̂ į̄̌ į̃ į̌ ị́ ị̀ ị̂ ị̄ ị̃ ḭ́ ḭ̀ ḭ̄ j́ j̀ j̄ j̑ j̃ "
Expand Down Expand Up @@ -139,53 +136,6 @@ def check_soft_dotted(ttFont):
f" other cases, for example: {warn_unchanged_strings}"
)

# Calculate font's affected languages for additional information
if fail_unchanged_strings or warn_unchanged_strings:
from shaperglot.checker import Checker
from shaperglot.languages import Languages, gflangs

languages = Languages()

# Find all affected languages
ortho_soft_dotted_langs = set()
for c in ortho_soft_dotted_strings:
for lang in gflangs:
if (
c in gflangs[lang].exemplar_chars.base
or c in gflangs[lang].exemplar_chars.auxiliary
):
ortho_soft_dotted_langs.add(lang)
if ortho_soft_dotted_langs:
affected_languages = []
unaffected_languages = []
languages = Languages()
checker = Checker(ttFont.reader.file.name)

for lang in ortho_soft_dotted_langs:
reporter = checker.check(languages[lang])
string = (
f"{gflangs[lang].name} ({gflangs[lang].script}, "
f"{'{:,.0f}'.format(gflangs[lang].population)} speakers)"
)
if reporter.is_success:
affected_languages.append(string)
else:
unaffected_languages.append(string)

if affected_languages:
affected_languages = ", ".join(affected_languages)
message += (
f"\n\nYour font fully covers the following languages that require"
f" the soft-dotted feature: {affected_languages}. "
)

if unaffected_languages:
unaffected_languages = ", ".join(unaffected_languages)
message += (
f"\n\nYour font does *not* cover the following languages that"
f" require the soft-dotted feature: {unaffected_languages}."
)

if fail_unchanged_strings or warn_unchanged_strings:
yield WARN, Message("soft-dotted", message)
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from glyphsets import languages_per_glyphset, get_glyphsets_fulfilled
from shaperglot import Checker
from shaperglot import Languages

from fontbakery.prelude import check, Message, FAIL, WARN
from fontbakery.utils import markdown_table

Expand All @@ -16,9 +20,6 @@
)
def check_glyphsets_shape_languages(ttFont, config):
"""Shapes languages in all GF glyphsets."""
from shaperglot.checker import Checker
from shaperglot.languages import Languages
from glyphsets import languages_per_glyphset, get_glyphsets_fulfilled

def table_of_results(level, results):
from fontbakery.utils import pretty_print_list
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ beautifulsoup4 = [
]

shaperglot = [
"shaperglot >= 0.3.0, < 0.7.0",
# versions prior to v0.3.0 had too stric dependency rules
# for other deps such as protobuf, making it harder satisfy all dependencies.
"shaperglot >= 1.0.0a1, == 1.*",
]

# These Google Fonts profile dependencies contain data that is critical to
Expand All @@ -80,7 +78,7 @@ googlefontsalwayslatest = [
"gflanguages >= 0.7.1, == 0.7.*",
"gfsubsets >= 2024.9.25",
"glyphsets >= 1.1.0, == 1.*",
"shaperglot >= 0.6.4, == 0.6.*",
"shaperglot >= 1.0.0a1, == 1.*",
]


Expand Down

0 comments on commit d3e4539

Please sign in to comment.