[webkit-dev] Fonts for WebKit tests on OS X?

Myles C. Maxfield mmaxfield at apple.com
Mon Mar 14 15:34:53 PDT 2016

Replies inline.
> On Mar 11, 2016, at 1:50 PM, Frédéric WANG <fred.wang at free.fr> wrote:
> Le 11/03/2016 22:12, Myles C. Maxfield a écrit :
>> Just to clarify: you want tests to use some specific fonts, but don’t
>> want to check the fonts into the repository?
> Yes. To test some specific OpenType MATH feature we already use our own
> small fonts (a few kilobytes) loaded as Web fonts. However, for all the
> other tests with real math fonts (where we want to get reliable
> rendering and independent of which of these math fonts are installed or
> not), it's not clear whether the license (compatibility with WebKit's?)
> or the size (several hundreds of kilobytes) make that
> possible/judicious. For WebKitGTK+ we have the separate repository of
> fonts [3] mentioned in my previous mail that ensures Latin Modern Math
> is available when running GTK tests.
>> The downside to 1 is that it adds a new (non-obvious) step that all
>> developers will have to perform every time they install a new
>> operating system (in addition to any time we bring up a new buildbot).
>> I would object to making the development environment even more
>> complicated than it already is.
> I agree with that. I'd just like to note that:
> a) From my experience, installing user font in the Apple Font Book does
> not even seem enough. For some reason, only the pre-installed font are
> used when running tests…

This is because we whitelist an explicit list of fonts which the tests are allowed to use. We don’t want tests to start failing just because the user has some unexpected font installed on their system.

See allowedFontFamilySet() in Tools/DumpRenderTree/mac/DumpRenderTree.mm, Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm, and Tools/WebKitTestRunner/mac/TestControllerMac.mm

> b) As said above, WebKitGTK+ has a special mechanism to setup a jhbuild
> environment and automate installation of dependencies ; I was wondering
> if something similar exists for the Apple ports, but apparently that's
> not the case...
>> I’m not sure if I’m allowed to publicly discuss my opinions about 2
>> (since it is technically an internal matter) but I would expect its
>> success to be dubious.
> Yes, I expected that. However, some years ago Apple accepted to install
> the STIX font version 1.0. So I was hoping that maybe an upgrade to
> version 2 when it is released would not be asking too much... at least
> compared to the burden of managing a jhbuild-like mechanism in Apple
> ports or bundling big fonts into the repo...
>> Given this, I think the best solution is to check the fonts into the
>> repository. Layout tests could target these as web fonts using
>> @font-face, or they could use the same mechanism that we use for
>> WebKitWeightWatcher (which is a font) to view the font as if it is
>> preinstalled (without actually preinstalling it). 
> Can you elaborate on what is done for WebKitWeightWatcher?

We call CTFontManagerRegisterFontsForURLs(… kCTFontManasgerScopeProcess …) to make the fonts look like they are installed for just the local process.

On iOS, we use the -sectcreate linker flag to place the font data directly inside the DumpRenderTree binary. We then create an in-memory CGFontRef backed by these bytes (the loader will put them in memory for us at process creation) we use CTFontManagerRegisterGraphicsFont() to make it look like it is installed. See activateTestingFonts() and activateFontIOS() in Tools/DumpRenderTree/mac/DumpRenderTree.mm.

> Thanks,
> Frédéric

More information about the webkit-dev mailing list