Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 02-24-2014, 05:25 AM   #1
DrChiper
Bookish
DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.
 
DrChiper's Avatar
 
Posts: 907
Karma: 1803094
Join Date: Jun 2011
Device: PC, t1, t2, t3, aura 2 v1, clara HD, Libra 2, Nxtpaper 11
Question Embedding fonts

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?
DrChiper is offline   Reply With Quote
Old 02-24-2014, 06:35 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Fonts are placed in the folder fonts/ and referred to from a newly created stylesheet called fonts.css, where they are referred to as

url(fonts/fontname-style.ttf)
kovidgoyal is offline   Reply With Quote
Advert
Old 02-24-2014, 07:42 AM   #3
DrChiper
Bookish
DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.
 
DrChiper's Avatar
 
Posts: 907
Karma: 1803094
Join Date: Jun 2011
Device: PC, t1, t2, t3, aura 2 v1, clara HD, Libra 2, Nxtpaper 11
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.

Last edited by DrChiper; 02-24-2014 at 07:58 AM.
DrChiper is offline   Reply With Quote
Old 02-24-2014, 08:05 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
How are you embedding the fonts? I was referring to the action of Tools->Embed referenced fonts
kovidgoyal is offline   Reply With Quote
Old 02-24-2014, 08:13 AM   #5
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,549
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I'm not seeing the expected behavior either, Kovid.

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 View Post
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?

Last edited by DiapDealer; 02-24-2014 at 08:21 AM.
DiapDealer is offline   Reply With Quote
Advert
Old 02-24-2014, 08:32 AM   #6
DrChiper
Bookish
DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.
 
DrChiper's Avatar
 
Posts: 907
Karma: 1803094
Join Date: Jun 2011
Device: PC, t1, t2, t3, aura 2 v1, clara HD, Libra 2, Nxtpaper 11
Ok, this is my workflow:
  1. I open an epub
  2. I place a font-family entry in the stylesheet
  3. I add via "Import files into booK" the font file
  4. As the font file is not placed in the fonts/ dir, and no fonts.css is created, I manually add the @font-face entry in the stylesheet.

Using the "Embed referenced fonts" does not find anything, but I can understand that as the font I want to use is not located in the windows fonts dir.

@DiapDealer: Hmm, Did not used "New file (images/fonts/HTML/etc." before, but yes, that could also be an option.

Last edited by DrChiper; 02-24-2014 at 08:37 AM.
DrChiper is offline   Reply With Quote
Old 02-24-2014, 08:42 AM   #7
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
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.

Last edited by kovidgoyal; 02-24-2014 at 08:54 AM.
kovidgoyal is offline   Reply With Quote
Old 02-24-2014, 08:49 AM   #8
DrChiper
Bookish
DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.
 
DrChiper's Avatar
 
Posts: 907
Karma: 1803094
Join Date: Jun 2011
Device: PC, t1, t2, t3, aura 2 v1, clara HD, Libra 2, Nxtpaper 11
Ok, that possibly explains the fact the font file is not located in a fonts/ dir. But what is causing the fonts.css file not to be created?
DrChiper is offline   Reply With Quote
Old 02-24-2014, 08:54 AM   #9
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
When you add using add new file, the file is placed in whatever folder you specify in the add ilfe dialog, or the root if you specify no folder.
kovidgoyal is offline   Reply With Quote
Old 02-24-2014, 08:55 AM   #10
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by DrChiper View Post
Ok, that possibly explains the fact the font file is not located in a fonts/ dir. But what is causing the fonts.css file not to be created?
fonts.css is only created if you use the embed referenced fonts tool. Adding font files does not create css for you.
kovidgoyal is offline   Reply With Quote
Old 02-24-2014, 09:27 AM   #11
DrChiper
Bookish
DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.
 
DrChiper's Avatar
 
Posts: 907
Karma: 1803094
Join Date: Jun 2011
Device: PC, t1, t2, t3, aura 2 v1, clara HD, Libra 2, Nxtpaper 11
Ok, so summarizing:
  1. I must use "New file (images/fonts/HTML/etc." (and not "Import files into book") to control the location where I want to have the font file, e.g. Fonts/
  2. As I'm using non-standard font files, I'm supposed to manually add any references to that font file (hence, no automagically fonts.css for me)
  3. Optionally, I can use function "Arrange into folders" to even more control where all specific files of the epub should be in sub-folders

Thanks for clearing that up, Kovid!
DrChiper is offline   Reply With Quote
Old 02-24-2014, 11:13 AM   #12
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
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.
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedding fonts - so confused EkkoJohnny Sigil 12 03-27-2012 01:39 PM
Fonts embedding 1drey Writer2ePub 3 06-17-2011 11:15 PM
Embedding fonts JaneFancher Calibre 14 04-10-2010 09:28 PM
Embedding fonts AprilHare ePub 6 01-02-2010 11:42 AM
Embedding fonts jash Calibre 2 09-09-2008 05:05 PM


All times are GMT -4. The time now is 11:39 PM.


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