kurnevsky / prs-plus

Automatically exported from code.google.com/p/prs-plus
0 stars 0 forks source link

font-size through style.css is applied twice in nested items. (Example <span> inside <p>, or <p> inside <div>) #364

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Your model / PRS+ version?
PRS-650 / Nightly 169 (although I think it's irrelevant).

What steps will reproduce the problem?
1. First of all maybe this issue is unavoidable but nevertheless I post it.

2. New forced styles through auto-generated 
database/system/PRSPlus/epub/style.css are applied twice for nested items (or 
even maybe more times). And this can be a problem with "font-size: 1.066em;" 
because each time you multiply by 1.066, so you end with 1.136 (or 1.211, ...)

3. As reference, I copy the whole css style I have right now:

div, div[class], p, p[class],  html, span, ol, ul, li, table, td, th, 
TheAntiquaB-W5Plain_95 {font-size: 1.066em !important;} /* MARKER MFONTSIZE 0*/

4. A real world example: in several recent books, instead of using <i>, <b> or 
<u> tags, text formatting is done through several <span> classes. So you have 
nested <span> tags within some their <p> paragraphs.

5. Another real world example. I don't know why but I've found books where you 
have <div> sections with <p> paragraphs inside them, but also <p> paragraphs 
without being inside any <div>.

6. Another real world example built by me:
6.1. Because of what I explain later, I usually edit my Spanish ebooks adding 
this css style: .nw {white-space: nowrap;}
6.2 And then I insert span tags in dialogues. I explain it in case you don't 
know that the typical <p>"Bla, bla, bla," John said.</p> English dialogue 
sentence would be written as <p>-Bla, bla, bla, -John said.</p> in Spanish. 
(Notice how " is more or less changed by -).
6.3 In order to avoid ugly line-wrapping between "-" and "John", I edit my 
Spanish ebooks and I change the previous sentence to <p>-Bla, bla, bla, <span 
class="nw">-John</span> said.</p>.

7. In any of these situations, you get mixed final font sizes. And the final 
looking is specially ugly in 4. and 6. examples because these different font 
sizes are located in the same sentence. 
Ok, I know how to fix it in 6., (.nw {white-space:nowrap; font-size:1em;}), but 
4. will lead to horrible formatting for the average user who doesn't have to 
know how to edit/fix the epub file.

What is the expected output?
I'm no expert so maybe there's some kind of drawback in the next suggestion. So 
please check it with care.

Instead of applying font-size to "p, div, ..." individually, why don't you 
apply it just to "body"? As font-size is inherited, you'll change the full book 
font-size in just one step (except if body has a pre-set font-size in a css 
style, but this trouble also would happen with p or div).

Another good side effect you'd get: with current style.css setting you are not 
changing h1 through h6 tags, so you are currently scaling the font-size in all 
the ebook BUT the titles.

Original issue reported on code.google.com by alr...@gmail.com on 27 Dec 2012 at 8:59

GoogleCodeExporter commented 9 years ago
This is easy solvable.

You have full control over CSS selectors used:
Quote from WIKI:
Just Edit extern.css in /database/system/PRSPlus/epub/ to choose which 
selectors are affected by CSS-tweaking. 

Thanks for your insights shared in 7. I'm in no way CSS-expert and so I was not 
sure, if subsequent font-size-definitions are be added up, or are related to 
the base-fontsize.
Even so for subsequent CSS-seets. Embedded ones and style.css
Noticed lately some books, where S was ok, but set to 1.033em, the font became 
much smaller, so this lead my to the assumption that font-size set to ...em 
will apply to the font-base-size.

Original comment by Mark.N...@gentlemansclub.de on 28 Dec 2012 at 8:24

GoogleCodeExporter commented 9 years ago
When you specify sizes through ...em they are all applied one after other, but 
just over inherited sizes. Conflictive settings are discarded.

In this way, if you have several "p {font-size: whatever}" styles because of 
any reason:
- Several p CSS definitions in several css files,
- Additional definitions for base p (lower priority) AND for p.whateverclass 
(higher priority),
only the very "uppest/highest priority" font-size setting will be applied. All 
the conflictive and previous "lower prioity" font-size settings will be 
discarded.

In this way with my ".nw{font-size:1em}", I'm overriding any font-size set 
before me even the one set in the style.css file for the generic <span> tag. 
But, as <span class="nw"> is inside a <p> (and <p> is also inside a <body>), 
the final size I get is 1.0 x p size x body size.

BTW I don't understand how 1.033em can lead you to "much smaller" sizes. It 
should always make your sizes bigger, (just a little, but bigger nevertheless), 
than no setting one. ?!?!?!

Original comment by alr...@gmail.com on 28 Dec 2012 at 2:00