From d3e4539b603ded7323602134d591702d924ac599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Thu, 16 Jan 2025 14:27:43 -0300 Subject: [PATCH] update shaperglot dependency --- Lib/fontbakery/checks/soft_dotted.py | 64 ++----------------- .../googlefonts/glyphsets/shape_languages.py | 7 +- pyproject.toml | 6 +- 3 files changed, 13 insertions(+), 64 deletions(-) diff --git a/Lib/fontbakery/checks/soft_dotted.py b/Lib/fontbakery/checks/soft_dotted.py index 39cd46dc88..25ae0dcc78 100644 --- a/Lib/fontbakery/checks/soft_dotted.py +++ b/Lib/fontbakery/checks/soft_dotted.py @@ -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( @@ -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̃ " @@ -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: diff --git a/Lib/fontbakery/checks/vendorspecific/googlefonts/glyphsets/shape_languages.py b/Lib/fontbakery/checks/vendorspecific/googlefonts/glyphsets/shape_languages.py index 8b49eec0e6..f7b72026e1 100644 --- a/Lib/fontbakery/checks/vendorspecific/googlefonts/glyphsets/shape_languages.py +++ b/Lib/fontbakery/checks/vendorspecific/googlefonts/glyphsets/shape_languages.py @@ -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 @@ -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 diff --git a/pyproject.toml b/pyproject.toml index b4f3965292..1b717993f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 @@ -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.*", ]