开发者

Flex special characters not embedding

开发者 https://www.devze.com 2022-12-28 03:26 出处:网络
I am using the following code to embed Arial into my application: [Embed(source=\'../assets/fonts/Arial.ttf\',fontFamily=\'CustomFont\',fontWeight=\'regular\',

I am using the following code to embed Arial into my application:

[Embed(source='../assets/fonts/Arial.ttf',fontFamily='CustomFont',fontWeight='regular',
        unicodeRange='U+0020-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E,U+0080-U+00FF,U+0100-U+017F,U+0400-U+04FF,U+0370-U+03FF,U+1E00-U+1EFF,U+2022,U+2219,U+20AC-U+21AC',
        mimeType='application/x-font-truetype' 
        )]
    public static var MY_FONT:Class;
    [Embed(source='../assets/fonts/Arial Bold.ttf',fontFamily='CustomFont',fontWeight='bold',
        unicodeRange='U+0020-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E,U+0080-U+00FF,U+0100-U+017F,U+0400-U+04FF,U+0370-U+03FF,U+1E00-U+1EFF,U+2022,U+2219,U+20AC-U+21AC',
        mimeType='application/x-font-truetype'
        )]
    public static var MY_FONT_BOLD:Class;
    [Embed(source='../assets/fonts/Arial Italic.ttf',fontFamily='CustomFont',fontWeight='regular',fontStyle="italic",
    开发者_JS百科    unicodeRange='U+0020-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E,U+0080-U+00FF,U+0100-U+017F,U+0400-U+04FF,U+0370-U+03FF,U+1E00-U+1EFF,U+2022,U+2219,U+20AC-U+21AC',
        mimeType='application/x-font-truetype'
        )] 
    public static var MY_FONT_ITALIC:Class;
    [Embed(source='../assets/fonts/Arial Bold Italic.ttf',fontFamily='CustomFont',fontWeight='bold',fontStyle="italic",
        unicodeRange='U+0020-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E,U+0080-U+00FF,U+0100-U+017F,U+0400-U+04FF,U+0370-U+03FF,U+1E00-U+1EFF,U+2022,U+2219,U+20AC-U+21AC',
        mimeType='application/x-font-truetype'
        )] 
    public static var MY_FONT_ITALIC_BOLD:Class;
    [Embed(source='../assets/fonts/Arial Unicode.ttf',fontFamily='CustomFont',fontWeight='regular',
        unicodeRange='U+0020-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E,U+0080-U+00FF,U+0100-U+017F,U+0400-U+04FF,U+0370-U+03FF,U+1E00-U+1EFF,U+2022,U+2219,U+20AC-U+21AC',
        mimeType='application/x-font-truetype'
        )] 
    public static var MY_FONT_UNICODE:Class;

It's working fine for foreign characters, but no special characters (copyright, trademark, euro sign etc) are working. Can anyone help? I've checked my unicode ranges, they should work fine!


If you don't specify a unicode range, do the characters appear (I'm not suggesting to launch this way, merely for testing). If they don't appear with the full font embedded, maybe your version of the font doesn't contain the characters. Arial Unicode should contain the copyright at least though, it's code is U+00A9, which I think is included in your ranges but you could try explicitly including that number, ie adding: U+00A9-U+00A9.

You might find this AIR app handy for determining unicode ranges: http://undefined-type.com/tag/unicode/


I'd suggest using external libraries for fonts esp. considering their weight if unicode chars are embedded. There's a rather trivial AS3 script to embed a system font, e.g. Impact:

package {
    import flash.display.Sprite;
    public class Impact extends Sprite {
        [Embed(systemFont='Impact', fontName='Impact', mimeType='application/x-font')]
        public static var Impact:Class;
    }    
}

You can get the above *.as from http://tekkie.flashbit.net/flash/as/embed-system-fonts-with-flex-sdk

0

精彩评论

暂无评论...
验证码 换一张
取 消