[webkit-dev] Design change request for Font

David Hyatt hyatt at apple.com
Sun Mar 19 01:04:44 PST 2006

On Mar 18, 2006, at 4:05 PM, Mike Emmel wrote:

> On 3/18/06, David Hyatt <hyatt at apple.com> wrote:
>> You are not intended to initialize the native binding in the Font
>> constructor.  The "native" side is created lazily when the properties
>> of the font are queried.  Font is still in flux though (there are
>> more changes coming to the Mac side that will make the design a bit
>> more clear).
>> dave
> Okay but I'm not sure why not ..  in any case that decision should be
> left to the implementor I'd think.

Fonts are created for all objects in the RenderTree.  This includes  
objects that do not use the font values for anything.  Here's an  

<img style="font-weight:bold; font-size:36px; display:block">

This image has a Font object that knows it is 36px and bold, but do  
you really want to create and access a native font resource when the  
font is effectively never going to be used?  The answer (for obvious  
performance reasons) is no.

The design is that Font is a promise.  If you start asking it for  
actual metrics or to paint, then at that time the native font data  
should be accessed as needed.

> I'm happy to wait for the changes  your
> speaking of  but this is a good example were a bit of design
> documentation would be useful IMHO.

Yeah.  Keep in mind Font is extremely young and in a state of flux.   
A lot of the design/classes are just now emerging (e.g., FontDataSet,  
etc.) and more of the Mac code is going to move over to this new  
design and become cross-platform.

I would advise doing what we did on Win32 (see FontWin.cpp) and (for  
now) just hack an implementation that does very basic text and then  
move on to something else.  If you wait a bit you'll find a lot more  
of the functionality will have become cross-platform, and then you'll  
have to do a lot less work.

(hyatt at apple.com)

More information about the webkit-dev mailing list