Font subsetting problem with CSS pseudo classes

Bug #1990766 reported by Jackie Stockdale
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Released

Bug Description

Raising this bug report as per your agreement in this thread

The current container utility, subset_all_fonts, doesn't seem to take any account of text styled by a CSS font-family rule with a pseudo class selector. The result is that too many chars are removed during subsetting and sometimes even the whole font.

I've attached a 1-page test epub which uses ::first-letter and ::first-line to demo the problem.

As mentioned in the above MR link I know that text styled by ::first-line is variable depending on screen width but a compromise might be to retain all characters used by the main part of the selector,
e.g. .sb::first-line {font-family: MyFont} should retain all chars in MyFont used by class="sb"

Or if that's too finicky maybe allow subset_all_fonts to take a parameter of a list of fonts to *exclude* from subsetting.

My particular use case is for a utility I can call in a personal plugin rather than in Polish/Editor. Anything you can do to improve things will be much appreciated.

Tags: font subset
Revision history for this message
Jackie Stockdale (jackiestockdale) wrote :
Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

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

 status fixreleased

Changed in calibre:
status: New → Fix Released
Revision history for this message
Jackie Stockdale (jackiestockdale) wrote :

Hi Kovid, Thanks for looking at this so quickly. I tried it out by running from source using the test epub from this thread in the Editor.

1. ::first-letter seems to work OK.

2. ::first-line has a problem retaining the italics from the word 'loathed' in the next-to-last paragraph. Font file BMinProSC-Italic.ttf is completely discarded as you can see in the Subsetting report pop-up. It was a little confusing because if you only look at the Editor Preview panel then the italics look as if they have been correctly retained. I can only assume the previewer is displaying simulated italics.

I ran a similar test by replacing the <i> tags with <b> tags before subsetting. This time BMinProSC-Bold.ttf was incorrectly discarded. In fact, no matter what I tried, only BMinProSC-Regular.ttf survived the subsetting process. The good news is that the Regular ttf does appear to have retained all the necessary chars.

Please let me know if you need more info.

Revision history for this message
Kovid Goyal (kovid) wrote :
Revision history for this message
Jackie Stockdale (jackiestockdale) wrote :

Yes, all seems good now. :)

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.