[Qt-interest] Some fonts don't work on Mac OS X

James Larcombe james.larcombe at avid.com
Thu Sep 9 16:13:13 CEST 2010


Thanks a lot for bringing up this font issue. I hadn't noticed it
before. It's a very serious one for our Mac application.

I can reproduce the problem described in this thread with Big Caslon on
my Mac (10.6.4).

By coincidence I was stepping through the code in QFontDatabase::load on
the Mac just yesterday, in pursuit of an unrelated problem in our
application. So I've just taken another look at it.

What seems to be happening is that it finds the ATSFontFamilyRef for
"Big Caslon", but then retrieving the actual ATSFontRef is failing
(ATSFontFindFromName returns 0).

This null ATSFontRef is then passed to the QCoreTextFontEngineMulti
constructor, which attempts to find the font's name using it - obviously
this fails. Unfortunately though this is what's used to create the real
CoreText font (passed to CTFontDescriptorCreateWithNameAndSize), hence
this is also failing, and the font ends up falling back to something
else. This fallback is whatever CTFontCreateWithFontDescriptor returns
when presented with a null descriptor.

This all seems a bit round the houses - why still use ATS at all in the
CoreText implementation, and if it's only being used to get the font
name, why not pass this directly to QCoreTextFontEngineMulti? The
ATSFontRef isn't used for anything that I can see.

I'll continue to dig further into this, but thought I'd post something
in case it was helpful in the meantime.

James




More information about the Qt-interest-old mailing list