Monday, November 23, 2009

iPhone dev Stupidity 101: How to draw text vertically?

1. Drawing NSString in unusual direction : limited to ascii string and have effect like this:

    use CGContextShowText(ctxt, tbuf.c_str(), tbuf.length()); and CGAffineTransform 

2. CGFontGetGlyphsForUnichars

   to draw unichar we need this function to get glyph out of a unichar. Then core graphic has a set of function for showing glyph like this one:


void CGContextShowGlyphsAtPoint (
CGContextRef c,
CGFloat x,
CGFloat y,
const
CGGlyph glyphs[],
size_t count
);


but CGFontGetGlyphsForUnichars is a private API for iPhone. So we got:

3. A replacement for CGFontGetGlyphsForUnichars

on github

-----

4. bonus: draw gradient filled UILabel.

also uses: extern void CGFontGetGlyphsForUnichars(CGFontRef, const UniChar[], const CGGlyph[], size_t);


No comments: