Re: Shadowed Text
Re: Shadowed Text
- Subject: Re: Shadowed Text
- From: Aki Inoue <email@hidden>
- Date: Mon, 2 Jul 2001 01:17:52 -0700
When you're using ATSUI in Cocoa, you can specify the current CG context
to the textlayout instead of setting up the QDport.
- (void)drawRect:(NSRect)theRect {
ATSUStyle style;
ATSUAttributeTag tags[1] = {kATSUCGContextTag};
ByteCount sizes[1];
CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext
currentContext] graphicsPort];
status = ATSUCreateStyle(&style);
sizes[0] = sizeof(cgContext);
status = ATSUSetAttributes(style, 1, tags, sizes, &cgContext);
}
Aki
On 2001.06.30, at 00:34, David Clark wrote:
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
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev