07-12-2013, 09:17 PM | #1 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
Adjustable line spacing not proportional to font size [solved]
Does anyone know how the line spacing set via the slider on the font menu relates to the line-height CSS directive, if at all?
If I set the line spacing to minimum on the sider, readingLineHeight=1.3 is set in the device's configuration file. So I thought this would mean the same thing as if I had set line-height:1.3 in the CSS. But it seems Kobo's readingLineHeight and the CSS line-height value only correspond when font-size:medium is active in the book's CSS. If I have the main text set to font-size:xx-large, then the lines overlap with the slider at minimum (i.e. line-height is less than 1.0), and if I have it set to font-size:x-small then the lines are about double spaced. However if I set line-height:1.3 in the books CSS then the line height remains proportional regardless of the font-size, the lines are never overlapping or double-spaced. So this means that the line spacing set via the font menu slider is not changing the line-height in the same way as setting it in the CSS. Hence my question: how to they relate? Personally I find the minimum slider-set line spacing (readingLineHeight=1.3) comfortable if the book is using a medium font-size, but some books, for reasons I cannot figure out, use font-size:small or x-small for the main text, which causes the actual line spacing to appear proportionally much larger. This also means that scaling up all the font-size directives in a book's CSS (medium to large, small to medium, etc.) would make the minimum slider-set line spacing much closer, which would probably be more useful (because the slider-set range would be shifted, it could be set near the middle of the range with room to adjust both ways, instead of always at the minimum). Edit: The cause of the problem was exactly as tshering speculated in post #2. See post #31 for a firmware patch that fixes the problem. Last edited by GeoffR; 04-18-2014 at 01:43 PM. |
07-13-2013, 12:07 PM | #2 |
Wizard
Posts: 3,489
Karma: 2914715
Join Date: Jun 2012
Device: kobo touch
|
I offer a wild speculation. From looking a little bit into libnickel during the last days, I have got the impression, that there line-height is primarily set in em. Even if readingLineHeight=1.3 seems to suggest a unit-less value, it might perhaps be handled internally as 1.3em. This difference between the internal line-height setting in em and your css setting might produce differences in elements that inherit the line-height.
|
07-13-2013, 09:57 PM | #3 |
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
From what I have seen, I thing tshering is right. If I edit a book, I either remove any font sizes, or set them in em's. The basic paragraph will be 1em if I set it. I have done a test in the past where I set various line-heights in CSS and 1.3em seem to match using 1.3 in the reading settings.
|
07-15-2013, 11:59 PM | #4 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
Thanks tshering and davidfor, that doeslook like what is happening.
This means that there is a way to effectively reduce the Kobo's minimum line spacing from 1.3 to 1.0 while still leaving it adjustable: just scale up all the font sizes in the book so that the size of the main text is 1.3em (removing any existing line-height directives if necessary). I have tried this with one book and it works well. From my Glo's font menu I just reduce the font size slider to bring the oversize fonts back to my normal preferred size, and I can now adjust the line spacing right down to the point where the lines start to overlap using the slider. |
07-16-2013, 05:23 AM | #5 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
OK it looks like the font rescaling is not always as straight forward as I thought, but I found a very simple way to reduce the minimum line spacing (while still leaving it adjustable via the line spacing slider) that works for the books I have tried which have font sizes set in terms of "font-size:small", "font-size:medum:", etc., the main text being set to font-size:medium):
All I did was remove any occurrence of "line-height" from the CSS stylesheet, then added the following line to the top of the stylesheet: Code:
body {font-size:80%} (The left-most slider notches set readingLineHeight to 1.3, 1.35, 1.4, 1.6, ..., etc. It seems that if I set the body font-size to 80% then the line spacing for fonts of size medium becomes 0.8*1.3, 0.8*1.35, 0.8*1.4, 0.8*1.6, ..., etc.) |
07-16-2013, 06:38 AM | #6 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
Example
As an example, try this book from the MobileRead library: https://www.mobileread.com/forums/showthread.php?t=97675.
Compare with the version attached, which has two lines added to the top of the stylesheet, setting the font size to medium at the paragraph level and to 75% at the body level. With the attached version the line spacing is still adjustable, but the lines are much closer at the minimum slider setting. |
07-16-2013, 06:52 AM | #7 |
Addict
Posts: 200
Karma: 42238
Join Date: Oct 2012
Device: Kobo: Glo, Aura , Aura H2O, Aura ONE, Forma, Elipsa
|
Interesting, doesn't seem to work with the stylesheet I use in my books, time for some comparison work.
|
07-16-2013, 07:42 AM | #8 | |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
Quote:
E.g. say you have font sizes set like this: Code:
p {font-size:1em} h1 {font-size:2em} Code:
body {font-size:1em} p {font-size:1.3em} h1 {font-size:2.6em} |
|
07-17-2013, 01:08 AM | #9 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
This is my guess about what is going on with the font size and line spacing:
As tshering noted above, the Kobo readingLineHeight set by the slider is in units of em. But it does this based only on the font size at body level, and does not scale the value properly properly at lower levels. For example if the CSS font-size at body level is the default 1.0em and readingLineHeight is at its minimum setting of 1.3, then the line-height at paragraph level is the inherited value 1.0em*1.3 = 1.3em instead of the unitless value 1.3, which I think is a Kobo bug. Thus if font-size is set at paragraph level to a value different to the body level, then the inherited line-height is incorrect. For example if font-size is 1.0em at body level and 1.2em at paragraph level then the inherited line-height should be 1.3*1.2em = 1.56em, but because of the bug it is actually just 1.3em. This is the bug we can exploit to reduce the minimum line spacing without resorting to setting line-height expliitly in CSS (which would make it non-adjustable). |
07-17-2013, 02:03 PM | #10 | |
Bibliophagist
Posts: 35,367
Karma: 145435140
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
My preference is for using an unitless setting so when I change the font size, the line height automatically changes. Regards, David |
|
07-18-2013, 04:29 AM | #11 | |||
Wizard
Posts: 1,760
Karma: 9918418
Join Date: Feb 2013
Location: Here on the perimeter, there are no stars
Device: Kobo H2O, iPad mini 3, Kindle Touch
|
Quote:
Quote:
See, an em unit is defined by the current size of the font. Consider the following CSS, assuming it's the only styling in effect: Code:
body { font-size: 10pt; line-height: 1.2; } h1 { font-size: 30pt; } It should therefore be obvious that setting a font-size to 80% should have no effect on line-height; all it does is make your text smaller. Since the line-height is* dependent on the current font size, the proportions won't change. * In properly-written CSS, of course. Nobody should ever, ever, EVER define text-related values in an ebook - such as line-height - as absolute units. This is VERY STRONG BAD EVIL practice. There are some cases where doing so in a very limited scope can be useful, such as to match a text caption to an embedded image, but such cases are so incredibly rare that I feel comfortable with ignoring them as statistically insignificant. Quote:
Last edited by Rev. Bob; 07-18-2013 at 04:32 AM. |
|||
07-18-2013, 04:37 AM | #12 |
Wizard
Posts: 1,760
Karma: 9918418
Join Date: Feb 2013
Location: Here on the perimeter, there are no stars
Device: Kobo H2O, iPad mini 3, Kindle Touch
|
While I agree with the rest of your message, I have to point out that "em" does not belong on that list, being a relative rather than absolute unit. It's still a good rule of thumb to say "no units on line-height," but ems should be okay due to their relative nature.
|
07-18-2013, 07:07 AM | #13 | |
Wizard
Posts: 3,489
Karma: 2914715
Join Date: Jun 2012
Device: kobo touch
|
Quote:
|
|
07-18-2013, 08:56 AM | #14 | |
Wizard
Posts: 1,760
Karma: 9918418
Join Date: Feb 2013
Location: Here on the perimeter, there are no stars
Device: Kobo H2O, iPad mini 3, Kindle Touch
|
Quote:
I think what you mean to say is that your theory is that the software calculates the baseline font size in terms of rendered pixels or some other absolute final value, and then mistakenly multiplies that by the line-height - such that line-height gets converted to an absolute unit instead of the relative value it ought to carry. At least, that would explain the results you report. |
|
07-18-2013, 03:41 PM | #15 | |
Wizard
Posts: 3,489
Karma: 2914715
Join Date: Jun 2012
Device: kobo touch
|
Quote:
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Overriding Proportional Spacing | townsend | Sigil | 6 | 05-02-2013 10:22 PM |
Kobo Mini font/line spacing problem | speakingtohe | Devices | 6 | 11-26-2012 01:46 AM |
epub to mobi - keep non proportional font ? | cybmole | Conversion | 6 | 02-06-2011 09:14 AM |
Problem with epub to lrf with changing font size and line spacing | kleinbiker | Calibre | 4 | 12-17-2009 08:55 AM |
How to change the line spacing of a font | IceHand | Bookeen | 29 | 03-07-2009 03:09 AM |