Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader > Kobo Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 04-15-2014, 01:04 PM   #16
GeoffR
Wizard
GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.
 
GeoffR's Avatar
 
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
∃, ∀, ∧, ∨, ¬, are all present in Kobo's built-in Ryumin and Gothic fonts.

However in general I think embedding a subset of a font with all the symbols you need is the right way to go. And for mathematics, rather than just using individual symbols from the embedded font, I would put the whole expression including numerals and variables in the embedded font, because some standard fonts (e.g. Georgia) have lower-case style numerals that look bad in mathematical expressions, or the user might have cranked the font weight up so high that it is hard to distinguish regular from bold variables, etc.

Edit: You might like to look at the STIX fonts: http://www.ctan.org/pkg/stix for either embedding in epubs or sideloading to your Kobo.

Last edited by GeoffR; 04-15-2014 at 01:30 PM. Reason: Add link to STIX fonts
GeoffR is offline   Reply With Quote
Old 04-16-2014, 10:20 AM   #17
8140david
Connoisseur
8140david began at the beginning.
 
Posts: 54
Karma: 10
Join Date: Mar 2014
Device: none
Thanks for the comments and for suggesting the Stix font, which is very nice, and complete for mathematics.

To sum up
I downloaded the font here:
http://www.ctan.org/pkg/stix)
Then I created a trimmed version (stix-regular-webfont.ttf) with only the symbols I need plus English here:
http://www.fontsquirrel.com/tools/webfont-generator
This reduces the size a lot.

For mathematical symbols and formulas, I've specified the following in my CSS:
Code:
@font-face
    {
    font-family: 'StixRegular';
    src: url('../Fonts/stix-regular-webfont.ttf');
    }
.maths
    {
    font-family: 'StixRegular';
    }
Then in the xhtml pages of my epub, I've embeded isolated symbols and complete formulas in this way:
Code:
<span class="maths">∧∨∃∀→↔≡≤<¬σ∪</span>
Everything is now displayed correctly and nicely on my Kobo Aura, as well as on my computer with FBReader. Hopefully, it will also appear nicely on other readers.

PS: Alternatively, I could have specified, in the CSS, that the entire text should be in StixRegular. But this would presumably give readers "less freedom" to change fonts on their reader: using a specific font on a reader, say Georgia, might make it impossible to see some mathematical characters not contained in Georgia.

Last edited by 8140david; 04-16-2014 at 10:26 AM.
8140david is offline   Reply With Quote
Advert
Old 04-16-2014, 11:33 AM   #18
Lucas Malor
Pain in the arse
Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.
 
Lucas Malor's Avatar
 
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
Quote:
Originally Posted by GeoffR View Post
And for mathematics, rather than just using individual symbols from the embedded font, I would put the whole expression including numerals and variables in the embedded font, because some standard fonts (e.g. Georgia) have lower-case style numerals that look bad in mathematical expressions, or the user might have cranked the font weight up so high that it is hard to distinguish regular from bold variables, etc.
indeed this is the standard in Latex, if I remember well. But it's hard to do if your document has no CSS class for formulas only.

@8140david: sorry for the suggestion of DejaVu. Since it's a popular unicode font I wrongly supposed it has also all math symbols. Unfortunately math will be never popular.
Lucas Malor is offline   Reply With Quote
Old 04-16-2014, 12:34 PM   #19
8140david
Connoisseur
8140david began at the beginning.
 
