Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Fonts such as Verdana might have greater readability at smaller sizes; however, it sounds like you are experiencing text metrics issues.</p> <p>In this example, TextLineMetrics are used to accurately measure each text field.</p> <p>Result:</p> <p><img src="https://i.stack.imgur.com/zK00a.png" alt="text line metrics"></p> <p>Code:</p> <pre><code>package { import flash.display.Sprite; import flash.text.AntiAliasType; import flash.text.Font; import flash.text.TextField; import flash.text.TextFieldAutoSize; import flash.text.TextFormat; import flash.text.TextFormatAlign; import flash.text.TextLineMetrics; [SWF(percentWidth = 100, percentHeight = 100, backgroundColor = 0xefefef, frameRate = 30)] public class X extends Sprite { public function X() { super(); // collection of words var words:Array = [ "These", "are", "the", "words", "to", "be", "placed" ]; // define a text format var textFormat:TextFormat = new TextFormat(); textFormat.font = "Arial"; textFormat.bold = false; textFormat.size = 8; textFormat.color = 0x0; textFormat.align = TextFormatAlign.LEFT; // destination x coordinate for next word text field var dx:Number = 0; // for every word for each (var word:String in words) { // create a text field var textField:TextField = new TextField(); textField.setTextFormat(textFormat); textField.defaultTextFormat = textFormat; textField.autoSize = TextFieldAutoSize.LEFT; textField.antiAliasType = AntiAliasType.ADVANCED; // set text and place the text field textField.text = word; textField.x = dx; textField.y = 20; addChild(textField); // measure the text field for accurate width var textLineMetrics:TextLineMetrics = textField.getLineMetrics(0); dx += textLineMetrics.width + 2; } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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