I'm drawing some unicode text with ATSUDrawText into a GrafPort.
I'm trying to draw command-shift as they appear in a menu. (Flower and
Up Arrow.)
I create the string with:
UniChar cchars[3] =
{ 0x2318, 0x21e7, theKeyChar };
CFStringRef s =
CFStringCreateWithCharacters(CFAllocatorGetDefault(), cchars, 3);
DrawString(s, someRect);
But all I get are boxes where the command-shift should be.
All lower 128 characters are working well. (A-Z, etc.) I got the
numbers for command and shift from the character palette that is
available from the International control panel -> input menu.
What am I doing wrong?
Thanks,
Sanford
Here's the code below, in case it's necessary:
----
// Include PowerPlant ATS Helpers
#include <UATSUI.h>
void CSomeClass::DrawString(CFStringRef inString, Rect rect)
{
CGContextRef windowContext = NULL;
volatile OSStatus err = noErr;
GrafPtr port = UQDGlobals::GetCurrentPort();
err = ::CreateCGContextForPort(port, &windowContext);
if (err) {
return;
}
err = ::SyncCGContextOriginWithPort(windowContext, port);
if (err) {
return;
}
LATSUIStyle style;
UniChar unicode[1024] = {0};
CFStringGetCharacters(
inString,
CFRangeMake(0, CFStringGetLength(inString)),
unicode);
LATSUITextLayout layout(
unicode,
kATSUFromTextBeginning,
kATSUToTextEnd,
CFStringGetLength(inString),
style);
CGContextSetAlpha(windowContext, 1.0);
CGContextSetTextDrawingMode(windowContext, kCGTextFill);
layout.SetCGContext(windowContext);
layout.DrawOneLineAt(
kATSUFromTextBeginning,
kATSUToTextEnd,
IntToFixed(rect.left),
IntToFixed(rect.top - 23));
}
Sanford Selznick - 11 Jul 2003 16:06 GMT
> I'm drawing some unicode text with ATSUDrawText into a GrafPort.
>
> I'm trying to draw command-shift as they appear in a menu. (Flower and
> Up Arrow.)
The solution was to use DrawThemeTextBox instead.
-Sanford