Question

I've been stuck for a very, very long time on this issue, which has already been raised and discussed many times. The task is yet a simple one, and really shouldn't take the insane amount of time it already has: to bold a few words in a textfield with an embedded font (other than Arial).

The b tag only seems to work when using a font in which Flash seems to recognize the bold weight natively (Arial, etc.) - but I use a font that comes in 4 weights: regular, medium, bold, and black. I need the black weight for bold words in the medium weight body text.

I did literally dozens of tests, all failing using "classic" text fields, embedding the font once for each weight and using htmlText: tried every setting possible in the embed dialog, with tags b, span, em - with TextFormat (bold, font) or StyleSheet (fontWeight, fontStyle, fontFamily)...

Conclusion: there is NO way to set 2 different embedded fonts in a single textField.

The problem is surely linked to the embedding of the fonts, confirmed with the following debug helper functions:

/**
 *  Debug helper: trace embedded fonts
 */
function trace_embedded_fonts():void
{
    var fonts:Array = Font.enumerateFonts();
    for ( var i:int = 0; i < fonts.length; i++ )
       trace( fonts[ i ].fontName + " - " + fonts[ i ].fontStyle + " - " + fonts[ i ].fontType );
}

/**
 *  Debug helper: Trace format
 */
function trace_classic_textfield_format( tf:TextField ):void
{
    trace( "trace_tlf_textfield_format( " + tf.name + " )" );
    trace( "  font = " + tf.getTextFormat().font );
}

outputting respectively Maven Pro - regular - embedded (just this single line even though I embedded 4 times the font, once per weight - and yes: I named them carefully, and I tried exporting for actionscript, in DF3 and in DF4, and also without exporting), and font = Maven Pro on all the textField instances on the scene, whichever style is applied on them (also tried both selecting the embedded font - with * at the end - and the system font).

In short, the font is weird, but I can't do anything about it.

So my question relates to the new Text Layout Framework (TLFTextField): can it be achieved with it ?

The text is loaded from XML and contains simple tags like em, b, etc., but rewriting them to flow tags is not an option.

I tried the conversion available via the TextConverter class - like var tf:TextFlow = TextConverter.importToFlow(hyperText, TextConverter.TEXT_FIELD_HTML_FORMAT); - cf. http://help.adobe.com/en_US/as3/dev/WS14c3067b34b57c6d4a97343b122ab36a52f-7ffb.html#WS14c3067b34b57c6d4a97343b122ab36a52f-7ff9 - but I don't understand how to style each tag and how to apply the TextFlow to a TLF Text Field already added manually on the Flash stage ?

Was it helpful?

Solution

For information, I gave up using TLFTextFields and worked around this issue by using another font (one for which Flash understands the bold) - the moral of the story is that this issue is currently a cruel limitation to TextFields in Flash.

One more thing: bold text won't work in textfields dynamically added on stage unless there already are TextFields (in each style you need to use) present on the stage from the start (I left 2 textfields with "test" in white on a white bg to hide them).

Note for the future: make videos à la "Angry Video Game Nerd" for issues like these.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top