Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader

Notices

Reply
 
Thread Tools Search this Thread
Old 05-29-2019, 03:10 PM   #106
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Quote:
Originally Posted by Gorcsev View Post
thank you

for item2: is it possible just to use "kobo_extra.css" in the device root directory (used by KTE) to override the CSS? (so I don't need patch)
I could be wrong but I don't see how. I think the (over-)aggressive* default firmware override may cancel out anything you put in kobo_extra.css.

Experimentation is probably the only way you'll find a definitive answer.

* Just a personal opinion, of course
jackie_w is offline   Reply With Quote
Old 05-29-2019, 05:55 PM   #107
lumpynose
Wizard
lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.
 
Posts: 1,086
Karma: 6719822
Join Date: Jul 2012
Device: Palm Pilot M105
Quote:
Originally Posted by jackie_w View Post
Kepubs do support both ligatures and kerning if you add the right line of CSS - body {text-rendering: optimizeLegibility;} - either by hand, via calibre driver or via patch. Ligatures/kerning will only be as good as the font you're using.
What about this CSS:

Code:
body {
  font-kerning: normal;
  font-variant: common-ligatures oldstyle-nums proportional-nums;
  font-feature-settings: "kern", "liga", "clig", "onum", "pnum";
}

h1, h2, h3 {
  font-variant: common-ligatures lining-nums proportional-nums;
  font-feature-settings: "kern", "liga", "clig", "lnum", "pnum";
}
This comes from (scroll down to Improve legibility):

https://friendsofepub.github.io/eBookTricks/
lumpynose is offline   Reply With Quote
Advert
Old 05-29-2019, 06:36 PM   #108
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Quote:
Originally Posted by lumpynose View Post
What about this CSS:

Code:
body {
  font-kerning: normal;
  font-variant: common-ligatures oldstyle-nums proportional-nums;
  font-feature-settings: "kern", "liga", "clig", "onum", "pnum";
}

h1, h2, h3 {
  font-variant: common-ligatures lining-nums proportional-nums;
  font-feature-settings: "kern", "liga", "clig", "lnum", "pnum";
}
This comes from (scroll down to Improve legibility):

https://friendsofepub.github.io/eBookTricks/
Why not try it and report back

I seem to remember, from 2-3 years ago when I was originally messing with this, that
Code:
-webkit-font-feature-settings: "liga"
did give standard ligatures in kepubs, but that "dlig" didn't work. I didn't try "kern" or any of the others in your example.

My final conclusion was that text-rendering: optimizeLegibility; was convenient for both ligatures and kerning and I've used it ever since.

Always willing to reconsider, though, if you discover a few golden nuggets.
jackie_w is offline   Reply With Quote
Old 05-29-2019, 07:20 PM   #109
lumpynose
Wizard
lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.
 
Posts: 1,086
Karma: 6719822
Join Date: Jul 2012
Device: Palm Pilot M105
Quote:
Originally Posted by jackie_w View Post
Why not try it and report back
Sorry, I did try it and it worked. I was wondering if there was anything it did that your suggestion didn't.

The lnum for headers is nice but I'm wondering how many fonts have both styles of numbers so that this would switch between them.

In any event I'm taking the scatter gun approach and using his and yours together.
lumpynose is offline   Reply With Quote
Old 05-31-2019, 11:37 AM   #110
Gorcsev
Enthusiast
Gorcsev began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Mar 2019
Device: Kobo Clara HD
Quote:
Originally Posted by jackie_w View Post

Item 1 needs to be done only once per Kobo device.
Item 2 needs to be done after every firmware update.
Item 3 needs to be done for every book which needs a monospace font.
Thank you, I made as you suggested. Works well. I am using with courier.
Gorcsev is offline   Reply With Quote
Advert
Old 05-31-2019, 12:36 PM   #111
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Quote:
Originally Posted by Gorcsev View Post
Thank you, I made as you suggested. Works well. I am using with courier.
Good to know.
jackie_w is offline   Reply With Quote
Old 06-01-2019, 10:07 AM   #112
Gorcsev
Enthusiast
Gorcsev began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Mar 2019
Device: Kobo Clara HD
Quote:
Originally Posted by jackie_w View Post
Good to know.
Once you uploaded two images what compares the weird character spacing in kebub, and with one of your tweak it was better handled. I am searching that post for a while but do not find, can you give me a hint where it is? :-)
Gorcsev is offline   Reply With Quote
Old 06-01-2019, 12:31 PM   #113
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Quote:
Originally Posted by Gorcsev View Post
Once you uploaded two images what compares the weird character spacing in kebub, and with one of your tweak it was better handled. I am searching that post for a while but do not find, can you give me a hint where it is? :-)
Is this old post the one you mean?
jackie_w is offline   Reply With Quote
Old 06-01-2019, 01:11 PM   #114
Gorcsev
Enthusiast
Gorcsev began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Mar 2019
Device: Kobo Clara HD
Quote:
Originally Posted by jackie_w View Post
Is this old post the one you mean?
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?
Gorcsev is offline   Reply With Quote
Old 06-02-2019, 08:17 AM   #115
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Quote:
Originally Posted by Gorcsev View Post
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...
  1. Find the place in container.py where you hacked the original code to
    Code:
                    groups = [text]
    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.

  2. 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

  3. 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.


  4. 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.
jackie_w is offline   Reply With Quote
Old 06-02-2019, 03:03 PM   #116
Gorcsev
Enthusiast
Gorcsev began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Mar 2019
Device: Kobo Clara HD
Quote:
Originally Posted by jackie_w View Post
[*]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.[/LIST]
Thank you I see I will play a lot. :-)

