I'm having a problem writing text to a Quartz graphics context in a
view using ATSUI: there is no text displayed, regardless of the kind
of graphics context I use (I tried it with a PDFContext or the View
itself). I added a blue square just to test if at least anything is
drawn, but this is displayed correctly in both cases - just no text.
Here is my code; is there any obvious error I just don't see? If
anybody has a hint, I'd really appreciate that...
if (pdfImgRep) [pdfImgRep drawInRect:CGtoNSRect(&cgfr)];
// (the rect is not correct to make the code shorter, but
that doesn't matter for testing purposes)
[self drawText:@"Test string" toContext:gcr]; // try to draw
the string; only the square is drawn!
//--- add the style information to the ATSUTextLayout:
checkStatus(ATSUSetRunStyle(myTextLayout, myTextStyle,
kATSUFromTextBeginning, kATSUToTextEnd));
//--- add the text to the ATSUTextLayout:
UniCharCount length = [tmpStr length];
UniCharArrayPtr theUnicodeText = (UniCharArrayPtr) NewPtr
(length*sizeof(UniChar));
[tmpStr getCharacters:theUnicodeText];
checkStatus(ATSUSetTextPointerLocation(myTextLayout,
theUnicodeText,
kATSUFromTextBeginning, kATSUToTextEnd, [tmpStr
length]));
//--- now draw the text: (twice at different coordinates just to
make sure)
Fixed x = 100;
Fixed y = x;
checkStatus(ATSUDrawText (myTextLayout, kATSUFromTextBeginning,
kATSUToTextEnd, (Fixed)-20, (Fixed)-20));
checkStatus(ATSUDrawText (myTextLayout, kATSUFromTextBeginning,
kATSUToTextEnd, x, y));
CGContextStrokeRect(gcr, CGRectMake(100.,100.,200.,200.)); //
just to test if ANYTHING is drawn
void checkStatus(OSStatus status)
{ // log if an error occurred
if (status) NSLog(@"%i", status);
}
NSRect CGtoNSRect(CGRect *r)
{ // convert an CGRect to an NSRect:
return NSMakeRect(r->origin.x, r->origin.y, r->size.width, r-
>size.height);
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden