3
votes

I am trying to embed a font in my Flash Builder 4.6 project, so far unsuccessful. I searched around and found this fix, adding "-managers flash.fonts.AFEFontManager" to the Compiler, doesn't work. I've embedded tons of images to the same project, but I'm not sure what's going on with the embedding of fonts.

I get this error:

Multiple markers at this line:

-unable to build font 'Chinese Rocks Rg'

-exception during transcoding: Font for alias 'Chinese Rocks Rg' with plain weight and style was not found at: file:/E:/StarlingIntro - >Finished/src/../assets/textures/chinese_rocks_rg.otf

-Unable to transcode ../assets/textures/chinese_rocks_rg.otf.

For the following code:

    [Embed(source="../assets/textures/chinese_rocks_rg.otf", fontName="Chinese Rocks Rg", fontWeight="normal", advancedAntiAliasing="true", embedAsCFF=false, mimeType = "application/x-font")] 
    public var ChineseRocks_FontClass:Class;
    public var chineseRocks_textFromat:TextFormat = new TextFormat("Chinese Rocks Rg");

What do they mean was not found? It's the same path as everything else I've embedded. Does it mean that it's expecting a certain "style" from the .otf file? Wut?

Thanks for any info on this!

PS: it gives the same error for other fonts as well, for example MyriadWebPro.ttf.

[EDIT]

Okay, here's what's going on. I am using this embed code right now:

[Embed(source="chinese_rocks_rg.otf", //yes, it's in my src folder because I'm paranoid 
            fontName = "myChineseRocks", 
            mimeType = "application/x-font", 
            fontWeight="normal", 
            fontStyle="normal", 
            unicodeRange="englishRange", 
            advancedAntiAliasing="true" 

    )]//embedAsCFF="false"

I have commented out the embedAsCFF, because I tried it with the -managers=flash.fonts.AFEFontManager compiler parameter. None of the two work.

This is in Flash Builder 4.6, using Flex SDK 4.6.0. Now, if I switch to Flex SDK 3.6.0, the error seems to go away, but I can't use 3.6.0 since I'm using the Starling Stage3D framework.

Is it possible that stuff changed from 4.0 to 4.6, and now your article, Divillysausages, (which really illuminated me btw) doesn't apply to it?

[EDIT2]

I solved it! With the help of Divillysausages and his patience :).

Basically, I was completely stupid. I had a "#" and 2x" ` "s in the actual path to my project. I KNEW having those dumb folder names would screw my stuff up some day! And sure enough it did -with Java, but I moved Eclipse out of there a long time ago and forgot about it.

Anyway, I moved the flash project to a more friendly directory and included the embedAsCFF="false" and it worked. Also, having -managers=flash.fonts.AFEFontManager in your compiler arguments or not, seems to not matter.

3
unless you're using spark components, set embedAsCFF=false (it's true by default in flex 4). It's possible some stuff has changed since I wrote it, but just testing it there (I downloaded the latest SDK), it's working. Can you send me the font file? Is it still the same error? - divillysausages
Thanks for trying it out yourself. It made me realize it had to be the path, and notice the " ` "s in my dir names... - Spectraljump
glad to see you got it working :) If you want to read up on font managers, check out help.adobe.com/en_US/flex/using/… - divillysausages

3 Answers

4
votes

fontWeight="regular", doesn't exist. You're probably looking for fontWeight="normal" (or "bold", or "heavy")

Basically what your error is telling you that in the font you're trying to load, it couldn't find the weight "regular", so it can't be embedded.

I wrote this a while ago to explain font embedding, it might help: http://divillysausages.com/blog/as3_font_embedding_masterclass

0
votes

Be sure you are not overwriting the default flex config file. If you need some config property append them in Additionnal compiler arguments : -load-config+=configFile.xml rather than -load-config configFile.xml It solve our trouble

0
votes

I had the same issue embeding .otf font to starling project. Resolved it by converting the otf file to ttf

Good luck