View Single Post
Old 05-23-2021, 06:47 AM   #4
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 shibuyaloren View Post
Hi everyone, I'm a newbie to both eBook formatting and Calibre, but willing to learn!
Fantastic. Welcome to MobileRead!

Quote:
Originally Posted by shibuyaloren View Post
There are several instances of Japanese kanji characters in the book that show up fine in Calibre and in Kindle Previewer. However, when I send it over to my Kobo Libre, the Japanese text is deleted out. (Doesn't display as a blank or as weird characters; just vanishes entirely.)

[...]

I was trying to follow directions to embed the fonts after seeing older posts in this forum, thinking that might be a fix, [...].

Can someone nudge me in the right direction?
Do I have the thread for you:

2020: "Should Chinese Fonts be Embedded in Ebooks?"

I was working on a few journal articles that had a handful of Chinese/Japanese characters.

The topic goes into a lot of technical discussion though, so I'll try to create a more easy tutorial here.

* * *

This is what you'll do:

1. Use Proper HTML Language in Your Document

Add this code around all your Japanese text:

Code:
<span class="japanese" lang="ja" xml:lang="ja">返</span>
Don't be scared. Let me break this down into its 3 main pieces:
  • <span class="japanese">
    • Helps you apply CSS + fonts later.
  • lang="ja" xml:lang="ja"
    • Says "Hey! I'm Japanese text!"
    • Note: Every language uses different 2-letter codes. So you'll need to change if you're doing Korean ("ko") or Chinese ("zh") or Vietnamese ("vi").

    • Where you put your actual "foreign" characters.

2. Find Font That Includes Characters You Need

A big list of CJK fonts can be found on Wikipedia:

https://en.wikipedia.org/wiki/List_of_CJK_fonts

For example, the "Source Han" or "Noto" fonts have a license that allows you to embed them in ebooks for free.

3. Download the OTF or TTF

Once you've chosen your font, download the OTF or TTF versions. (This is the format needed for EPUBs.)

For example, here is the latest page for "Source Han Sans":

https://github.com/adobe-fonts/sourc...ses/tag/2.004R

(As of today, it's v2.004. Yes, fonts have version numbers + they get updated/fixed!)

Every font will be slightly different in organization/naming conventions...

But in this case, you want to download:
  • Static Language Specific OTFs
    • Note: This will be a huge 765 MB file.

Unzip the file, and you'll see multiple folders. What you want is buried in OTF:

- SourceHanSans
-- OTF
--- Japanese
---- SourceHanSans-Regular.otf

You can install that font to your computer and/or you can use that file to shove into your ebook.

4. Add the CSS

Now, you want to go back into your EPUB.

This time, we'll adjust the CSS.

In your CSS file, add this:

Code:
span.japanese {
	font-family: "Source Han Sans", sans-serif;
}
Remember when we did the <span class="japanese"> code above?

This says to use the font ONLY for those specific pieces.

And in plain English, the code says:

"For every <span> that has a class named 'japanese': Use the font Source Han Sans. If you can't find that, use the device's default sans-serif font."

5. Insert Font Into Your EPUB

5.1. If you're using Calibre:
  • Tools > Embed Referenced Fonts

or you can:
  • File > Import Files into Book
    • Find + add the font's OTF file.

5.2. If you're using Sigil:

5.3. Or you can manually put this at the top of your CSS:

Code:
@font-face {
	font-family: "Source Han Sans";
	font-weight: normal;
	font-style: normal;
	src: url(“../Fonts/SourceHanSans-Regular.otf”);
}
In plain English, this says:

"I have a new font here! The font's name is Source Han Sans. It is not bold and not italics. This is the location of the font file."

(Optional) 6. Subset your Fonts

If Calibre: Tools > Subset Embedded Fonts
If Sigil: Use Doitsu's "SubsetFonts" plugin.

This will cut down the filesize.

Asian font files are huge, because there are thousands and thousands of characters.

If you're only using a handful (like in my journal articles, there were maybe ~20 characters total), you can shave the font from many MBs down to a few hundred KBs.

In plain English:

What does subsetting do exactly?

Subsetting looks through your specific book + font, then deletes every letter you're not using.

Imagine you only used the fancy font on your book's title page: "I CUP".

You can remove all those thousands and thousands of characters, only leaving 4 within the subsetted font: I + C + U + P!

Quote:
Originally Posted by Notjohn View Post
Also note that Calibre, while a wonderful library management tool, is not the best way to format a book for sale. For that, Sigil is the go-to software.
Complete hogwash. Both are perfectly capable EPUB editors.

Calibre's Editor does some things better than Sigil, like External Link check + Insert Special Character.

And Sigil does some things better than Calibre, like easier TOC editing + easier-to-read Reports.

Last edited by Tex2002ans; 05-23-2021 at 08:12 AM.
Tex2002ans is offline   Reply With Quote