shaperglot

View on PyPIReverse Dependencies (1)

0.5.0 shaperglot-0.5.0-py3-none-any.whl

Wheel Details

Project: shaperglot
Version: 0.5.0
Filename: shaperglot-0.5.0-py3-none-any.whl
Download: [link]
Size: 30914
MD5: 384fd16c427fe3c6356fcb25059c5702
SHA256: 0134340751d4aada78c622353ce036e95d5030ac66bad5062330921688f9116d
Uploaded: 2024-02-29 16:59:52 +0000

dist-info

METADATA

Metadata-Version: 2.1
Name: shaperglot
Version: 0.5.0
Summary: Test font files for OpenType language support
Author-Email: Simon Cozens <simon[at]simon-cozens.org>
Project-Url: homepage, https://pypi.org/project/shaperglot
Project-Url: documentation, https://shaperglot.readthedocs.io
Project-Url: repository, https://github.com/simoncozens/shaperglot
License: # Shaperglot - Test font files for OpenType language support [![PyPI Version](https://img.shields.io/pypi/v/shaperglot.svg)](https://pypi.org/project/shaperglot) [![PyPI License](https://img.shields.io/pypi/l/shaperglot.svg)](https://pypi.org/project/shaperglot) Shaperglot is a library and a utility for testing a font's language support. You give it a font, and it tells you what languages are supported and to what degree. Most other libraries to check for language support (for example, Rosetta's wonderful [hyperglot](https://hyperglot.rosettatype.com) library) do this by looking at the Unicode codepoints that the font supports. Shaperglot takes a different approach. ## What's wrong with the Unicode codepoint coverage approach? For many common languages, it's possible to check that the language is supported just by looking at the Unicode coverage. For example, to support English, you need the 26 lowercase and uppercase letters of the Latin alphabet. However, for the majority of scripts around the world, covering the codepoints needed is not enough to say that a font really *supports* a particular language. For correct language support, the font must also *behave* in a particular way. Take the case of Arabic as an example. A font might contain glyphs which cover all the codepoints in the Arabic block (0x600-0x6FF). But the font only *supports* Arabic if it implements joining rules for the `init`, `medi` and `fina` features. To say that a font supports Devanagari, it needs to implement conjuncts (which set of conjuncts need to be included before we can say the font "supports" Devanagari is debated...) and half forms, as well as contain a `languagesystem` statement which triggers Indic reordering. Even within the Latin script, a font only supports a language such as Turkish if its casing behaving respects the dotless / dotted I distinction; a font only supports Navajo if its ogonek anchoring is different to the anchoring used in Polish; and so on. But there's a further problem with testing language support by codepoint coverage: it encourages designers to "fill in the blanks" to get to support, rather than necessarily engage with the textual requirements of particular languages. ## Testing for behaviour, not coverage Shaperglot therefore determines language support not just on codepoint coverage, but also by examining how the font behaves when confronted with certain character sequences. The trick is to do this in a way which is not prescriptive. We know that there are many different ways of implementing language support within a font, and that design and other considerations will factor into precisely how a font is constructed. Shaperglot presents the font with different strings, and makes sure that "something interesting happened" - without necessarily specifying what. In the case of Arabic, we need to know that the `init` feature is present, and that when we shape some Arabic glyphs, the output with `init` turned on is different to the output with `init` turned off. We don't care what's different; we only care that something has happened. *(Yes, this still makes it possible to trick shaperglot into reporting support for a language which is not correctly implemented, but at that point, it's probably less effort to actually implement it...)* Shaperglot includes (or will include) the following kinds of test: * Certain codepoints were mapped to base or mark glyphs. * A named feature was present. * A named feature changed the output glyphs. * A mark glyph was attached to a base glyph or composed into a precomposed glyph (but not left unattached). * Certain glyphs in the output were different to one another. * Languagesystems were defined in the font. * ... Using this library of tests, we then create language support definitions which exercise the font's capabilities to obtain a fuller picture of its support for a particular language. These language support definitions, expressed as YAML files, are the core of Shaperglot; to extend and improve Shaperglot, we need as many language support definition files as possible - so if you know a language well and can express what it means to "support" that language properly, please contribute a definition! ## Using Shaperglot To report whether or not a given language is supported, pass a font and one or more ISO639-3 language codes. ``` $ shaperglot -v -v MyFont.ttf urd Font does not fully support language 'urd' * PASS: All base glyphs were present in the font * FAIL: Some mark glyphs were missing: ْ * PASS: Required feature 'mark' was present * PASS: Mark glyph ◌َ (FATHA) took part in a mark positioning rule * PASS: Mark glyph ◌ُ (DAMMA) took part in a mark positioning rule * PASS: Mark glyph ◌ِ (KASRA) took part in a mark positioning rule * PASS: Mark glyph ◌ٰ (LONG_A) took part in a mark positioning rule * PASS: Required feature 'init' was present * PASS: Glyph ع (AINu1) took part in a init rule * PASS: Required feature 'medi' was present * PASS: Glyph ع (AINu1) took part in a medi rule * PASS: Required feature 'fina' was present * PASS: Glyph ع (AINu1) took part in a fina rule * PASS: Repeated beh forms should produce different shapes * PASS: Initial and final forms should differ ``` Shaperglot can also be run in bulk mode to check language support of entire font libraries. This is done by running `bulk-run-sg-.py` located in the scripts folder. ``` $ python bulk-run-sg.py ./<path-to-font-library> ``` This script will automatically drill down the direcory tree and identify all .ttf font files and check them against a subset of language tags. At this time `bulk-run-sg.py` only checks fonts for Pan-African language support. The list of relevant language tags are defined in `data/iso639-3-afr-all.txt`. Shaperglot results procesed in bulk can be quite large and may require additional tools to analyze. See [font-lang-support-afr](https://github.com/JamraPatel/font-lang-support-afr) for an example of how bulk results can be reported. Results are saved into two `.json` files. ``` results.json afr_tag_overview.json ``` `results.json` contains the checker results (`<failure type>: <failure details>`) for each language tag, broken down by font. `afr_tag_overview.json` is a summary of which fonts in the library pass and fail for each language tag that was checked. # Setup ## Requirements * Python 3.9+ ## Installation Install it directly into an activated virtual environment: ```text $ pip install shaperglot ``` or add it to your [Poetry](https://poetry.eustace.io/) project: ```text $ poetry add shaperglot ``` # Usage After installation, the package can imported: ```text $ python >>> import shaperglot >>> shaperglot.__version__ ```
Classifier: Development Status :: 1 - Planning
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: gflanguages (>=0.4.7)
Requires-Dist: termcolor (>=1.1.0)
Requires-Dist: vharfbuzz
Requires-Dist: strictyaml
Requires-Dist: num2words (~=0.5)
Requires-Dist: ufo2ft
Requires-Dist: youseedee
Requires-Dist: PyYAML
Requires-Dist: protobuf (>=3.19.4)
Description-Content-Type: text/markdown
License-File: LICENSE.md
License-File: AUTHORS.txt
[Description omitted; length: 6739 characters]

