![]() |
#31 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,004
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,004
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 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; Today at 10:40 AM. |
![]() |
![]() |
![]() |
#33 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,004
Karma: 5449552
Join Date: Nov 2009
Device: many
|
@BeckyEbook,
Okay, I took your ChangeMonoFont-v7.py and tweaked it to create a ChangeMonoFont-v8.py that tries the approach I used for the LiberationMono font. So when you get a free moment, would you please grab this version and edit it (comment out my LiberationMono font input/output, and uncomment your IBMPlexMono ones and give this a try inside Sigil.) It seems to give nice (almost double) spacing. Since it does not play with usWinAscent and usWindDescent it may only work on Qt6 apps on Linux. But it worth a shot at things for Windows. I will try it on macOS later today. Thanks! ps. It first tries the hhea info, but if it is missing it defaults to using the OS2 usWinAscent and Descent for initial values (setting linegap to 0) If the USE_TYPO_METRICS flag is not set, it doesn't trust the sTypo values and so fixes the Typo metrics using the gathered above ascent, descent and line gap values, then it sets that flag (updating the version number if needed) If the USE_TYPO_METRICS flag is set, it assumes they are correct and uses them to fix up the hhea metrics from them. Then it scales the line gaps values in Typo and hhea and sets them. It then adjusts the names to meet the spec (no spaces allowed in internal font name) and outputs it. Last edited by KevinH; Today at 01:37 PM. |
![]() |
![]() |
![]() |
#34 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 739
Karma: 2296998
Join Date: Jan 2017
Location: Poland
Device: Various
|
Modified by v8 "Liberation Mono-ls150" works on my Sigil (Windows 10).
Last edited by BeckyEbook; Today at 12:46 PM. Reason: Screenshots |
![]() |
![]() |
![]() |
#35 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,004
Karma: 5449552
Join Date: Nov 2009
Device: many
|
Great! Thanks for testing it. Now I need to test it on Mac.
Attached are some screenshots from my Linux box: |
![]() |
![]() |
![]() |
#36 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,004
Karma: 5449552
Join Date: Nov 2009
Device: many
|
And I just tested it on macOS (installing it only for my user and not system installed) and it worked just fine giving lots of space between lines.
So BeckyEbook's code (even in its early versions) has clearly demonstrated that we could use a python3 program to allow the user to scale the line spacing as needed in their preferred monospaced ttf font. If fontTool is pure python, we may be able to include it in a Sigil plugin and have the plugin do the work. So this is probably an approach that will work for those few who need or want more linespacing without hurting Sigil's performance esecially on large text files. Nicely Done BeckyEbook! Last edited by KevinH; Today at 01:41 PM. |
![]() |
![]() |
![]() |
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 |