Re: Loading a TTF font
Re: Loading a TTF font
- Subject: Re: Loading a TTF font
- From: John Stiles <email@hidden>
- Date: Thu, 9 Oct 2003 15:41:08 -0700
Unfortunately, I get NULL back from ATSFontGetPostScriptName when I use
Papyrus.dfont. It is the same result as ATSFontGetName.
(FrizQuadrata.ttf continues to work. It reports its name as
"FrizQuadrataTT".)
On Thursday, October 9, 2003, at 02:33 PM, Aki Inoue wrote:
John,
- ATSFontGetName -> font ref in, font name out
- +NSFont fontWithName:size: -> font name in, NSFont out
The argument for -fontWithName:size: must be a postscript name.
So, it should ATSFontGetPostscriptName instead of ATSFontGetName.
Aki
On 2003/10/09, at 11:06, John Stiles wrote:
Thanks to everyone's help, I have managed to get this working! I am
puzzled by one small thing, but other than that, it's going great.
The good stuff: I am able to make the following calls and get a font
loaded.
- ATSFontActivateFromMemory -> block of memory in, font container out
- ATSFontFindFromContainer -> font container in, array of font refs
out
(At this point I just take the first font ref in the array; I don't
think there are any cases where our content guys will use a container
with multiple fonts/styles in it. Our needs aren't that complicated,
fortunately.)
- ATSFontGetName -> font ref in, font name out
- +NSFont fontWithName:size: -> font name in, NSFont out
Unfortunately, on some fonts, the CFString returned by ATSFontGetName
is NULL! (Fonts which worked: MSMincho.ttc, FrizQuadrata.ttf. A font
which gave a NULL name: Papyrus.dfont)
Why would this happen? Is it something to do with dfonts versus
ttf's? Since we aren't going to be using dfonts anyway (we need
Win98-compatible fonts), this isn't a big deal for me, but I want to
make sure that's what the problem actually is.
Really, it would be more convenient if I could pass an ATSFontRef
directly to NSFont and skip the name-grabbing step, but I doubt
that's an option.
On Wednesday, October 8, 2003, at 08:01 PM, John Stiles wrote:
For legal reasons, I probably cannot install the fonts. (We have a
license to use them in our software, but not to give them to
end-users.) I'm pretty sure I'm safe putting them in a temporary
directory, but putting them in a semi-permanent place on the user's
hard drive is probably a recipe for trouble.
Can I use Carbon code to activate the fonts, and have NSFont "see"
the fonts? And TTFs will work?
(FWIW I have no aversions to Carbon at all. I am not really a
language/API zealot. I just want stuff to work with a minimum of
headache. Usually that means Cocoa, but not always.)
On Wednesday, October 8, 2003, at 06:42 PM, Andrew Thompson wrote:
On Wednesday, Oct 8, 2003, at 20:23 America/New_York, Aki Inoue
wrote:
John,
The ATS framework, our font management layer, can work with
Windows fonts.
You just have to install them in one of the folders for fonts.
Aki
On 2003/10/08, at 16:03, John Stiles wrote:
I'm working on a program which needs to load a font from a
Windows-origin ".TTF" or ".TTC" font, and turn it into an NSFont
that would be suitable for rendering text as bezier paths (in my
case, I use -NSBezierPath >>>>
appendBezierPathWithGlyphs:count:inFont:).
Is this easily doable with Cocoa? Or am I looking at a painful
process?
If necessary I could preprocess the font to be more Mac-friendly
in some way, but that means wasting a few hundred K of disk space
on our CD for two copies of one font. In the worst case (the
Japanese version), that could mean up to 10MB gone. Not really
thrilled about that option :)
Thanks for any suggestions :)
If you don't want to install the fonts, you can activate arbitrary
fonts using these APIs:
http://developer.apple.com/documentation/Carbon/Reference/ATS/
atsfontsref_Reference/function_group_1.html#//apple_ref/doc/uid/
TP30000037/Activating_and_Deactivating_Fonts
Its definately Carbon not Cocoa (well, actually I think its
technically part of Core Foundation), but Cocoa can call Carbon
code with no problems.
As to how hard it is to get right, I don't know...
A: Top replies
Q: What's the most annoying thing you can do in an email?
(sorry Aki, couldn't resist ;)
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.
_______________________________________________
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.
_______________________________________________
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.