Quote:
Originally Posted by Gorcsev
Thanks, that's it. I think it is made with your "one node-one span" hack in KTE what you shared earlier and I also built into my version of the container.py.
Later in this thread, you said the leading/trailing spaces replacement out of the spans helps more. (btw. a similar thing is commented as a TODO in the original code itself as well, just there are thoughts about putting the trailing space into the next span as I understood well.)
Is your tweak code "space out from span" is shareable for experimenting?
|
If you're game for a bit more hacking you can try the following...
- Find the place in container.py where you hacked the original code to
and change it to
Code:
# reduce multiple normal spaces to a single space
text = re.sub(r'[ ]{2,}', r' ', text)
groups = [text]
This is to combat a bizarre-but-true discovery that multiple consecutive normal spaces in the HTML text content can do weird things to the evenness of word spacing in a kepub paragraph.
- This is the kobospan trailing spaces hack. A bit lower down the same chunk of code, where you see:
Code:
span.text = g
node.append(span)
self.__segment_counter += 1
change it to
Code:
# move any trailing spaces outside the kobospan
left = g.rstrip()
span.text = left
if len(g) > len(left):
span.tail = g[len(left):]
node.append(span)
self.__segment_counter += 1
- The kobospan leading space hack is more tricky. I don't know how to explain this in a non-geeky way, but the problem arises when switching between hacking using a parsed HTML page and hacking using a non-parsed HTML page. Switching can be done but great care is needed.
The 2 kobospan hacks, one-per-node and trailing spaces, are examples of parsed hacks.
The kobospan leading space hack needs a non-parsed hack using simple regex on raw text. I can't think of a simple way to do it with a parsed hack, but I could be wrong. As my KTE is very different from the official one I can't just post my own solution. I'll need to give this more thought over the next few days. If I can think of a safe way of doing it with the official KTE I'll PM you.
- Whilst you're in experimental mood, there is another simple technique you can try to manipulate word spacing in kepubs.
In your kobo_exta.css file you can add something like
Code:
body>div#book-columns>div#book-inner {
word-spacing: -0.05em;
}
The bigger the negative value the smaller the gaps between words. My good friend Google tells me that the default value for word spacing is 0.25em, so the above CSS should reduce it to 0.2em.
Caveat: if you make it too big some words will get fused together and you don't want that! Do lots of testing before re-transferring your whole library.