https://bugs.kde.org/show_bug.cgi?id=461390

mil...@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mil...@gmail.com

--- Comment #1 from mil...@gmail.com ---
still an issue

Okular Version 23.08.5
EPub Backend Version 0.2.3

sample epub file
https://annas-archive.org/md5/6985fb6687007f71313d73356e71dbcc

on page 2 there are 2 lines

»Sei du selbst die Veränderung, die du dir wünschst für diese Welt« 
Mahatma Ghandi (1869–1948)

for the curious, the quote translates to
"Be the change you want to see in the world"

html: OEBPS/xhtml/halftitle.html

<p class="noindentd1"><i>»Sei du selbst die Veränderung ...«</i></p>
<p class="right">Mahatma Ghandi (1869–1948)</p>

css: OEBPS/css/9783280037188.css

.noindentd1 { font-size: 1em; }
.right { font-size: .9em; }

line 1 has normal size
line 2 is too large

line 1 has height 21px
line 2 has height 186px

186px should be 19px
so apparently
font-size: .9em
is parsed as
font-size: 9em

workaround: convert font size from short float to full float

#!/usr/bin/env python3
# convert css font size from short float to full float
# fix too large fonts in okular
import re
import sys
with open(sys.argv[1], "r") as f:
    css = f.read()
def replace(match):
    a, b, c = match.groups()
    #b = str(round(float(b) * 100)) + "%" # convert em to percent
    b = str(float(b)) + "em" # convert short float to full float: .9 to 0.9
    return a + b + c
css =
re.sub(r"(font-size:\s*)([0-9]+|[0-9]+\.|\.[0-9]+|[0-9]+\.[0-9]+)em(\s*;)",
replace, css, re.S)
print(css)

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to