Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 08-20-2023, 05:19 AM   #1
Zillion_
Enthusiast
Zillion_ began at the beginning.
 
Posts: 29
Karma: 10
Join Date: Jul 2023
Device: KindleOasis10thGen
KFX: centered 'transition' too much to the left

Hello,

another KFX-weirdness on the Kindle.
I use an EM Dash as a character for Transitions / Scene Breaks.

On the Kindle Reader using KFX format e-books, the dash is always about 1 cm too much to the left (see screenshot) if I set negative margins (more on that below).
No such problem with AZW3 or the Calibre viewer.
Even if the EM Dash is in a blockquote with other text that is properly centered, the dash itself is about 1 cm to the left of the center.
No text indents, no padding, etc.

After some playing with settings I noticed the following:

- confirmed: issue only appears with KFX format on Kindle. You can't see it with AZW3 files, nor in the Calibre viewer.

- issue appears when I use negative margins on body text during conversion from ePub to KFX (I do this to reduce the way-too-large-for-me Kindle default margins which really annoy me).

- same issue if I use other characters
- the issue doe NOT occur, however, with full paragraphs of text used e.g. in a Chapter intro, quotes or poems. They are all centered correctly.
- I first though the issue did not affect "<hr>" lines, but it does -- only less strongly - they move less far to the left and only when I set stupidly low negative margins, not my normal "-1.5".

- code for negative margins during conversion ("extra CSS"):

Code:
.calibre {
  display: block;
  padding-left: 0;
  padding-right: 0;
  text-align: justify;
  margin: 0;
  text-indent: 0;
  font-size: 1em;
  margin-left: -1.5em !important;
  margin-right: -1.5em !important;
}
.Body {
  display: block;
  text-align: justify;
  text-indent: 0;
  margin-top: 0.3em;
  margin-bottom: 0.3em;
  font-size: 1em;
}
This code applies negative margins to the "calibre" class, which is applied through the <Body class="calibre"> tag on each page.

Screenshots attached:
- result with margin-left and margin-right in Extra Css set to 0
- with -2.5
- with -5.5
- with -5.5 in AZW3 format: which results in "0", because the negative margins through this method don't work in AZW3 at all...

Please note that the centered text lines are not affected by this bug.
Use the Kindle clock above each screenshots as a reference for where the center should be.


Anybody got any idea why this happens, and if there could be a workaround ?

p.s. I'd rather not use images as scene breaks, because they cause the whole Kindle screen to flash (full page refresh). I've tried other text characters instead of the EM Dash, to no avail.

p.p.s. The trick with setting negative L&R margins through Extra CSS on the "calibre" tag only works with KFX, not with AZW3, and is one of the reasons I try to stick to KFX, the other being the hyphenation, X-ray, Wordwise and "about this book" features.
Attached Thumbnails
Click image for larger version

Name:	margins_0.png
Views:	148
Size:	54.8 KB
ID:	203230   Click image for larger version

Name:	margins_-2.5.png
Views:	120
Size:	53.5 KB
ID:	203231   Click image for larger version

Name:	margins_-5.5.png
Views:	147
Size:	52.9 KB
ID:	203232   Click image for larger version

Name:	margins_-5.5_AZW3.png
Views:	132
Size:	61.5 KB
ID:	203233  
Zillion_ is offline   Reply With Quote
Old 08-21-2023, 05:10 AM   #2
Zillion_
Enthusiast
Zillion_ began at the beginning.
 
Posts: 29
Karma: 10
Join Date: Jul 2023
Device: KindleOasis10thGen
I've actually found a sort of workaround using the following code for my Transitions or Scene Breaks:

