Cocoa text rendering and setUsesScreenFonts: ATSUI? QuickDraw? Something else?
Cocoa text rendering and setUsesScreenFonts: ATSUI? QuickDraw? Something else?
- Subject: Cocoa text rendering and setUsesScreenFonts: ATSUI? QuickDraw? Something else?
- From: Evan Jones <email@hidden>
- Date: Wed, 9 Apr 2003 20:34:58 -0400
I'm trying to write some code which uses low level ATSUI calls to draw
text. Unfortunately, the output isn't quite what I desire.
Specifically, I'm hoping to mimic the rendering done by Cocoa apps. I'm
using Hydra as an example here, because it provides a check-box "Use
screen fonts" which makes what I'm seeing quite clear:
If you download Hydra, it defaults to displaying text using 10 point
Monaco, just like Project Builder. This text is not antialiased when it
is drawn to the screen, also like Project Builder and any other Mac OS
X application (Safari, Mail, whatever). However, if you open "Hydra ->
Preferences", you can toggle a box which reads "Use screen fonts". I'm
assuming that this turns around and calls [NSLayoutManager
setUsesScreenFonts]. If I uncheck this box, I get identical (or almost
identical) rendering as my ATSUI calls: 10 point Monaco text that is
being antialiased. So my question is:
What does [NSLayoutManager setUsesScreenFonts] do to get "screen
fonts"? Does it change the ATSUI drawing settings? Does it draw with
QuickDraw instead of Quartz? Is it actually selecting alternate fonts
using ATS? It is in cases like this that I wish Apple would release the
code for Cocoa, so I could answer this question myself.
My application is drawing text like this:
1. Create an ATSUStyle object.
2. Set the text size ( X2Fix( 10 ) )
3. Set the font ( Using ATSUFindFontFromName on the string "Monaco" )
4. Create an ATSUTextLayout object.
5. Add a CGContextRef to the object (I'm using Quartz).
5. Add my text to the object.
6. Add the style to the object.
7. Draw the text.
I have tried the following settings:
1. Forcing antialiasing off. This gives me correct (?) rendering at 10
points, but much worse rendering at higher sizes. At higher sizes,
Cocoa apps antialias the text.
2. Using ATSUI options such as kATSLineUseDeviceMetrics and
kATSLineFractDisable. This doesn't seem to affect anything.
I've learned through searching the mailing list archives that Mac OS X
does not support bitmap fonts, but that doesn't appear to be the issue
here, since Cocoa is doing the right thing.
Thank you for your assistance,
Evan Jones
--
Evan Jones:
http://www.eng.uwaterloo.ca/~ejones/
"Computers are useless. They can only give answers" - Pablo Picasso
_______________________________________________
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.