Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you can get the text field font name by using <code>getTextFormat</code> function of it. Consider <code>txt</code> is the textfield, then</p> <pre><code>var format:TextFormat = txt.getTextFormat(); trace(format.font); </code></pre> <p>After some research, I found this solution and it might solve the problem.</p> <pre><code>import flash.text.TextField; import flash.text.TextFormat; import flash.utils.getQualifiedClassName; import flash.text.Font; import flash.display.Loader; import flash.events.Event; import flash.net.URLRequest; var font:Font; var txt:TextField; var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded); loader.load(new URLRequest("sub_fla.swf")); function onLoaded(e:Event){ var cl:Class = e.currentTarget.applicationDomain.getDefinition("CustomFont") as Class; Font.registerFont(cl); trace(cl); txt = new TextField(); this.addChild(txt); txt.text = "Moorthy"; var format:TextFormat = new TextFormat();// = txt.getTextFormat(); font = new cl(); format.font = font.fontName; txt.setTextFormat(format); enumerateFonts(); } function enumerateFonts(){ var embeddedFonts:Array = Font.enumerateFonts(false); embeddedFonts.sortOn("fontName", Array.CASEINSENSITIVE); trace("----&gt;"+embeddedFonts.indexOf(txt.getTextFormat().font)); for(var i:int = 0;i&lt;embeddedFonts.length;i++){ font = embeddedFonts[i]; trace("embeddedFonts["+i+"]:"+font.fontName+":"+font); if(txt.getTextFormat().font == font.fontName){ trace("My font class is '"+getQualifiedClassName(font) +"'"); } } } </code></pre> <p>Don't forget to register the font to get it in the <code>enumerateFonts</code> list. Otherwise it fetches the default font class not your custom class.</p> <p>Or else, you can simply add a variable to the movieclip (in which the text field is placed) to hold the font class or font class name. </p> <p>Eg: If <code>holder</code> is the movieclip who contains the textfield, then use</p> <p><code>holder.fontClass = cl</code></p> <p>instead of</p> <p><code>Font.registerFont</code></p> <p>and you can simply retrieve the font class by</p> <p><code>txt.parent.fontClass</code></p> <p>If so there is no need of <code>enumerateFonts</code> in this way.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload