Skip to main content
Participant
February 24, 2010
Question

Getting list of used fonts in TextFlow

  • February 24, 2010
  • 1 reply
  • 418 views

Hi!

I'm wondering how i can get a list of fonts used in a TextFlow - especially usefull, when working with embedded fonts loaded

at runtime.

The idea is to be able when loading new content into textflow, to preload the used fonts before the text is shown.

Any suggestions? - looking at the API, i have not been able to come up with any solution.

Kindly regards

// Netphreak

This topic has been closed for replies.

1 reply

Adobe Employee
February 24, 2010

There's no single place you get can a list of fonts, but it wouldn't be too hard to generate one. Iterate through all the leaf nodes, and get the font from the computedFormat. I'm thinking something like this would work:

function getFontList(textFlow:TextFlow)

{

     var leaf:FlowLeafElement = textFlow.getFirstLeaf();

     while (leaf)

     {     

          var fontFamily:String = leaf.computedFormat.fontFamily;    

          // add fontFamily to list if its not already there

          leaf = leaf.getNextLeaf();

   }

}

If you want to, you could check for InlineGraphicElement and ignore their fontFamily settings.

- robin