calibre-devs team mailing list archive
-
calibre-devs team
-
Mailing list archive
-
Message #00062
Re: EPUB font embedding
On Tuesday 30 December 2008 11:08:41 Marshall T. Vandegrift wrote:
> Kovid etc,
>
> I took a look at the matplotlib FontManager documentation and it does
> look really neat -- definitely much more complete and flexible than the
> partial fontconfig wrapper calibre has now. Any idea how intertwingled
> it is with matplotlib? Calibre's dependency list is getting pretty
> large as it is...
>
I'd rather not add a dependency on matplotlib to calibre. The last time I
looked at the matplotlib code (which is admittedly a while ago), there was a
pure python module that included support to map from css to fontconfig
patterns. If we can extract just that module it should be enough (along with
calibre's existing fontconfig support) to do what we need.
> I've been trying to think about the use-cases for font embedding, and I
> think there are four which cover it:
>
> 1. Book generation / design. The book designer specifies a set of
> families (and possibly @font-face rules defining them) using fonts
> present on their system.
> 2. Book conversion w/ embedded fonts. The source book contains
> embedded fonts which need to be re-embedded in the output.
> 3. Web content conversion. The source CSS will specify font families
> which may or may not be present.
> 4. Content conversion w/ user font override. The user will specify
> fonts present on their system to use, possibly instead of fonts
> specified by content itself.
>
> In cases 1, 2, and 3 the fonts are specified in-band. Calibre just
> needs to interpret the 'font' properties and '@font-face' rules, find
> appropriate font files, and generate appropriate '@font-face' rules for
> them. I think the only tricky bit is what to do in cases (probably
> mostly 3) where it can't find an appropriately close font.
>
> For case 4, I think any sort of comprehensive interface for out-of-band
> control of font embedding would be difficult to make usable. I think
> the simplest thing which could possibly work would be to allow the user
> to specify just font families for the CSS generic font families and
> reduce all 'font-family' properties to just one of that set. Tricky
> bit: is it too confusing to make the user specify a sans-serif font for
> 'serif' if they want to force sans-serif fonts everywhere?
>
> -Marshall
>
From the perspective of calibre, cases 1 and 2 are identical. The matplotlib
class + fontconfig should handle case 3. In case of no close match we can
default to the liberation fonts shipped with calibre.
As for 4, the system you propose is efectively what happens in LRF anyway, so
I'm fine with it.
Kovid.
--
_____________________________________
Kovid Goyal MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125
cell : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : kovid@xxxxxxxxxxxxxxxxxx
web : http://www.kovidgoyal.net
_____________________________________
References