Patrick Walton wrote:

> * `CTFontCollectionCreateMatchingFontDescriptors` - constructs the query
> used to ask the OS which fonts are available. This is ultimately called
> from Servo `FontContext::get_resolved_font_for_style()`, called during
> frame construction for text boxes.
>
> * `CTFontManagerCopyAvailableFamilyNames` - gets the list of available
> families from the OS. Called when we create the thread-local font context.
> (There is one font context per frame construction thread.) 

Jumping in a bit late on this thread, at first glance I'm puzzled why these 
API's are being used.  Putting aside what Gecko does now, with CoreText you 
should be able to create a CTFontDescriptor using attributes from the style 
(e.g. family name, weight, style, stretch) and use that to create a CTFont 
object.  You really don't need to be messing with font collections unless 
you're doing something fancy, something you probably should askew at this point.

So my suggestion would be to simplify your use of CoreText API's for now, I 
think you can get 99% feature coverage without using complicated features.

To expand on what roc has already described, Gecko currently keeps track of 
available platform fonts on Windows, OSX and Android.  Linux uses fontconfig 
but that's really a big ball of beeswax that would be best to avoid.  We only 
enumerate font data to the extent necessary, XP requires the most work, OSX the 
least.  The main reason we cache font family names is that lookups using Gecko 
hashtables are always faster than using system font API's.  In some 
environments such as XP we also need to do this because available system API's 
conflate various search operations, they don't distinguish font family names 
from other types of font names.  But you could easily omit this if you only 
support modern font API's like CoreText or DirectWrite.

The hardest and most poorly supported functionality in platform subsystems is 
system font fallback, the ability to match a given character with a font that 
contains a glyph for it.  This is basically a requirement of the modern web 
platform and you see it used all over the place, not just on Wikipedia pages. 
On XP, system fallback requires us to at some point sniff the cmaps of fonts to 
figure out which font supports which character.  With DirectWrite and CoreText, 
we can sort of use system API's to figure out a fallback font, although those 
aren't completely foolproof.

Within the gfx/thebes portion of the Gecko source tree you'll find most of the 
code that deals with font issues.  The subclasses of gfxPlatformFontList is 
where the code lives that deals with enumerating font data when it's needed.

Cheers,

John
_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo

Reply via email to