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 06-26-2024, 08:00 PM   #1
Kreeblah
Junior Member
Kreeblah began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jun 2024
Device: Kobo Sage
How to determine which CSS lines are specifying a font?

I have a book that was pretty terribly set up by the publisher, and I've had to fix some of the CSS in it. However, I'm having trouble with getting Calibre to recognize the fonts for it. It came with all of the font files it was supposed to, but two of them were referenced incorrectly in the stylesheet and also had invalid properties in the actual font files (they were bold fonts but not actually self-identifying as bold). So, I pulled the fonts out, added them to a directory where Calibre can find them, and attempted to polish the book to embed them.

The problem is, Calibre seems to be insisting that the stylesheet is specifying different properties than one of the fonts has, even though I can't find those properties anywhere in the stylesheet. Specifically, what I'm seeing is this:

Quote:
Could not find a font in the "NewsGoth BdXCn BT" family exactly matching the CSS font specification, will embed a fallback font instead. CSS font specification:
  • font-weight: 700
  • font-style: normal
  • font-stretch: normal
Matched font specification: /Users/myuser/.fonts/News Gothic Bold Extra Condensed BT.ttf
  • font-weight: bold
  • font-style: normal
  • font-stretch: condensed
Meanwhile, I have nothing in the stylesheet specifying a numeric weight for the font (only "bold"), and each reference to this font has font-stretch listed as "condensed", so I don't know where "normal" is coming from. There's only one stylesheet in the book and I've done a bunch of grepping through the book's files to see if I'm missing anything anywhere else, but I'm coming up with nothing. Additionally, running Calibre in debug mode just prints the same information to the console.

Is there a way to determine what lines Calibre is using to compose the font specification? If not, how can I figure out what I'm missing here? I'm running Calibre 7.12 on macOS 14.5, if it's relevant.
Kreeblah is offline   Reply With Quote
Old 06-26-2024, 09:52 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,506
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
bold is the old way (and older readers want that as well as EPUB2 )

