Kovid, I tried to embed in some documents a TTF font and got mix results with my ref in the stylesheet resulting in the font not being found.

I expected the font to be found in "src: url(../Fonts/<font>.ttf)", but it turned out to be placed after importing (function: "Import files into book") in a different location "src: url(../../fonts/<font>.ttf)". The next time I imported the same font in another document, it was not even located in a sub-folder "fonts", but at the same hierarchy level as "mimetype" so I had to change the ref into "src: url(../../<font>.ttf);" for it to be found.
Using the "Arrange into folders" function to force the font into sub-folder "Fonts" so it could be found via ref "src: url(../Fonts/<font>.ttf)" also failed as this function created the sub-folder "fonts" in lower-case.

As my results seems to differ each time, I currently import the font with the "Import files into book" function, open then the resulting zipped epub to look where it happens to be situated and then manually update the ref in the stylesheet.

Apparently I have the wrong font location expectations, but can you provide me a pointer on how it is supposed to be to cure my confusion?

Ok, well that's not happening for me. No new font.css is created in styles/ and the fontfile is not placed in a fonts/ directory. I just tried that in an existing epub which did not had any previous embedded fonts. Can it be that I'm missing a setting?

To rule out that it had something to do with a possibly corrupted epub, I tried an empty dummy epub with same result.

After adding the font file, it immediately appears in the "Files Browser" under Fonts; but in the OPF file, it's manifested as being in the same folder as the OPF file "../garamond-regular.ttf". No new css file gets created. Deleting the font file doesn't remove it from the manifest either. If you add the file again, you wind up with two entries in the manifest.

1.25 (32-bit) on Vista.

EDIT: actually... no file deleted from the Files browser appears to be removed from the OPF until the book is saved and re-opened (but this doesn't work for the deleted fonts; their manifest entries appear to be well and truly orphaned).

Quote:

Originally Posted by kovidgoyal

How are you embedding the fonts? I was referring to the action of Tools->Embed referenced fonts

I'm using File-->New file (images/fonts/HTML/etc. Or File-->Import files into book. Same behavior with both. In my case, there ARE no referenced fonts in my epub. I'm trying to add my own embedded fonts and use them. Is there another way we should be doing that?

When you add files using Import files it is placed into whatever folder int he book contains the most files of the same type. So if you add an image and the book contains images in images/ the new image will be added into images and so on.

I cant recall what happens if there are no files of the same type already in the book, I'll have to look at the code for that later.

1. You can always rename the file after import even if you use add files
2. Yes, calibre cannot know where you want the fonts referenced, whereas if you use embed referenced fonts, it knows exactly where the fonts are referenced.
3. Yes.