[webkit-dev] font metrics

Mike Reed mikerreed at gmail.com
Fri Jan 12 08:32:09 PST 2007


Thanks for the reply David.

I may end up taking the approach you describe down the road. My first
experiment was to add a seed to the FontCache objects, and have them
check it when a width was requested, and clear their cache if the seed
was out of date. I didn't follow that too far, and now I'm doing the
simplest approach (to get going), which is to force all measures and
draws through the "complex" case: drawComplexText and
floatWidthForComplexText. I know this means I have to handle the
linquistic processing on my side, but it does solve my spacing
problems (and I draw just as fast or faster here than via drawGlyphs).

I'm not very excited about taking on the unicode-processing burden, so
I will continue to look for other ways to make zooming look good
(including your archirectural fix to reference counting the cache.)

mike

On 1/11/07, David Hyatt <hyatt at apple.com> wrote:
> This is an architectural flaw right now.  I broke the ability to
> flush the cache when porting the code from Obj-C to C++, because I
> lost the reference counting aspect of the font cache.
>
> You basically want the ability to flush the cache.
>
> My suggested approach would be to re-architect things so that
> FontData and FontPlatformData are actually reference-counted objects.
>
> Right now font lookup is a 2-step process primarily just for Mac.
>
> You go from:
>
> FontDescription -> FontPlatformData
>
> and then from
>
> FontPlatformData -> FontData
>
> On the Mac, FontPlatformData doesn't need to be reference-counted,
> since it wraps an NSFont, which is already reference-counted and
> canonical (so that the same font will yield the same NSFont*).
> Because it's canonicalized, you can actually easily go from NSFont ->
> FontData.
>
> In order to flush the cache easily, you need FontData to be reference-
> counted so that the cache can drop references, and then the
> individual RenderStyles can drop references as they go away.
>
> FontPlatformData is the sticky bit though.  FontPlatformData will
> have to properly reference-count its internal object on all
> platforms.  The easiest way to guarantee this works on all platforms
> would probably be to just make FontPlatformData reference-counted
> too.  If this is done, the retains and releases of the NSFont on Mac
> could be dropped from FontPlatformData's constructors and destructors
> on Mac.
>
> I don't really have plans to get to this soon, so this would
> definitely be an area in which you could help out. :)
>
> dave
> (hyatt at apple.com)
>
> On Jan 11, 2007, at 1:26 PM, Mike Reed wrote:
>
> > In the (nearly) latest version, webkit is caching glyph metrics based
> > on font+pointSize. If my device characteristics change (e.g. screen
> > res), I think I need to invalidate those widths (or spawn a new set),
> > so that measuring and drawing reflect the new values.
> >
> > Any pointers to help me with my port?
> > _______________________________________________
> > webkit-dev mailing list
> > webkit-dev at lists.webkit.org
> > http://lists.webkit.org/mailman/listinfo/webkit-dev
>
>



More information about the webkit-dev mailing list