Cocoa, ATSUI, and graphics context
Cocoa, ATSUI, and graphics context
- Subject: Cocoa, ATSUI, and graphics context
- From: Todd Heberlein <email@hidden>
- Date: Sun, 21 Apr 2002 12:18:35 -0700
Hello all,
I am experimenting with ATSUI under Cocoa, and so far I am off to a bad
start. I hope someone can help me. The code below, trying to set the
graphics context for ATSUI, is based on code I found in the archives for
this mailing list. Unfortunately, it isn't working for me.
The ATSUSetAttributes() is failing with a status of -8799, the
kATSUInvalidAttributeTagErr result code.
What am I doing wrong?
Do I even need to set the graphics context to the style before using other
ATSU drawing commands?
[This a a method from MyView, a subclass of NSView]
- (void)drawRect: (NSRect)rect
{
OSStatus status;
ATSUStyle style;
CGContextRef CG_context;
ATSUAttributeTag tags[1];
ByteCount sizes[1];
ATSUAttributeValuePtr values[1];
if ((status = ATSUCreateStyle(&style)) != noErr) {
NSLog(@"Could not create style");
}
CG_context = (CGContextRef)[[NSGraphicsContext currentContext]
graphicsPort];
if (CG_context == nil) {
NSLog(@"No CG context");
}
tags[0] = kATSUCGContextTag;
sizes[0] = sizeof(CG_context);
values[0] = CG_context;
if ((status = ATSUSetAttributes(style, 1, tags, sizes, values))
!= noErr) {
NSLog(@"Could not set ATSU attribute: %d", (int)status);
}
...
}
Thanks,
Todd
PS. Ultimately I am trying to draw Arabic/Persian text in a Cocoa
application. If anyone happens to have a simple example of this (or other
right-to-left text), I would appreciate it.
_______________________________________________
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.