Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 08-25-2024, 04:24 PM   #16
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,870
Karma: 198099188
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by KevinH View Post
Okay, but that will really not leave us a path forward to fix this one. I am okay with that but hoped we could do something.
Me too. I was hoping the coding solution would work. We could still do something with fonts. We'd just have to make sure the fonts we started with were license free (and Linux folk would just be on their own getting them installed/configured).
DiapDealer is offline   Reply With Quote
Old 08-26-2024, 01:19 PM   #17
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,088
Karma: 5450184
Join Date: Nov 2009
Device: many
FWIW,
I used FontForge on Linux and was able to take the LiberationMono.ttf font from its github release site, and eventually found a way to edit the OS2 tables Win Ascent and Win Descent values and generated a MyLibMono font with increased line spacing. It took quite a bit of trial and error but it was doable. To install it I just copied it to ~/.fonts folder.

Then I launched Sigil and opened Preferences and used Appearance CodeView to select the MyLibMono font and it all worked.

Even with FontForge the process involved a lot of trial and error. And according to their docs, the same changes may not work on other platforms.

So not easy but doable.
KevinH is online now   Reply With Quote
Advert
Old 08-27-2024, 09:36 AM   #18
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,870
Karma: 198099188
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Just a thought--I've not looked into the code at all--but I'm wondering if it would be possible to come at this thing through the line-numbering widget? If we give it a Qt objectName, could we not change that widget's spacing or padding via qss (or perhaps come at it programmatically).

Then again, it's entirely likely that this is a "tail wagging the dog" situation (where the metrics of the font used in the QPlainTextWidget dictate the line-height of the LineNumbering area).

Just a thought.
DiapDealer is offline   Reply With Quote
Old 08-27-2024, 09:44 AM   #19
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,088
Karma: 5450184
Join Date: Nov 2009
Device: many
I think it is the latter case. The QPlaintextEdit document layout code is simply ignoring the QTextBlockFormat set and so always just uses the font bounding rectangle to determine spacing. The code just adds a left margin and a block number count, I think.

Last edited by KevinH; 08-27-2024 at 09:59 AM.
KevinH is online now   Reply With Quote
Old 08-27-2024, 11:07 AM   #20
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,088
Karma: 5450184
Join Date: Nov 2009
Device: many
I will at least look into what it would take to move to QTextEdit. It is just that QPlainTextEdit is supposedly optimized to work with much much larger text files than QTextEdit can handle.

So we would be trading off speed and size just to get line spacing. I am not sure that is a good tradeoff given interested users could edit a font to make that change themselves.
KevinH is online now   Reply With Quote
Advert
Old 08-27-2024, 11:15 AM   #21
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,870
Karma: 198099188
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Agreed. I think the line-height issue warrants some looking into. But I don't think moving to QTextEdit would be the best tradeoff to get it.
DiapDealer is offline   Reply With Quote
Old 08-27-2024, 01:15 PM   #22
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,088
Karma: 5450184
Join Date: Nov 2009
Device: many
QPlainTextEdit uses QTextLine in its text layout code. I took a look at QTextLine and it completely bases its height on the specific font's ascent, descent, and leading (line gap) metrics. I have no idea if we could subclass QTextLine and override its height routine to max that value against a user settable value or not.

Not sure if that is even possible.
KevinH is online now   Reply With Quote
Old 08-27-2024, 02:24 PM   #23
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,870
Karma: 198099188
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Weird that Qt would make something like this so difficult. Seems like something that more people would wish for.
DiapDealer is offline   Reply With Quote
Old 08-27-2024, 03:20 PM   #24
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,088
Karma: 5450184
Join Date: Nov 2009
Device: many
It is strange. It would not slow down QPlainTextEdit at all to add a user settable but fixed amount to the lineHeight to create better text spacing.

That said, from the qfontengine code we now know the exact values to change in a font to make the line gap (leading value) larger.

Perhaps a python program could allow a user to select a monospaced font and then update the type linegap, and leading value (hhea table leading value on mac) to created a modified font for them.

There are some nice font tools in python. That might be an avenue to consider.

Last edited by KevinH; 08-27-2024 at 03:39 PM.
KevinH is online now   Reply With Quote
Old 08-27-2024, 03:49 PM   #25
BeckyEbook
Guru
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 758
Karma: 2296998
Join Date: Jan 2017
Location: Poland
Device: Various
Works!

scale=1.1 means increasing the offset by 10%.

Before: pip install fonttools
Attached Files
File Type: py ChangeMonoFont.py (837 Bytes, 14 views)
BeckyEbook is offline   Reply With Quote
Old 08-27-2024, 04:19 PM   #26
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,088
Karma: 5450184
Join Date: Nov 2009
Device: many
Hi BeckyEbook,

Very nice!

But instead of scaling up the ascent and descent values there is a typo line gap (and similar line gap values for hhea) value that does not actually scale the drawn glyphs but instead just grows the gap between lines.

So I just add the current ascent plus descent (as a positive value) and and take 50% of it and make that the typo line gap value stead of 0 (for 1.5 line spacing).

That keeps font size exactly the same in QT QFonts but increases line spacing.

Does that python fontlib make it easy to try that?

Thanks!

Kevin


Update, checking the ttflib code the values I want to play with are:

Code:
   ttLib.getTableClass("hhea"),
            (
                "ascent",
                "descent",
                "lineGap",
                 ...
and

Code:
  ttLib.getTableClass("OS/2"),
            (
              ...
                "sTypoAscender",
                "sTypoDescender",
                "sTypoLineGap",
                "usWinAscent",
                "usWinDescent",
                "sxHeight",
                "sCapHeight",
            ),
are sTypoLineGap in the OS2 table and lineGap in the hhea table.


I am away from my Desktop so if you have a free moment would you try that. Based on my reading of the qfontengine code, this should work on all platforms under Qt6.


Quote:
Originally Posted by BeckyEbook View Post
Works!

scale=1.1 means increasing the offset by 10%.

Before: pip install fonttools

Last edited by KevinH; 08-27-2024 at 04:42 PM.
KevinH is online now   Reply With Quote
Old 08-27-2024, 05:43 PM   #27
BeckyEbook
Guru
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 758
Karma: 2296998
Join Date: Jan 2017
Location: Poland
Device: Various
I don't know if I understood correctly that you want to scale all these shown values. Because just changing those two (sTypoLineGap in the OS2 table and lineGap in the hhea table) is unlikely to work, or at least I haven't seen any difference.

In addition, the code now changes the internal name of the font by adding a scale to it, which is very useful for choosing your favorite spacing.

The attached code scales all the elements you mentioned.
Attached Files
File Type: py ChangeMonoFont-v2.py (1.4 KB, 11 views)
BeckyEbook is offline   Reply With Quote
Old 08-27-2024, 06:50 PM   #28
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,088
Karma: 5450184
Join Date: Nov 2009
Device: many
Not quite. The line gaps are typically 0 so scaling them in any way will not help.

So *instead* of scaling the ascent and descent values (ie. leave them alone) and just change the lineGap values as follows:

new_line_gap = int(0.5 * (ascent + descent)) (assuming of course descent is positive).

The 0.5 comes from (1.5 line spacing - 1).

That sets the leading value in the font metrics to be half the font original height.

Either way I will try it tomorrow when I get back home.

Thanks!
KevinH is online now   Reply With Quote
Old 08-27-2024, 07:58 PM   #29
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,088
Karma: 5450184
Join Date: Nov 2009
Device: many
But I just read that there is a flag value in a ttf file that tells it to use its Typo Metrics over Win Ascent and Descent values. I can set it easily in FontForge but I have no idea how to set it in python fontTool.

So my way may never work except with FontForge

Update:

in the OS2 table is the field fsSelection in bit 7 (128) is the USE_TYPO_METRICS flag which is not directly supported in fontTools.

Also it is clear that hhea , usWinAscent, usWinDescent, and the OS2 table values are really inconsistent in some shipping fonts and they do not fit with the em_square value which must be a power of 2.

So what the spec says and what is actually out there in the wild is very inconsistent.

Last edited by KevinH; 08-27-2024 at 08:51 PM.
KevinH is online now   Reply With Quote
Old 08-28-2024, 02:43 AM   #30
BeckyEbook
Guru
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 758
Karma: 2296998
Join Date: Jan 2017
Location: Poland
Device: Various
I agree with the inconsistency and total arbitrariness of the values, but I checked on a few fonts and it worked. I'm not saying to add this code to Sigil, but it could be a sure workaround for the few people who would have the need. People have different eyesight and wider spacing can certainly be counted as an Accessibility option.

Version 7 does exactly what you described (I hope):
* Adds spacing (gap) based on Ascend and Descend values.
* Resets the USE_TYPO_METRICS bit.
Attached Files
File Type: py ChangeMonoFont-v7.py (1.4 KB, 12 views)
BeckyEbook is offline   Reply With Quote
Reply

Tags
code view, qt_styles.qss


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 11:45 PM.


MobileRead.com is a privately owned, operated and funded community.