WHEEL

Wheel-Version: 1.0
Generator: bdist_wheel (0.42.0)
Root-Is-Purelib: true
Tag: py3-none-any

RECORD

Path Digest Size
shaperglot/__init__.py sha256=TjbwuHyZGPjixF4YdNx-dzaBhw4TZO5zVyEUQ_kkPk0 185
shaperglot/__main__.py sha256=z8xH2LEe0mAT-bwEVrb4l6INrDOkSR2uR_Be1uOR388 144
shaperglot/checker.py sha256=zbmx_1LjYDe5psXVBTjd4u97seWhFRVOcKmsfuY1PWg 2308
shaperglot/languages.py sha256=GwkuSzszpGTsv5x5L-jpIt3hVa_cCZbay_KjvNAtba4 3580
shaperglot/reporter.py sha256=85zlSFT8AMfus9XJBaXEmMcAzJ9sx8EqP35ifo8MoGg 1644
shaperglot/checks/__init__.py sha256=3PTlazXuZPNWak7iB2kwEbRn8k4rwuNblG6frXR4XhA 417
shaperglot/checks/common.py sha256=fHWCFe1AlPaTCu0pH6ijsdq-aofCrEsHKmFxckDDsRU 3043
shaperglot/checks/no_orphaned_marks.py sha256=Qv5M2Mw31CagcqDasFijwahTHslSUYiS82cQiXsURIQ 3695
shaperglot/checks/orthographies.py sha256=Rby0KH9OdKaOnKrnZPgIfmIb_jXrgGvKoImRewxZLGo 3353
shaperglot/checks/shaping_differs.py sha256=cinWInEDXIPYVKpA5p_PQOz4KFIYUIUBBkms9sqX5QI 4183
shaperglot/checks/unencoded_variants.py sha256=jC_1HMwU9n4q-w4IrtHK0soIuRzHOax91Xp6gU4kQ-0 2266
shaperglot/cli/__init__.py sha256=QNsCHsA8EQIOIdrG3XyfYkVbJYUqth3DN5LncAKXjv0 1777
shaperglot/cli/check.py sha256=avm6aXnCJN5qYhnFnfsbrxE3g8ARkI0y7JmYO8p4jqg 959
shaperglot/cli/describe.py sha256=qLkrwq1UU-c5iHDlX_dJgA0DgUPXFE4ABorP9gX-2v8 1157
shaperglot/cli/report.py sha256=WgBJKtnaoTVPoljed7MZypykKRlxPaJn3wqleUYzSC8 4779
shaperglot/providers/__init__.py sha256=n-_jBg1aPc61KxWILZpYhc7Ex9XmLfxsImXjLmvVPTI 514
shaperglot/providers/african_latin.py sha256=xnX6cK5ICCjqgo5PFsWXDcP9S8eNfsyyaQgYJ4YM2TM 27514
shaperglot/providers/arabic.py sha256=RNQ2FJGfJaKrvSavr65HzcdGK50WUGJ7lUD6Hu--Bxo 3732
shaperglot-0.5.0.dist-info/AUTHORS.txt sha256=0iDXDMGB07PQIktGBJqw_kvJAq-aylcWdmASiMkUCLs 302
shaperglot-0.5.0.dist-info/LICENSE.md sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA 11358
shaperglot-0.5.0.dist-info/METADATA sha256=KeeKl-cqSIFJXJotk6E0Pw2gM8tfcZ7Wp_vHiEJtCuA 15764
shaperglot-0.5.0.dist-info/WHEEL sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM 92
shaperglot-0.5.0.dist-info/entry_points.txt sha256=6VJNkgj0V7alP5ZXdmT8SZfjapsl37N7zhMLXriORvM 51
shaperglot-0.5.0.dist-info/top_level.txt sha256=snK3YMDUaytwHS5QxK9xdLfpuJETmqF4BIgnjEEeQjI 11
shaperglot-0.5.0.dist-info/RECORD

top_level.txt

shaperglot

entry_points.txt

shaperglot = shaperglot.cli:main