Search code examples
cssapache-flexflex4font-faceflex4.10

Embed Fonts using @font-face in CSS across domains in flex4.11


I am trying to Embed fonts in External css file using @font-face in flex4.11 sdk. The code snippet is like this,

MyOwnFontStyle.css:

 @namespace s "library://ns.adobe.com/flex/spark";
 @namespace mx "library://ns.adobe.com/flex/mx";
 @font-face {
    src:url("font/GOTHICB.ttf");
    fontFamily: myFontFamily;
    embedAsCFF: true;
    fontWeight: bold;
 }

 s|VGroup {
    fontFamily: myFontFamily;
    fontSize: 15;
 }   

It builds successfully without any errors. But when am launching application it throws runtime execption like below,

ArgumentError: Error #1508: The value specified for argument font is invalid. at flash.text::Font$/registerFont() at MyOwnFontStyle/setStyleDeclarations() at MethodInfo-19757() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at ModuleInfoProxy/moduleEventHandler() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at ModuleInfo/readyHandler() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::FlexModuleFactory/update() at mx.core::FlexModuleFactory/docFrameHandler() at mx.core::FlexModuleFactory/docFrameListener()

If anyone come across this kind of things, Kindly share your ideas to resolve this issue. Thanks in advance.


Solution

  • If anyone facing the same problem, do forcefully include the below statements in your main application.

    import mx.core.EmbeddedFontRegistry;

    private var embeddedFontRegistry:EmbeddedFontRegistry;