03-17-2024, 06:17 PM | #1 |
Zealot
Posts: 105
Karma: 6368
Join Date: Nov 2018
Location: Italy
Device: Kindle P.white3/Kobo Clara 2E
|
No centered text, kepub ebook.
Hello, guys
I have an odd issue with centered text in a epub changed into a kepub ebook by means of "kepub output" Calibre plug in. In my style sheet I've got this simple class: .center { text-align: center; text-indent:0; font-style:italic; } I write my epubs directly into Sigil; the preview shows the text as I like it, in the middle of the page, but when I open my converted kepub in my Clara, nothing..it ignores it. Why? |
03-17-2024, 08:04 PM | #2 |
Guru
Posts: 769
Karma: 6528026
Join Date: Sep 2012
Device: Kobo Elipsa
|
I've encountered a similar problem. If I give the class a margin-left and margin-right of auto or a specific %, that usually fixes it. It doesn't happen all the time, so I'm not sure what circumstances trigger it (divs but not ps, for example). Someone else probably has better insight about this than I do.
|
Advert | |
|
03-18-2024, 12:38 AM | #3 |
Grand Sorcerer
Posts: 10,144
Karma: 224760044
Join Date: Jan 2014
Location: Estonia
Device: Kobo Sage & Libra 2
|
Do you have a justification option selected on your Clara? That would also justify centered text in kepubs. If you select "off" for justification, will the centered text display correctly?
|
03-18-2024, 03:14 AM | #4 |
Guru
Posts: 928
Karma: 2146660
Join Date: Nov 2011
Location: London, UK
Device: Kobo Aura, Kobo Aura ONE, Marvin 3
|
This sounds like the feature that this patch to libnickel changes:
Code:
Un-Force user text-align in div,p tags in KePubs: - Enabled: yes - Description: | This patch allows the text alignment set by the publisher in the kepub stylesheet to override the alignment selected by the reader from the device. # div, p { text-align: %1 !important; } # --> body { text-align: %1 !important; } - FindBaseAddressString: "div, p { text-align: %1" - ReplaceString: Find: "div, p {" Replace: "body {" MustMatchLength: yes |
03-18-2024, 05:49 AM | #5 |
Resident Curmudgeon
Posts: 73,998
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
Advert | |
|
03-18-2024, 06:04 AM | #6 |
Zealot
Posts: 105
Karma: 6368
Join Date: Nov 2018
Location: Italy
Device: Kindle P.white3/Kobo Clara 2E
|
|
03-18-2024, 08:52 AM | #7 |
Guru
Posts: 769
Karma: 6528026
Join Date: Sep 2012
Device: Kobo Elipsa
|
Interesting. I have justification set to off, but I also have the "Un-Force user text-align in div,p tags in KePubs" patch enabled. Maybe that's what messes up centered images, although it doesn't seem to affect text in my case. One of these days, I'll have to experiment. I've been using margin-left/right: auto in the css, which seems to take care of it.
Edit: I just checked to see which patches I have enabled, and "Un-Force user text-align" isn't one of them. I must have stopped using that one at some point. I haven't noticed a problem with centering lately either, so who knows? Last edited by icallaci; 03-18-2024 at 09:03 AM. |
03-18-2024, 10:35 AM | #8 |
the rook, bossing Never.
Posts: 11,161
Karma: 85874891
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
|
margin-left and margin-right is best at zero (0) for centred anything in CSS
|
03-18-2024, 11:21 AM | #9 |
Grand Sorcerer
Posts: 10,144
Karma: 224760044
Join Date: Jan 2014
Location: Estonia
Device: Kobo Sage & Libra 2
|
Yes. Unfortunately I've seen lots of ebooks (mostly self-published) where there is centered text with a left or right margin >0 (not both margins, no, one of them) or a text indent >0. No piece of code is stupid enough not to use, it seems.
|
03-20-2024, 06:47 AM | #10 |
Zealot
Posts: 105
Karma: 6368
Join Date: Nov 2018
Location: Italy
Device: Kindle P.white3/Kobo Clara 2E
|
I did a little more testing..I can confirm you that just kepub format ignores
Code:
text-align: center; At this point, epub are better than kepub with a kobo. |
03-20-2024, 08:52 AM | #11 | |
Grand Sorcerer
Posts: 10,144
Karma: 224760044
Join Date: Jan 2014
Location: Estonia
Device: Kobo Sage & Libra 2
|
Quote:
|
|
03-20-2024, 11:13 AM | #12 | |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Quote:
The Kobo Adobe reading app, used for standard epub, applies override CSS: Code:
body {text-align: %1 !important;} Code:
div, p { text-align: %1 !important;} So if your epub's HTML/CSS for scenebreaks is something like: Code:
<p class="center">***</p> .center {text-align: center} There are similar (but not the same) CSS override differences between the epub and kepub reading apps for the other settings in the [Aa] menu, namely font-family and line-height. Whatever Kobo chooses as default CSS overrides some users will be upset. These users are at liberty to use existing kobopatches to change override CSS to something more (or less) heavy-handed. |
|
03-21-2024, 02:50 AM | #13 | |
Zealot
Posts: 105
Karma: 6368
Join Date: Nov 2018
Location: Italy
Device: Kindle P.white3/Kobo Clara 2E
|
Quote:
For God's sake no! Gosh.. no no. I 've never put myself in quicksands with patches, hacking or some similar stuff. |
|
03-21-2024, 04:10 AM | #14 |
Guru
Posts: 928
Karma: 2146660
Join Date: Nov 2011
Location: London, UK
Device: Kobo Aura, Kobo Aura ONE, Marvin 3
|
So the cleanest solution seems to me to use another HTML element that doesn't match the default non-patched kepub stylesheet, and then style that to be centred. For example:
Code:
<span class="centred">***</span> ... span.centred { display: block; text-align: center; /* etc */ } |
03-21-2024, 04:11 AM | #15 |
Wizard
Posts: 1,026
Karma: 11500112
Join Date: Sep 2022
Device: Kobo Libra 2
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
centered text having a specific width | Vroni | ePub | 18 | 08-07-2019 05:23 AM |
Conversion ePub -> azw3, text centered | apeiron75 | Calibre | 0 | 05-18-2013 12:28 PM |
Calibre screwing up centered-text b/c of forced tabs | lurker316 | Calibre | 0 | 12-21-2010 09:36 PM |
.epub hyperlinks, centered and non indented text. | Xabache | ePub | 2 | 09-13-2010 01:11 PM |
Centered and right aligned text for Stanza on iPhone | Arjen | ePub | 6 | 06-17-2010 12:19 PM |