I'm trying to draw a character from a Unicode font whose value is 0x1d11e (this is the treble clef character from the Sonata font).
I read on an Adobe forum that I have to convert Unicode chars > 0xFFFF to using UTF-16 surrogate pairs, but this doesn't seem to work.
Here's my code:
[Embed(source='C:/WINDOWS/Fonts/SonataStd.otf',
fontName="Sonata__", mimeType="application/x-font")]
private var font1:Class;
public function draw():void {
var txt:TextField = new TextField();
var fmt:TextFormat = new TextFormat("Sonata__", 40);
var clefChar:uint = 0x1d11e
var p1:uint = (((clefChar - 0x10000) >> 10) & 0x3ff) + 0xd800;
var p2:uint = ((clefChar - 0x10000) & 0x3ff ) + 0xdc00;
txt.text = String.fromCharCode(p1, p2);
txt.setTextFormat(fmt);
txt.embedFonts = true;
addChild(txt);
When I run this code nothing gets drawn. If I try drawing a 2-byte Unicode char it works.
This is on Flex 3, running on Flash Player 10.
Thanks.