Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-08-2010, 05:10 AM   #1 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 155
Default Quartz2D: Text on context appears upside down and mirrored

Hi,

i got a custom UIView-subclass and in the drawRect-Method, i am drwing on the context.
The drawing stuff works fine, but when i show some text, it is upside down ond mirrored.

Code:
CGContextRef ctx = UIGraphicsGetCurrentContext();
...
...
CGContextSelectFont(ctx, PDF_FONT_NAME, 20, kCGEncodingMacRoman);
CGContextSetTextDrawingMode (ctx, kCGTextFill);
CGContextSetRGBFillColor (ctx, 1, 1, 1, 1);
     
const char *goodVals = "Some Text";
CGContextShowTextAtPoint (ctx, 35, 250, goodVals, strlen(goodVals));
I use this code in my app several times and it works fine there.
Any ideas why the text is upside down and mirrored?

Regards,
Daniel
Grinarn is offline   Reply With Quote
Old 06-08-2010, 10:15 AM   #2 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 107
Default

Quote:
I use this code in my app several times and it works fine there.
Any ideas why the text is upside down and mirrored?
It has been my experience that text is always drawn upside down the way you are describing... other graphics objects are treated with 0,0 in the top left of the image, and thus are not rendered upsidedown.

insert:

Code:
CGAffineTransform textTransform = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, 0.0);
CGContextSetTextMatrix(ctx, textTransform);
before:

Code:
CGContextShowTextAtPoint (ctx, 35, 250, goodVals, strlen(goodVals));
to set it back to what you 'want'.
JDave is offline   Reply With Quote
Old 06-08-2010, 02:31 PM   #3 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 155
Default

Thanks, i didnt thought about this possibilty. Works fine.
Grinarn is offline   Reply With Quote
Old 06-09-2010, 03:49 PM   #4 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 107
Default Another way to draw text...

Apple's Graphics & Animation Coding How-To's mention another way:

Code:
[myText drawAtPoint:CGPointMake(0.0,0.0) withFont:[UIFont systemFontOfSize:[UIFont systemFontSize]]];
where myText is an NSString.

Last edited by JDave; 06-09-2010 at 03:53 PM.
JDave is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 158,557
Threads: 89,123
Posts: 380,243
Top Poster: BrianSlick (7,102)
Welcome to our newest member, wTaylorDaviesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:48 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0