Re: Font names
Re: Font names
- Subject: Re: Font names
- From: Andy <email@hidden>
- Date: Tue, 26 Nov 2002 22:26:27 -0500
Thilo Ettelt wrote:
>
>
Hi!
>
>
I'm trying to brigde a REALbasic (so carbon) chat application with my
>
cocoa chat client. the problem is that a font in carbon has a different
>
name than in cocoa. what I mean is that in cocoa everything is splitted
>
into font/family/etc. (and bold/italic etc) but in carbon it's just
>
"Copperplate" and "Copperplate Light". So when a message from the
>
carbon app arrives with the font name "Copperplate Light" my cocoa
>
client won't handle it because there's no font exactly named
>
"Copperplate Light" than rather a font object "Copperplate" with
>
family/style or whatever called "Light". Is there some sort of
>
converter for such things? Like a method which returns an NSFont object?
>
Find the postscript name for the font.
This would be something like ArialMT-Bold.
These match across Carbon and Cocoa, the other font names don't (Cocoa
name != Quickdraw name)
I do this:
+ (ATSFontRef) NSFontToATSFont: (NSFont *) a_font {
ATSFontRef result = ATSFontFindFromPostScriptName((CFStringRef)
[a_font fontName], kATSOptionFlagsDefault);
return (result != kATSFontFamilyRefUnspecified) ? result : nil;
}
But you might prefer to call the Carbon Font Manager than access ATSFontFindFromPostScriptName.
In general the Carbon Font Manager has mostly the same routines, they
just start with FM rather than ATS and take slightly different arguments.
--
AndyT (lordpixel - the cat who walks through walls)
A little bigger on the inside
(see you later space cowboy ...)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: | |
| >Font names (From: Thilo Ettelt <email@hidden>) |