I'm trying to calculate the width of a text and the same code I used in the past in a drawRect routine in a view to its UIGraphicsGetCurrentContext() isn't working. The main difference of course is the context, in this case I created a bitmap context and the code is basically this:
CGFloat fontSize = 20.0; int cw = 500; int ch = 50; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); CGContextRef context = CGBitmapContextCreate(NULL, cw, ch, 8, cw, colorSpace, kCGRenderingIntentDefault); if(context == NULL){ NSLog(@"Paragraph couldn't create context!"); } CGColorSpaceRelease(colorSpace); CGContextSelectFont(context, "Helvetica", fontSize, kCGEncodingMacRoman); CGContextSetTextDrawingMode(context, kCGTextFill); const char* textC = [str cStringUsingEncoding:NSMacOSRomanStringEncoding]; int len = strlen(textC); CGContextShowTextAtPoint(context, 0, 0, textC, len); CGPoint pt = CGContextGetTextPosition(context); CGContextRelease(context); pt.x is 0. I used a bitmap context because I didn't know how to create a different one, isn't possible to write text on a bitmap context or I am missing something else? Thanks a lot for any help, chr _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]