View Single Post
Old 09-10-2016, 02:18 AM   #14
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by eggheadbooks1 View Post
I don't how to make a subset of the font, that only includes the one character, to embed. Though that would be good to know for future issues. I'll google it.
There are quite a few methods to subset fonts, but Calibre made it super easy.

After you have the fonts in your EPUB + correct CSS, you could either:
  • Right click a book in your library and press "Polish Books" -> "Subset all embedded fonts".
  • If you have the book open in the Calibre Editor, press "Tools" -> "Subset Embedded Fonts"

Open Source Fonts

There are plenty of free fonts you can choose from to embed:

https://en.wikipedia.org/wiki/Open-s...code_typefaces

One of the fonts that includes the ♫ is Deja Vu Sans, which can be downloaded here:

http://dejavu-fonts.org/wiki/Main_Page

You can easily add the OTF or TTF fonts to the EPUB just like you add any other file. Then you just have to make sure to properly add the references to CSS.

Example Musical Notes EPUB

Here is example code (sample EPUBs attached to this post):

Quote:
<p><span class="musicnote">♩</span> &amp;#x2669; Unicode Character 'QUARTER NOTE' (U+2669)</p>

<p><span class="musicnote">♪</span> &amp;#x266a; Unicode Character 'EIGHTH NOTE' (U+266A)</p>

<p><span class="musicnote">♫</span> &amp;#x266b; Unicode Character 'BEAMED EIGHTH NOTES' (U+266B)</p>

<p><span class="musicnote">♬</span> &amp;#x266c; Unicode Character 'BEAMED SIXTEENTH NOTES' (U+266C)</p>

<p class="NoIndent">When you see this symbol <span class="musicnote">♫</span> in the chapter, listen to the song that accompanies the story.</p>
Here is the CSS you need to tell the musical notes to use "Deja Vu Sans" as the font:

Quote:
@font-face {
font-family: 'DejaVuSans';
font-style: normal;
font-weight: normal;
src: url(../Fonts/DejaVuSans.ttf);
}

.musicnote {
font-family: 'DejaVuSans', serif;
}
I attached 3 EPUBs:
  • [NoFont]
    • This is just the HTML, no CSS.
  • [YesFont]
    • This includes the entire "Deja Vu Sans" font (739.33 KB).
    • Total EPUB Size: 373.0 KB.
  • [YesSubsetFont]
    • I subset this using Calibre, and the font became 175.01 KB.
    • Total EPUB Size: 62.8 KB.

ADE Before/After:

Click image for larger version

Name:	ADEBefore.png
Views:	585
Size:	58.2 KB
ID:	151482 Click image for larger version

Name:	ADEAfter.png
Views:	552
Size:	57.6 KB
ID:	151481

Kindle Before/After:

Click image for larger version

Name:	KindleBefore.png
Views:	556
Size:	43.7 KB
ID:	151484 Click image for larger version

Name:	KindleAfter.png
Views:	564
Size:	44.6 KB
ID:	151483

Quote:
Originally Posted by eggheadbooks1 View Post
I did not embed the Unicode font in the ePub; I was hoping it would work automatically as it does in the Kindle (as per Doitsu's post). It didn't. So I am using a GIF for the ePub. Works just as well now that I tweaked the code.
In the topic I linked to there was a bit of discussion of many of the Pros/Cons of the different methods (Font/Bitmap/Vector). I will just mention a few of the downfalls of the Bitmap method off the top of my head:
  • Not searchable
  • Not copy/pastable
  • Doesn't work well with Text-to-Speech (well... you could add an alt to your <img>)
  • Doesn't match user preferences
    • The user might want to read in a different color font .
    • Might not work well in Night Mode (could have a huge white background behind the image).
  • Doesn't upscale/downscale well (unless SVG)

As you can probably see, many of the cons are sort of "hidden" from plain view. The images LOOK/WORK fine on the surface, but underneath, there are issues that creep up.
Attached Files
File Type: epub MusicNotes[NoFont].epub (2.0 KB, 480 views)
File Type: epub MusicNotes[YesFont].epub (373.0 KB, 453 views)
File Type: epub MusicNotes[YesSubsetFont].epub (62.8 KB, 459 views)

Last edited by Tex2002ans; 09-10-2016 at 02:49 AM.
Tex2002ans is offline   Reply With Quote