Hi,

Just embed it as a resource, and then use the code
below to load it for use. You can just reference it by
name from then on (well, as long as your app is
running) as you would any other font. (Where
"kDefaultFontFile" is the name of your TTF file. Ex:
@"MyFont.TTF")

HTH!

B


                NSString *fontPath = [[[[NSBundle mainBundle]
resourcePath] stringByAppendingPathComponent:@"Fonts"]
stringByAppendingPathComponent: kDefaultFontFile];
                NSData *fontData = [NSData dataWithContentsOfFile:
fontPath]; 

                ATSFontContainerRef container;
                OSStatus err = ATSFontActivateFromMemory([fontData
bytes], [fontData length],
                                                   kATSFontContextLocal,
                                                   kATSFontFormatUnspecified,
                                                   NULL,
                                                   kATSOptionFlagsDefault,
                                                   &container );
           
           if( err != noErr )
                   NSLog(@"failed to load font into memory");
           
           ATSFontRef fontRefs[100];
           ItemCount  fontCount;
           err = ATSFontFindFromContainer(
                                                   container,
                                                   kATSOptionFlagsDefault,
                                                   100,
                                                   fontRefs,
                                                   &fontCount );
           
                if( err != noErr || fontCount < 1 ){
                   NSLog(@"font could not be loaded.");
                }
                else{

                        NSString *fontName;
                        err = ATSFontGetPostScriptName(
                                                           fontRefs[0],
                                                           
kATSOptionFlagsDefault,
                                                           (CFStringRef*)( 
&fontName ) ); 
                                                           
                        NSLog(@"font %@ loaded", fontName);
                }




      
____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total 
Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to