One weird formatting experience what I have: I placed a hyphen dictionary, what I found here in another topic. Works quite well. (I hope with your tweaks Kobo will be "forced" to hyphenate often). What I do not understand: in the dic, is coded lefthyphens, righthyphens 2 and 2. I was given the same in the hyphenate.css as well. (just for sure) And I saw just ONE character after the hyphen. That looks weird.

Additionally for my eyes seems that in short words, sometimes after hyphens "stretches" Kobo (Makes "spaces" between characters. Not to mention a lot of time discussing "spaces" next to dashes.)
Gorcsev is offline   Reply With Quote
Old 06-03-2019, 08:18 AM   #117
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Quote:
Originally Posted by Gorcsev View Post
One weird formatting experience what I have: I placed a hyphen dictionary, what I found here in another topic. Works quite well. (I hope with your tweaks Kobo will be "forced" to hyphenate often). What I do not understand: in the dic, is coded lefthyphens, righthyphens 2 and 2. I was given the same in the hyphenate.css as well. (just for sure) And I saw just ONE character after the hyphen. That looks weird.
I think there may be a few things going on here.

I'm not sure that kepubs take any notice of the LEFTHYPHENMIN, RIGHTHYPHENMIN stuff coded at the top of the hyphenation dictionary. Epubs may use it but I'm not really sure.

Kepubs do respond to CSS styles such as
Code:
-webkit-hyphenate-limit-after: 3;
-webkit-hyphenate-limit-before: 3;
I don't use this file myself but the hyphenation.css file in the official KoboTouchExtended driver uses
Code:
-webkit-hyphenate-after: 3;
-webkit-hyphenate-before: 3;
which looks like an error to me. You could correct your own copy. You could also use kobo_extra.css to add these CSS styles.

If you don't use these styles at all, I expect default values will be used. I'm not sure what these are but I suspect 2. I use values of 3 myself because I got fed up of seeing things like:
Code:
an-
yone

th-
ing
Even so, kepub hyphenation has never seemed quite as good as epub hyphenation. It sometimes seems that they include punctuation in the character counts. e.g. if you do use -webkit-hyphenate-limit-after: 3 you might still see something like
Code:
He likes to use punctuati-
on.
jackie_w is offline   Reply With Quote
Old 06-03-2019, 01:41 PM   #118
Gorcsev
Enthusiast
Gorcsev began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Mar 2019
Device: Kobo Clara HD
Quote:
Originally Posted by jackie_w View Post

Code:
-webkit-hyphenate-limit-after: 3;
-webkit-hyphenate-limit-before: 3;
I don't use this file myself but the hyphenation.css file in the official KoboTouchExtended driver uses
Code:
-webkit-hyphenate-after: 3;
-webkit-hyphenate-before: 3;
which looks like an error to me. You could correct your own copy. You could also use kobo_extra.css to add these CSS styles.
You should be right, in this page https://friendsofepub.github.io/eBookTricks/ is documented in the way as you told. I was curious and found that the kepubify source code has the same error.

Quote:
Originally Posted by jackie_w View Post

Even so, kepub hyphenation has never seemed quite as good as epub hyphenation. It sometimes seems that they include punctuation in the character counts. e.g. if you do use -webkit-hyphenate-limit-after: 3 you might still see something like
Code:
He likes to use punctuati-
on.
This is happening in my book, the one char was followed by a point.
In the other thread, someone mentioned that in the metadata given language code determines which dictionary will be used for hyphenation. I am defining the language in the body element. I don't know which is correct I will use both for be on the safe side.

I will try the

hyphenate-limit-chars: 6 3 2;
-webkit-hyphenate-limit-lines: 2;
hyphenate-limit-lines: 2;

Quote from Blitz
"to improve hyphenation. You can indeed set the minimum number of letters a word must contain to be hyphenated, and the minimum number of letters which should be before and after the hyphen.

Finally, you can control the maximum number of consecutive lines for which hyphenation must happen. As Bringhurst advised, “avoid more than three consecutive hyphenated lines.”"
Gorcsev is offline   Reply With Quote
Old 06-03-2019, 01:59 PM   #119
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Quote:
Originally Posted by Gorcsev View Post
-webkit-hyphenate-limit-lines: 2;
Just a personal comment about this. It may work very well, however, I deliberately don't use this style because I figure kepubs need all the help they can get to keep word spacing looking good. If I occasionally have to look at hyphens at the end of 3 consecutive lines, so be it.

Last edited by jackie_w; 06-03-2019 at 02:05 PM.
jackie_w is offline   Reply With Quote
Old 06-03-2019, 02:09 PM   #120
Gorcsev
Enthusiast
Gorcsev began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Mar 2019
Device: Kobo Clara HD
Quote:
Originally Posted by jackie_w View Post
Just a personal comment about this. It may work very well, however, I deliberately don't use this style because I figure kepubs need all the help they can get to keep word spacing looking good. If I occasionally have to look at hyphens at the end of 3 consecutive lines, so be it.
Thank you, you made this trip already :-), seems my intentions are similar.

I feel somehow about kebup/epub like someone invented the wheel (epub) and the new one not works to let run it smoother, but reinvents the wheel again (kepub) just with looking better but not running as well like the original one.
Gorcsev is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
3.26.1 not converting Kepub format RZetlin Conversion 2 06-26-2018 02:47 AM
Aura H2O trying kepub and have questions Shadowjack Kobo Reader 25 12-26-2017 04:30 AM
Glo Question regarding kepub format user2178319 Kobo Reader 18 05-14-2015 12:48 PM
Kepub format and Koreader gontofe Kobo Reader 4 08-20-2014 09:10 AM
Harry Potter KePUB format Gazella Conversion 19 04-13-2014 06:54 AM


All times are GMT -4. The time now is 11:32 AM.


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