truetype fonts with formatting not translating from EPUB to PDF

Bug #1395176 reported by Amanda Guttmann on 2014-11-21
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

Summary: truetype fonts with formatting not translating from EPUB to PDF

Windows 7 – Calibre 2.10

Bug Description: I’m trying to convert an EPUB to a PDF and the formatting of the font is being lost in translation. When viewing the page in the Calibre reader, the formatting is present. When I convert to PDF, it is not.

There is a separate font file for the regular text and for the italicized text as well as the bold text for some books I’ve been trying to convert. I have examples of both.
The bold example is being converted at a custom size of 737x1100 devicepixels. The italics fits on a standard letter sized page.

I installed the fonts on my machine, and also added the fonts to Calibre. I have also tried checking the “embed reference fonts” option with Berling (for the italics example) set as the font family but nothing I’ve tried gets the font to render with formatting in the PDF.

Is there a solution I haven’t tried, or is this a bug?

You are embedding the fonts incorrectly. For example, for your italics
file, use the following @font-face rules:

@font-face {
  font-family: "Berling";
  src: url(OEBPS/fonts/BerlingRoman.ttf);
@font-face {
  font-family: "Berling";
  src: url(OEBPS/fonts/berlingi.ttf);
@font-face {
  src: url(fonts/Berling-Roman.ttf);
  panose-1: 2 0 5 3 8 0 0 2 0 4;
  font-family: "Berling";
@font-face {
  src: url(fonts/Berling-Italic.ttf);
  font-style: italic;
  panose-1: 2 0 5 3 8 0 0 9 0 4;
  font-family: "Berling";

Note how the font family for all the fonts is the same. The font-family
in the @font-face rule should always match the actual font-family
declared inside the ttf file.

And then in the CSS for hte actual text, to get italic style, use font-style:italic

While what you are doing is "technically" correct, it is not
recommended. Use the correct form and you should be fine.

I may at some point spend some time seeing if I can get PDF output to
support font family aliasing, but it is unlikely.

 status invalid

Changed in calibre:
status: New → Invalid
Kovid Goyal (kovid) wrote :

Turns out that adding support for font family aliasing to PDF Output was easy,
will be in the next release.

Fixed in branch master. The fix will be in the next release. calibre is usually released every Friday.

 status fixreleased

Changed in calibre:
status: Invalid → Fix Released

Wow! Thank you. I really appreciate the feedback you gave to begin with, and it's amazing you were easily able to implement it. Thank you so much!

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers