Last active
August 29, 2015 14:27
-
-
Save xavierstampslafont/1458b5cea79620f870bc to your computer and use it in GitHub Desktop.
Text width measured inconsistently between Legacy and Next on native target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package; | |
import openfl.display.Sprite; | |
import openfl.text.Font; | |
import openfl.text.TextField; | |
import openfl.text.TextFieldAutoSize; | |
import openfl.text.TextFormat; | |
import openfl.Lib; | |
class Main extends Sprite { | |
private var _log:TextField; | |
public function new () { | |
super (); | |
var format = new TextFormat ("Katamotz Ikasi", 60, 0x7A0026); | |
var textField = new TextField (); | |
textField.defaultTextFormat = format; | |
textField.embedFonts = true; | |
textField.selectable = false; | |
textField.y = 50; | |
textField.autoSize = TextFieldAutoSize.LEFT; | |
textField.text = "Hello World"; | |
addChild (textField); | |
// On Flash Legacy and Next, 281.45 | |
// On Mac Legacy, traces 285 | |
// On Mac Next, traces 280.71875 | |
doTrace(textField.width); | |
// On Flash Legacy and Next, it's placed consistently and looks exactly the same. | |
// On Mac Legacy, nicely hugs the right side of the app window | |
// On Mac Next, compared to Legacy, the right edge is just off screen | |
// On Mac Legacy and Next, it appears slightly larger than on Flash. | |
textField.x = Lib.current.stage.stageWidth - textField.width; | |
var textFieldWithTrailingSpace = new TextField(); | |
textFieldWithTrailingSpace.defaultTextFormat = format; | |
textFieldWithTrailingSpace.embedFonts = true; | |
textFieldWithTrailingSpace.selectable = false; | |
textFieldWithTrailingSpace.y = 250; | |
textFieldWithTrailingSpace.autoSize = TextFieldAutoSize.LEFT; | |
textFieldWithTrailingSpace.text = "Space after this "; | |
addChild(textFieldWithTrailingSpace); | |
// On Flash Legacy and Next, traces 579.35 | |
// On Mac Legacy, traces 580 | |
// On Next, traces 386.03125 | |
doTrace(textFieldWithTrailingSpace.width); | |
// On Flash Legacy and Next, this is approximately in the center of the window due to the spaces | |
// On Mac Legacy, it's approximately in the center of the window as well. | |
// On Mac Next, it's all the way to the right, as if there were no spaces. | |
textFieldWithTrailingSpace.x = Lib.current.stage.stageWidth - textFieldWithTrailingSpace.width; | |
// Links to screenshots: | |
// Flash Legacy https://dl.dropboxusercontent.com/u/7139766/The%20Mission/text%20width%20bug/Flash%20Legacy.png | |
// Flash Next https://dl.dropboxusercontent.com/u/7139766/The%20Mission/text%20width%20bug/Flash%20Next.png | |
// Mac Legacy https://dl.dropboxusercontent.com/u/7139766/The%20Mission/text%20width%20bug/Mac%20Legacy.png | |
// Mac Next https://dl.dropboxusercontent.com/u/7139766/The%20Mission/text%20width%20bug/Mac%20Next.png | |
} | |
private function doTrace(message:Dynamic):Void { | |
if (_log == null) { | |
_log = new TextField(); | |
addChild(_log); | |
} | |
_log.text += message.toString() + "\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Flash Legacy
Flash Next
Mac Legacy
Mac Next