Code:
<div style="margin-left:1em;margin-right:1em;text-align:center;margin-top:1.5em;margin-bottom:1.5em"> — </div>
... this causes the scene break to be formatted without the negative l & r margins which I apply to my other text (in order to reduce Kindle's default margins)...
Zillion_ is offline   Reply With Quote
Advert
Old 08-25-2023, 05:15 PM   #3
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 7,071
Karma: 91577715
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
I did some testing and I can verify that the KFX renderer has a bug that sometimes causes centered text to be rendered off-center if the block element is styled with negative left and right margins. The problem is worst with short text and large negative margins.

In the attached example all of the lines text should be centered. As the length of each line increases the centering becomes more accurate.

This is not a problem with conversion to KFX. The formatting in the KFX file is correct. It is the KFX reading software that is failing to center the text properly.

I doubt Amazon is going to do anything to fix this since this situation does not come up with books that are properly formatted for publishing.
Attached Thumbnails
Click image for larger version

Name:	uncentered.jpg
Views:	108
Size:	34.0 KB
ID:	203352  

Last edited by jhowell; 08-25-2023 at 05:46 PM.
jhowell is offline   Reply With Quote
Old 08-25-2023, 07:49 PM   #4
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,752
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by Zillion_ View Post
Hello,

another KFX-weirdness on the Kindle.
I use an EM Dash as a character for Transitions / Scene Breaks.

On the Kindle Reader using KFX format e-books, the dash is always about 1 cm too much to the left (see screenshot) if I set negative margins (more on that below).
No such problem with AZW3 or the Calibre viewer.
Even if the EM Dash is in a blockquote with other text that is properly centered, the dash itself is about 1 cm to the left of the center.
No text indents, no padding, etc.

After some playing with settings I noticed the following:

- confirmed: issue only appears with KFX format on Kindle. You can't see it with AZW3 files, nor in the Calibre viewer.

- issue appears when I use negative margins on body text during conversion from ePub to KFX (I do this to reduce the way-too-large-for-me Kindle default margins which really annoy me).

- same issue if I use other characters
- the issue doe NOT occur, however, with full paragraphs of text used e.g. in a Chapter intro, quotes or poems. They are all centered correctly.
- I first though the issue did not affect "<hr>" lines, but it does -- only less strongly - they move less far to the left and only when I set stupidly low negative margins, not my normal "-1.5".

- code for negative margins during conversion ("extra CSS"):

Code:
.calibre {
  display: block;
  padding-left: 0;
  padding-right: 0;
  text-align: justify;
  margin: 0;
  text-indent: 0;
  font-size: 1em;
  margin-left: -1.5em !important;
  margin-right: -1.5em !important;
}
.Body {
  display: block;
  text-align: justify;
  text-indent: 0;
  margin-top: 0.3em;
  margin-bottom: 0.3em;
  font-size: 1em;
}
This code applies negative margins to the "calibre" class, which is applied through the <Body class="calibre"> tag on each page.

Screenshots attached:
- result with margin-left and margin-right in Extra Css set to 0
- with -2.5
- with -5.5
- with -5.5 in AZW3 format: which results in "0", because the negative margins through this method don't work in AZW3 at all...

Please note that the centered text lines are not affected by this bug.
Use the Kindle clock above each screenshots as a reference for where the center should be.


Anybody got any idea why this happens, and if there could be a workaround ?

p.s. I'd rather not use images as scene breaks, because they cause the whole Kindle screen to flash (full page refresh). I've tried other text characters instead of the EM Dash, to no avail.

p.p.s. The trick with setting negative L&R margins through Extra CSS on the "calibre" tag only works with KFX, not with AZW3, and is one of the reasons I try to stick to KFX, the other being the hyphenation, X-ray, Wordwise and "about this book" features.
I don't recall why the line marked !important was added to the CSS code, but it did fix something at some point. Try it and see if it fixes your problem.
Code:
html {
  margin-right: -45px;
  margin-left: -45px;
  break-inside: avoid !important;
}
JSWolf is offline   Reply With Quote
Reply

Tags
kfx kindle center margins


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Left alignment with centered images shoelesshunter Kobo Reader 0 10-18-2019 03:22 PM
KFX to KFX to remove DRM Tomifonication Conversion 12 08-09-2018 01:32 PM
centered title page and chapter numbers display left in epub JohnMurphy99 Introduce Yourself 1 06-04-2017 06:33 AM
Centered but left align? mtrahan ePub 15 04-01-2012 03:56 PM


All times are GMT -4. The time now is 08:59 AM.


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