[base_has_width] Complains About Glyphs That Are GDEF Marks Or Are PUA And Fails To Complain About Real Problems
[base_has_width] Complains about Glyphs that are GDEF Marks or are PUA and Fails to Complain about Real Problems
Fontbakery is a tool used to test and validate OpenType fonts. It checks various aspects of a font, including its layout, metrics, and other properties. However, like any tool, Fontbakery is not immune to errors and bugs. In this article, we will discuss a specific issue with the base_has_width
check in Fontbakery, which complains about glyphs that are GDEF marks or are in the Private Use Area (PUA), while failing to report real problems.
When running Fontbakery's base_has_width
check, it reports failures for glyphs that meet certain criteria. Specifically, it checks for glyphs that are:
- Classified as marks in GDEF but are not known to be NSM due to out-of-date unicodedata. For example, in SIL's Scheherazade font, the glyph at codepoint U+0897 is listed in the GDEF mark table, but it is reported as not having a width. This is because the
unicodedata
module is outdated and does not recognize this glyph as a Non-Spacing Mark (NSM). - Glyphs for codepoints in the Private Use Area (PUA). In SIL's Charis font, the glyph at codepoint U+F176 is a PUA character that has zero width, as intended. However, it is not a mark, and the
base_has_width
check incorrectly reports it as a failure.
On the other hand, the base_has_width
check passes for some glyphs that it should not. For instance, in the current release of Scheherazade, the glyph at codepoint U+FFFC is encoded as an empty glyph with no width, but it is not flagged as a failure by the base_has_width
check.
The expected behaviour of the base_has_width
check is to:
- Not report glyphs classified in GDEF as marks or encoded as PUA as failures. These glyphs should be exempt from the check, as they are not intended to have a width.
- Report glyphs that are actually fails as failures. The check should correctly identify glyphs that do not have a width and report them as failures.
- Have a pytest for this check. A test case should be added to ensure that the
base_has_width
check is working correctly.
The root causes of these issues are:
- Mistake in the check: The
base_has_width
check contains a double negative, which is essentially restricting the test to looking at glyphs that are classified in GDEF as marks. This is the cause of problems 1 and 3. - PUA glyphs should not be tested: If we agree that PUA glyphs should not be tested, we can add a condition to the
is_space()
function to exclude them from the check.
To reproduce these issues, you can download the fonts mentioned above from the SIL website:
- Scheherazade: https://software.sil.org/scheherazade/download/
- Charis: https://software.sil.org/charis/download/
You will also need to run Fontbakery from source, with the commit hash 780e2b2900f91599c1902d0029bfc68a775d8091
. The operating system used for testing is Ubuntu 24.04.2 LTS.
To fix these issues, we need to:
- Remove the double negative from the check: This will allow the check to correctly identify glyphs that do not have a width.
- Add a condition to exclude PUA glyphs from the check: This will prevent the check from incorrectly reporting PUA glyphs as failures.
- Add a pytest for this check: This will ensure that the check is working correctly and catch any future regressions.
A test case has been written and can be included in a pull request with the above changes.
In conclusion, the base_has_width
check in Fontbakery has several issues that need to be addressed. These issues include complaining about glyphs that are GDEF marks or are in the PUA, while failing to report real problems. By fixing these issues and adding test cases, we can ensure that Fontbakery is working correctly and providing accurate results.
[base_has_width] Complains about Glyphs that are GDEF Marks or are PUA and Fails to Complain about Real Problems: Q&A
In our previous article, we discussed the issues with the base_has_width
check in Fontbakery, a tool used to test and validate OpenType fonts. In this Q&A article, we will answer some common questions related to these issues.
A: The base_has_width
check is designed to ensure that glyphs in a font have a width. This is an important aspect of font validation, as glyphs without a width can cause layout and rendering issues.
A: The base_has_width
check is complaining about glyphs that are GDEF marks or are in the PUA because it is incorrectly identifying them as glyphs without a width. GDEF marks are glyphs that are intended to be non-spacing, meaning they do not occupy any horizontal space. PUA glyphs, on the other hand, are glyphs that are not part of the standard Unicode character set and are intended for private use.
A: The base_has_width
check is failing to report real problems because it is incorrectly identifying glyphs that do not have a width. This is due to a mistake in the check, which is causing it to incorrectly identify glyphs that are GDEF marks or are in the PUA.
A: The root cause of these issues is a mistake in the base_has_width
check, which is causing it to incorrectly identify glyphs that do not have a width. Additionally, the check is not correctly excluding PUA glyphs from the check.
A: These issues can be fixed by:
- Removing the double negative from the check: This will allow the check to correctly identify glyphs that do not have a width.
- Adding a condition to exclude PUA glyphs from the check: This will prevent the check from incorrectly reporting PUA glyphs as failures.
- Adding a pytest for this check: This will ensure that the check is working correctly and catch any future regressions.
A: The impact of these issues on font validation is that they can cause incorrect results and false positives. This can lead to font validation failures and delays in font development.
A: Font developers can ensure that their fonts pass the base_has_width
check by:
- Verifying that their glyphs have a width: This can be done by checking the glyph's width in the font's metadata.
- Excluding PUA glyphs from the check: This can be done by adding a condition to the check to exclude PUA glyphs.
- Testing their fonts with the
base_has_width
check: This can be done by running thebase_has_width
check on their fonts and verifying that they pass the check.
In conclusion, the base_has_width
check in Fontbakery has several issues that need to be addressed. These issues include complaining about glyphs that are GDEF marks or are in the PUA, while failing to report real problems. By fixing these issues and adding test cases, we can ensure that Fontbakery is working correctly and providing accurate results.