opensubscriber
   Find in this group all groups
 
Unknown more information…

q : quartz-dev@lists.apple.com 12 January 2006 • 1:57AM -0500

Re: Resource use of CG Fonts
by Derek Clegg

REPLY TO AUTHOR
 
REPLY TO GROUP




On Jan 11, 2006, at 2:29 AM, Kai Brüning wrote:

> Folks:
>
> I am creating CGFonts using CGFontCreateWithPlatformFont for all  
> our text drawing.
>
> Initially, I recreate the CGFont each time to draw a piece of text.  
> This turned out to be bad at least for the PDF conversion done by  
> Quartz (as accessible via the print dialog): the resulting PDFs  
> contain a separate embedded font subset for each time  
> CGFontCreateWithPlatformFont is called. This can result in  
> ridiculously large and slow PDFs.
>
> Now I am caching the CGFonts as I create them, using a mapping  
> against ATSFontRefs. Works beautifully, but do I need to be  
> concerned about resource use? Like restricting the number of fonts  
> in the cache to some upper number? Or is it best (certainly it is  
> easiest) just to keep any CGFont around once it is created until  
> the program exists?
>
> Note: I have a notification for font list changes installed with  
> ATSFontNotificationSubscribe and handle this correctly, dropping  
> fonts from the cache which are no longer available.

I think your approach is exactly the right thing to do.  You don't  
really need to worry about resource use — CGFonts are themselves  
lightweight, and we manage the resources they use internally to keep  
them low without sacrificing performance.  I'd create a CGFont once  
and hang on to it until the program exits.

Derek



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list      (Quartz-dev@list...)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/subscriber%40opensubscriber.com

This email sent to subscriber@open...

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.