Posts: 54
Karma: 10
Join Date: Mar 2014
Device: none
By the way, I just noticed that Sigil offers reports about the epub.
Among them, one is "Characters in the files"; in my case:
Code:
!"#&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz~*§¬°ÀÇÉÊàâäçèéêëîïôöùûüœσ—‘’…→↔↵∀∃∧∨∪≡≤
This makes it easy to select which characters to include when trimming a font.
8140david is offline   Reply With Quote
Old 04-16-2014, 01:12 PM   #20
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 8140david View Post
This makes it easy to select which characters to include when trimming a font.
Another option if you also happen to be a calibre user, the calibre epub/azw3 Editor has an option to subset any embedded fonts (i.e. auto-remove unused characters). The same option is also included in the calibre Polish feature (that's Polish as in "shine" not Polish the language BTW) if you want to font subset many epub/azw3 books in one go.
jackie_w is offline   Reply With Quote
Advert
Old 04-16-2014, 01:22 PM   #21
Lucas Malor
Pain in the arse
Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.
 
Lucas Malor's Avatar
 
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
An idea: I think a Calibre plugin could extract fonts in documents you have on Kobo and install them on the device. This way you'll save space without trimming fonts.
Lucas Malor is offline   Reply With Quote
Old 04-16-2014, 01:36 PM   #22
PeterT
Grand Sorcerer
PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.
 
PeterT's Avatar
 
Posts: 12,228
Karma: 74000000
Join Date: Nov 2007
Location: Toronto
Device: Nexus 7, Clara, Touch, Tolino EPOS
One MAJOR problem with the extracting of fonts and installing them would be if the font was subsetted, then installation of it would probably not have the desired effect for other books.
PeterT is offline   Reply With Quote
Old 04-16-2014, 02:03 PM   #23
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
You don't need a calibre plugin to make your epubs access a font sideloaded into the Kobo's /fonts directory - instead of embedded into the actual epub. All that should be required is
  • Rename the Stix Maths font to Kobo standards, probably STIX Math-Regular.otf (case sensitive)
    and copy it to /fonts on the Kobo - followed by a reboot as it's a new font.
  • a slight change to the @font-face css, namely
    Code:
    @font-face
        {
        font-family: "StixRegular";
        src: url("res:///fonts/normal/STIX Math")
        }
    .maths
        {
        font-family: "StixRegular";
        }
The red names MUST match exactly the internal font name of the Stix font file. The blue names can be anything (alphanumeric I think) as long as they match each other.

Again FYI, if you're a calibre user, you can have the above css automatically added to epubs during the calibre/Kobo send-to-device process, leaving the calibre master epub unchanged.

However, I think the OP wanted to embed the font so that it would be sure to work on any epub reading device/app not just the Kobo.
jackie_w is offline   Reply With Quote
Old 04-16-2014, 02:49 PM   #24
Lucas Malor
Pain in the arse
Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.
 
Lucas Malor's Avatar
 
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
Quote:
Originally Posted by PeterT View Post
One MAJOR problem with the extracting of fonts and installing them would be if the font was subsetted, then installation of it would probably not have the desired effect for other books.
Yes, this is the greatest problem. You could simply check the font file size, but it seems unreliable to me. A better approach is to compare supported chars. I think it could be done using fontforge py module.
Lucas Malor is offline   Reply With Quote
Old 04-16-2014, 02:53 PM   #25
Lucas Malor
Pain in the arse
Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.
 
Lucas Malor's Avatar
 
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
Quote:
Originally Posted by jackie_w View Post
Again FYI, if you're a calibre user, you can have the above css automatically added to epubs during the calibre/Kobo send-to-device process, leaving the calibre master epub unchanged.
Do you mean you can already do this automatically with Calibre?

EDIT: I didn't find that option in Calibre for now. Anyway, what I'm thinking about is not a simple CSS change, but also an automatic extraction and installation of fonts for the entire collection.

Anyway, as you pointed out, this is slightly OT

Last edited by Lucas Malor; 04-16-2014 at 03:22 PM.
Lucas Malor is offline   Reply With Quote
Old 04-16-2014, 03:46 PM   #26
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 Lucas Malor View Post
EDIT: I didn't find that option in Calibre for now.
If you want to investigate further it's an option in the standard Kobo driver.
jackie_w is offline   Reply With Quote
Old 04-16-2014, 03:49 PM   #27
Geco
Zealot
Geco doesn't litterGeco doesn't litter
 
Posts: 112
Karma: 100
Join Date: Aug 2011
Device: Touch, Aura
Another possibility I saw on my Kobo Touch (not sure it works on Aura as well but, why not?!). I've created a "fonts" folder in the root directory of Kobo (when connected through USB, obviously) the I've put the Unifont TTF file you can download from here http://unifoundry.com/pub/unifont-6....3.20140214.ttf and when reading books in Japanese language (before Rakuten and Japanese firmware), the firmware was able to automagically select such font for symbols that were unknown or unavailable in the font I was using for reading.
I still using this font (by selecting it through the menu) for novels and so on. Obviously technical books with programming languages and things like that are better with "default" one due to normal text, fixed width and so on. But still, Unifont is "the whole" human-readable character set... and it's also free as in GPL! So if you have symbols problems, take a look.

NOTE: the font it's hugely huge (>10MB but contains glyphs for every printable code point in the Unicode 6.3 Basic Multilingual Plane (BMP). The BMP occupies the first 65,536 code points of the Unicode space, denoted as U+0000..U+FFFF.)
Geco is offline   Reply With Quote
Old 04-16-2014, 09:31 PM   #28
8140david
Connoisseur
8140david began at the beginning.
 
Posts: 54
Karma: 10
Join Date: Mar 2014
Device: none
Thanks all for these interesting suggestions!
If I have problems reading some epub on my Kobo Aura, I'll try them.

But concerning my particular issue for now, jackie_w is right:
Quote:
Originally Posted by jackie_w
I think the OP wanted to embed the font so that it would be sure to work on any epub reading device/app not just the Kobo.
The fact that Calibre can trim a font for a particular document (or set of documents) is nice in this regard: no need to use the site I was mentioning, and the trimming is optimized to the specific characters used.
Of course, as mentioned here and there, trimming is a good idea only when one is sure that the text of the epub is final (won't be modified).
When one is not, it's safer to embed the entire font needed (or a sufficient large subset of it).

Last edited by 8140david; 04-16-2014 at 09:48 PM.
8140david is offline   Reply With Quote
Old 04-17-2014, 12:27 AM   #29
GeoffR
Wizard
GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.
 
GeoffR's Avatar
 
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
I think a good way to do it is to embed the whole font, and select the embedded font at body level to make it the document default font (i.e. body {font-family: 'STIX'} ), and also select it for those special spans/paragraphs where you need the mathematical symbols.

This way if the reader chooses the "Document Default" font they see the whole book in the embedded font, but if they choose another font such as Georgia then they see the main text in Georgia but the special spans/paragraphs will still be in the embedded font.
GeoffR is offline   Reply With Quote
Old 04-17-2014, 01:23 AM   #30
8140david
Connoisseur
8140david began at the beginning.
 
Posts: 54
Karma: 10
Join Date: Mar 2014
Device: none
This makes sense, thanks.

I was toying with the idea but didn't want to trim 3 fonts (regular, bold, italic) on the website I was mentioning, as this is a rather slow operation. But doing it with Calibre is easy and very quick, so I've done it.

And it works!
I personnally prefer to use the Georgia font on my Kobo Aura.
But it's also fine with the document default, in this case, Stix.

So here are the current declarations concerning Stix in the css of the epub (I didn't need bold italic):
Code:
@font-face
    {
    font-family: 'Stix';
    font-weight: normal;
    font-style: normal;
    src: url('../Fonts/STIX-Regular.otf');
    }
@font-face
    {
    font-family: 'Stix';
    font-weight: normal;
    font-style: italic;
    src: url('../Fonts/STIX-Italic.otf');
    }
@font-face
    {
    font-family: 'Stix';
    font-weight: bold;
    font-style: normal;
    src: url('../Fonts/STIX-Bold.otf');
    }
body
    {
    font-family: 'Stix'
    }
.maths
    {
    font-family: 'Stix';
    }

Last edited by 8140david; 04-17-2014 at 01:36 AM.
8140david is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Aura HD Kobo Glo/Aura/Aura HD future firmware feature request thread arspr Kobo Reader 25 03-26-2015 05:19 AM
KOBO AURA HD vs the KOBO AURA and Paperwhite 1 Josieb1 Kobo Reader 81 05-04-2014 01:52 PM
Dymo tape fix for eBay Kobo Aura and Aura HD covers RobertJSawyer Kobo Reader 2 02-10-2014 10:34 AM
Canadian shoppers discount on kobo aura and aura hd eejit Deals and Resources (No Self-Promotion or Affiliate Links) 4 11-28-2013 01:43 AM
Conversion from azw (Kindle) to epub (Kobo) format with Calibre garbages symbols myildi Conversion 2 09-13-2013 03:19 AM


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


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