View Single Post
Old 08-28-2024, 10:25 AM   #32
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,893
Karma: 6120478
Join Date: Nov 2009
Device: many
I grabbed fresh official releases for IBMPlexMono-Regular.ttf and LibrerationMono-Regular.ttf direct from their official release pages on github.

I then used FontForge to dump the font metrics information:

Code:
                   LiberationMono    IBMPlexMono
                  --------------    -----------
Ascent            1638               780
Descent            410               220
EM Square         2048              1000

Win Ascent        1705              1025
Win Descent        615               275

Use TYPO            No                No
Typo Ascent       1255               780
Typo Descent      -386              -220
Typo LineGap         0               300

hhea Ascent       1705              1025
hhea Descent      -615              -275
hhea LineGap         0                 0
So you can see just how confused things are,

The hhea values, the Win values, and the Typo values all differ in the same font for no good reason at all.

The em space according to the ttf spec should be a power of 2 (in the IBM case it is not).

The USE_TYPO_METRICS flag is not set in either but according to the Microsoft font docs it should be set and the Typo ones are the preferred values (but neither is using them, and the values do not make sense in the case of the Liberation font)

The IBM font seems to be designed around a baseline to baseline (line height) measure of 1300, whereas the Liberatifont uses 2320 but its Typo values are just plain wrong.

At least in the IBM font Win Ascent + Win Descent = 1300, for Typo (780 - -280 + 300) = 1300 and for hhea (1025 - -275 + 0) = 1300 so the line height based on all 3 measures it at least consistent.


No wonder the world of fonts is so messed up. *No one* follows the spec and every font engine around is loaded with code to fix up these values on the fly just to get things to work.

-----

Since the OS2 table in a ttf font is actually optional (but always included as far as I can tell) and the hhea table is required, we do the following:

1. If not OS2, we use the hhea values and are done unless they are 0
2. if OS2 table exists we next check the USE_TYPO_METRICS flag.
3. If USE_TYPO_METRICS is set, we use its TYPO values.
4. If not set, we can not trust the TYPO values but since Qt6 uses them, we set them to match the hhea table values no matter what. We can then decide to set or not set the USE_TYPO_METRICS flag.
5. If the Typo values are 0 we use the WinAscent and WinDescent values and assume line gap is 0

What a mess!

Last edited by KevinH; 08-28-2024 at 10:40 AM.
KevinH is offline   Reply With Quote