![]() |
#31 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,001
Karma: 5449552
Join Date: Nov 2009
Device: many
|
Hi BeckyEbook,
Thanks! Nicely done. I tried it on LiberationMono ttf font but since the descender was negative it did not quite work as expected. The Qt6 FontEngine code uses values as follows: 1. grabs hhea values for ascender and descender and lineGap. 2. if OS2 table exists it replaces them with the sTypo values of the same So if we modify a font for use in Qt6/Sigil (as opposed to for generic non-qt6 based software), we should probably make sure that those 3 values for hhea ascender, descender, lineGap match the 3 values in the OS2 sTypo if the OS2 table exists, and then set (not clear) the USE_TYPO_METRICS flag. I will grab the IBM Plex Monospaced font from github and the LiberationMono font from github and dump the metrics just to see if there is any consistency across the various metrics across fonts to see if this approach is even possible. Perhaps for Linux, your approach of just scaling all metrics and leaving gap at 0 would be more robust. Thanks! Last edited by KevinH; Today at 08:22 AM. |
![]() |
![]() |
![]() |
#32 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,001
Karma: 5449552
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 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 o 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; Today at 10:37 AM. |
![]() |
![]() |
![]() |
Tags |
code view, qt_styles.qss |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to change background color in Code View window | philja | Sigil | 13 | 10-06-2022 11:27 AM |
replace in book view changes view to code view | cybmole | Sigil | 4 | 10-28-2012 01:20 PM |
Sigil highlight Book View No Longer Shows in Code View | Themus | Sigil | 4 | 10-04-2012 07:54 PM |
How do I change the syntax colouring and increase the font size in the Code View? | nicciglen | Sigil | 5 | 02-08-2012 09:34 AM |
lock book view & code view windows into synch | cybmole | Sigil | 5 | 01-19-2011 10:30 PM |