As I mentionned before, Apple released WebKit as an open source project. WebKit is much more than WebCore, as it also contains all the MacOS X specific rendering code for the HTML engine that is KHTML. I was enjoying to have a look at the code as it would should me how to achieve a fast text renderer on MacOS X like I need for AbiWord (currently, AbiWord text renderer is really buggy on MacOS X).

So I took a deep breath and dug into the code. I'm getting depressed.

First it looks like there is not one true way to render text as they have 2 methods to draw text with 2 different cases that they determine with shouldUseATSU() based on the content of the text run. From what I can say (comments are really sparse), it depends of the Unicode chars to be rendered. But they have a switch back when alwaysUseATSU is set to YES that makes ATSU being used all the time. I wonder if Safari doesn't set it all the time using the "private API". But why? Is using CoreGraphics directly way faster but much more limited? That what I'll try to figure out.

At one point I thought about using CoreGraphics, but in 10.2, the API do not allow to draw non ASCII char, or you have to get CGGlyph, which seems to be uneasy, and the font selection does not seems to be doable from a Cocoa NSFont as there is not method to get a CGFontRef from a NSFont. All the searches on google point to an undocumented method from NSFont, but as always, avoid that is it might break in future releases.

So I had a look at WebKit, and they use WKGetCGFontFromNSFont. Perfect. I look closely and realise that this function is in a damn libWebKitSystemInterface.a binary ! Yes. No API for a much needed feature, and when Apple's open source code actually need it, it is in a damn closed binary library...

Now getting the metrics fast. Same thing. Private function in the binary library.

Why can't Apple release this APIs ? Question about how to do that has been asked for years on various mailing list with Apple engineer always responding the same B.S.. With this they demonstrate that these APIs are usefull, so why do they have to be kept secret? I can't use a binary library like that for AbiWord.

I filed bug 4257530 for that, without any hope.

And years ago, there was an attempt of a lawsuit to Microsoft for the use of unpublished Windows APIs to stiffle the one bit of competition they can't stand for...