the numbers are the newer way of specifying font-weight (I have seen a chart. there are more number levels than the old)
Each font has an internal table (normal, bold, italic, bold-italic). That is 4 font files to make up the complete FAMILY (not al faces have all 4, so substitutes are sometimes called out and the check will complain that the names do not match the Family
theducks is offline   Reply With Quote
Old 06-26-2024, 10:36 PM   #3
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,403
Karma: 7000000
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by Kreeblah View Post
So, I pulled the fonts out, added them to a directory where Calibre can find them, and attempted to polish the book to embed them.
How did you do this?
Did you hack the epub and manually add files to it or did you use the Calibre Editor and select Add/Import new files?

You could also install a font program, like Sourceforge and check what is specified in the font file.
Attached Thumbnails
Click image for larger version

Name:	sourceforge.jpg
Views:	284
Size:	113.4 KB
ID:	209183  
Karellen is offline   Reply With Quote
Old 06-27-2024, 12:46 AM   #4
lomkiri
Zealot
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 149
Karma: 1451628
Join Date: Jul 2021
Device: N/A
Quote:
Originally Posted by Kreeblah View Post
Is there a way to determine what lines Calibre is using to compose the font specification?
Menu View / Live CSS,
Then, click anywhere in the text you want to analyze (in the edition window, not in the preview)
lomkiri is offline   Reply With Quote
Old 06-27-2024, 01:13 AM   #5
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,114
Karma: 27620706
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by lomkiri View Post
Menu View / Live CSS,
Then, click anywhere in the text you want to analyze (in the edition window, not in the preview)
You beat me to it, Live CSS is one of the calibre-editor's best features, alongside multi-lingual spell checking.

BR
BetterRed is offline   Reply With Quote
Old 06-27-2024, 04:47 AM   #6
Kreeblah
Junior Member
Kreeblah began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jun 2024
Device: Kobo Sage
Quote:
Originally Posted by theducks View Post
bold is the old way (and older readers want that as well as EPUB2 )

the numbers are the newer way of specifying font-weight (I have seen a chart. there are more number levels than the old)
Each font has an internal table (normal, bold, italic, bold-italic). That is 4 font files to make up the complete FAMILY (not al faces have all 4, so substitutes are sometimes called out and the check will complain that the names do not match the Family
Ah, good to know. I knew that the labels mapped to numbers (and that 700 and bold were equivalent), but I was confused about where it was getting the specifically numeric value from. Maybe Calibre just converts the text labels to numeric values, though, if that's the newer standard.

Quote:
Originally Posted by Karellen View Post
How did you do this?
Did you hack the epub and manually add files to it or did you use the Calibre Editor and select Add/Import new files?

You could also install a font program, like Sourceforge and check what is specified in the font file.
I unzipped the epub and copied the font files to ~/.fonts, removed them from the directory tree, the references from the manifest, and the locations to the font files from the stylesheet (plus fixed up the font names in the stylesheet based on the internal font names), then used the Polish Books function to embed them.

I've been using FontForge to check things with fonts in order to do things like get the font family name (because it was very wrong in the stylesheet originally for this font; it was listed as the font filename rather than the font family name). I've also been able to inspect other relevant properties with it, too (see the attachment for a screenshot).

Quote:
Originally Posted by lomkiri View Post
Menu View / Live CSS,
Then, click anywhere in the text you want to analyze (in the edition window, not in the preview)
That's good to know, but it would really help if I knew where the problem text is in the book in order to inspect that to see what's going on. That's the issue, though. I don't know where the book is calling for a style that comes out as what Calibre is determining is different than the actual font since the polish books function doesn't really report much other than that something didn't match somewhere. Something must be overriding some of the CSS somewhere, but it'd be helpful if Calibre could tell me where the mismatched font is being used.

If that's not currently an option, though, this should be able to get me the info I need. It'll just take me a while to find where every use of every relevant element is.
Attached Thumbnails
Click image for larger version

Name:	Screenshot 2024-06-27 at 00.26.54.png
Views:	278
Size:	805.9 KB
ID:	209192  
Kreeblah is offline   Reply With Quote
Old 06-27-2024, 11:08 PM   #7
Kreeblah
Junior Member
Kreeblah began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jun 2024
Device: Kobo Sage
Hmmm. Doesn't seem like I can edit posts, so I guess I need to make a new reply?

But, I just used that Live CSS tool and went through every element in the book that uses one of the classes that references the font I'm having issues with, and every computed style came up with a font-weight of 700 and a font-stretch of 75%. I'm absolutely mystified as to where that mismatch is coming from.

Is there anything else I can try to track this down?
Kreeblah is offline   Reply With Quote
Old 06-28-2024, 05:42 AM   #8
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,506
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
font-stretch?

FWIW My Kobo's don't like some valid CSS being used: letter-spacing causes words to run together. eg ChapterTitle

IMHO K.I.S.S. (an least for some things)

?? Isn't Live CSS a temporary (that session) operation??

I use the 'Inspector' to try and decode the CSS nesting.

Right click on a / the problem paragraph (in the Preview pane): Inspect element
theducks is offline   Reply With Quote
Old 06-28-2024, 05:59 AM   #9
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,403
Karma: 7000000
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Why don't you post the book here. Maybe someone will spot the issue.
If the book is in copyright, remember to scramble it first.
Karellen is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Extra CSS @font-face losing font url Amalthia Conversion 5 02-10-2024 07:04 PM
Epub to PDF Issue: text lines cut in half (Chinese font vertical-rl script) ignosticism Conversion 4 01-28-2021 12:17 PM
Managing Blank Lines Following <p> Using CSS SeaCanary Sigil 29 02-22-2014 09:41 PM
Determine font and font size on incoming epub? peaceridge Calibre 4 01-30-2012 04:35 PM
comment out lines in CSS cybmole Sigil 3 05-10-2011 06:54 AM


All times are GMT -4. The time now is 03:05 PM.


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