I want to display the ‘infinity’ symbol using
CGContextSelectFont(context, 'HelveticaNeue', textSize, kCGEncodingMacRoman); CGContextShowTextAtPoint(context, myCenter.x, myCenter.y + textHeight, [sName cStringUsingEncoding:NSMacOSRomanStringEncoding], [sName length]);
It is displayed as a square box, or a circle. I have found out this symbol is in decimal 176 and 221E in Hexadecimal format. I am using Helvetica as my font, and have tried others with no luck. Is this a problem with the encoding I am using?
It turns out that CGContextSelectFont only supports MacRoman encoding, which is basically has only a small set of characters. In order to display Unicode characters in a string, you have to use CGSetFont or the Cocoa drawing system. CGSetFont requires that you use Cocoa anyway to map characters to glyphs and then draw the glyphs using CGContextShowGlyphsAtPoint. I recommend that you look into other ways to draw these strings if you really need to display Unicode characters.
This code basically will display the infinity symbol:
Also note that on the iPhone (and on the Mac) Helvetica Neue actually does not exist… its name just maps back to standard Helvetica. See the table at http://daringfireball.net/misc/2007/07/iphone-osx-fonts for more information on available fonts on the iPhone.