Shadowed Text
Shadowed Text
- Subject: Shadowed Text
- From: David Clark <email@hidden>
- Date: Sat, 30 Jun 2001 03:34:11 -0400
All,
I have written a program called dock-it
http://www.gideonsoftworks.com/dockit.html. Dock It shows the name of
dock items in a transparent window when you mouse over them . I have
been trying to get the popup text to mimic the look of the dock popup
text. I have tried using a NSQuickDraw view w/ QD to draw shadowed text,
but it doesn't look as nice as the dock popups. From some investigative
work, I noticed that Dock.app uses the following functions to draw the
popup text.
ATSUCreateStyle
ATSUCreateTextLayoutWithTextPtr
ATSUDisposeStyle
ATSUDisposeTextLayout
ATSUDrawText
ATSUMeasureText
ATSUSetAttributes
ATSUSetFontFallbacks
ATSUSetLayoutControls
ATSUSetTransientFontMatching
All these methods are defined in
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/
QD.framework/Versions/A/Headers/ATSUnicode.h
I was able to figure out more or less what I have to do from the the
online sample code at
http://developer.apple.com/samplecode/Sample_Code/Text/TypeServicesForUnicode.
htm
and the documentation/headers. My current implementation is as follows.
I have a custom subclass of NSQuickDrawView and in the initForFrame:
method I handle creating a new empty style object (ATSUCreateStyle()
)and a text layout object ( ATSUCreateTextLayoutWithTextPtr() ). The
drawrect method is as follows
- ( void ) drawRect:(NSRect ) theRect
{
SetPort( [ self qdPort ] );
status = ATSUDrawText(textLayout, 0, textLength, 10, 10);
if( status != noErr )
{
NSLog(@"ATSUDrawText Failed");
}
}
The problem is that the text never shows up in my view. Are there any
special steps I have to take to render using ATSUI in a cocoa based
application - is SetPort enough ?
Any suggestions ?
TIA,
David