Skip to content

Conversation

@iorsh
Copy link
Contributor

@iorsh iorsh commented May 24, 2025

When checking glyph width validity, consider zero, full width and double width for fixed-pitch fonts.

Type of change

LogError(_("A point in %s is outside the font bounding box data.\n"), sc->name );
info->bad_cff = true;
}
if ( info->isFixedPitch && i>2 && sc->width!=info->advanceWidthMax )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for the i>2 condition in the existing code? Are the first two glyphs special/ignorable for some reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very old code, so the first glyph is probably .notdef, and the second also used to have some special meaning back then, maybe \n. I tend to kill unexplained cryptic stuff, especially when it only affects a warning message.

if ( info->isFixedPitch && i>2 && sc->width!=info->advanceWidthMax )
LogError(_("The advance width of %s (%d) does not match the font's advanceWidthMax (%d) and this is a fixed pitch font\n"),
if ( info->isFixedPitch ) {
bool valid = (sc->width==0 || sc->width==info->advanceWidthMax || sc->width==info->advanceWidthMax / 2);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the sc->width==0 test here for the same reasons (hidden characters) -- and/or others? -- outlined in:

if ( sc->width==0 )
widths[i] = 1; /* TeX/Omega use a 0 width as a flag for non-existant character. Stupid. So zero width glyphs must be given the smallest possible non-zero width, to ensure they exists. GRRR. */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and either way, maybe worth adding a comment about the reason here?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modern Unicode fonts tend to have lots of zero-width characters like control stuff, e.g. LRM or diacritics. These characters don't have an advance width and shouldn't affect pitch computation.

Good idea about comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. Thank you!

Copy link

@jayaddison jayaddison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iorsh I approved this without testing it, but then thought today: I really should have applied the patch and checked the results first.

So, I applied this branch as a patch against Debian's packaged version of the 20230101 (1:20230101~dfsg-4, specifically), and rebuilt that. Unfortunately the warning messages continue to appear:

The advance width of space (500) does not match the font's advanceWidthMax (1000) and this is a fixed pitch font
The advance width of exclam (500) does not match the font's advanceWidthMax (1000) and this is a fixed pitch font
The advance width of quotedbl (500) does not match the font's advanceWidthMax (1000) and this is a fixed pitch font
The advance width of numbersign (500) does not match the font's advanceWidthMax (1000) and this is a fixed pitch font
The advance width of dollar (500) does not match the font's advanceWidthMax (1000) and this is a fixed pitch font
The advance width of percent (500) does not match the font's advanceWidthMax (1000) and this is a fixed pitch font
The advance width of ampersand (500) does not match the font's advanceWidthMax (1000) and this is a fixed pitch font
The advance width of quotesingle (500) does not match the font's advanceWidthMax (1000) and this is a fixed pitch font
The advance width of parenleft (500) does not match the font's advanceWidthMax (1000) and this is a fixed pitch font
The advance width of parenright (500) does not match the font's advanceWidthMax (1000) and this is a fixed pitch font
The advance width of asterisk (500) does not match the font's advanceWidthMax (1000) and this is a fixed pitch font
The advance width of plus (500) does not match the font's advanceWidthMax (1000) and this is a fixed pitch font
The advance width of comma (500) does not match the font's advanceWidthMax (1000) and this is a fixed pitch font
The advance width of hyphen (500) does not match the font's advanceWidthMax (1000) and this is a fixed pitch font
...

I'm not certain why they continue to appear despite the changes; I'll try to figure that out.

@jayaddison
Copy link

@iorsh I approved this without testing it, but then thought today: I really should have applied the patch and checked the results first.
...
I'm not certain why they continue to appear despite the changes; I'll try to figure that out.

I think this may be a testing error by me; I think that although I ran the fontlint script from the patched build, the unpatched fontforge binary and/or library were invoked to perform the TTF parsing. I'm re-checking my testing process to try to confirm that theory.

@jayaddison
Copy link

I think this may be a testing error by me; I think that although I ran the fontlint script from the patched build, the unpatched fontforge binary and/or library were invoked to perform the TTF parsing. I'm re-checking my testing process to try to confirm that theory.

My apologies; yes, after an isolated rebuild of the package with this branch (at e9fa9a3) applied as a patch, the warnings have disappeared. The resulting output of the fontlint is concise and appears useful:

$ fontlint ~/Iosevka-Thin.ttf 2>&1 | more
Copyright (c) 2000-2024. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
 Version: 20230101
 Based on sources from 2024-09-06 01:07 UTC-ML-D-GDK3.
PythonUI_Init()
copyUIMethodsToBaseTable()
Program root: /usr
Attempt to unget two characters
CHECKING     /root/Iosevka-Thin.ttf
The following table(s) in the font have been ignored by FontForge
  Ignoring 'DSIG' digital signature table
ERROR      2 Self-intersecting glyph
ERROR      5 Missing points at extrema
ERROR      9 Bad glyph name
FAIL         /root/Iosevka-Thin.ttf

Thank you for the fix!

@iorsh iorsh merged commit d524804 into fontforge:master Jun 26, 2025
7 checks passed
@iorsh iorsh deleted the fixed_pitch_check branch June 26, 2025 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fontlint: bug: incorrect warnings for double-width fixed pitch truetype fonts

2 participants