Issue centering TextFields


I come back with an issue regarding centering two TextFields. So I have two TextFields each aligned at the center. I have two functions which handle the creation of these two TextFields. The issue I have is that, for example, if “createTextField1()” is placed before “createTextField2()” then the TextField created by the first function will be slightly to the right and not exactly in the center. If I put “createTextField2()” before “createTextField1()” then the second text will be slightly to the right.

Here is the code:


import openfl.display.Sprite;
import openfl.text.TextField;
import openfl.text.TextFormat;
import openfl.text.TextFormatAlign;
import openfl.Lib;

class InfoScene extends Sprite
    public function new()

private function onInit(): Void
    createDeveloperInfoText(); // This will be slightly to the right
    createIconsInfoText(); // This text is centered

private function createDeveloperInfoText(): Void
    var developerInfoTextFormat = new TextFormat();
    developerInfoTextFormat.align = TextFormatAlign.CENTER;
    developerInfoTextFormat.size = / 25);
    developerInfoTextFormat.font = "fonts/Ikaros.otf";
    developerInfoTextFormat.color = Colors.WHITE;

    var developerInfoText = new TextField();
    developerInfoText.text = "Designed and developed by\n ...";
    developerInfoText.defaultTextFormat = developerInfoTextFormat;
    developerInfoText.width = Lib.current.stage.stageWidth;
    developerInfoText.height = developerInfoTextFormat.size * 3;
    developerInfoText.x = 0;
    developerInfoText.y = Lib.current.stage.stageHeight / 5;


private function createIconsInfoText(): Void
    var iconsInfoTextFormat = new TextFormat();
    iconsInfoTextFormat.align = TextFormatAlign.CENTER;
    iconsInfoTextFormat.size = / 25);
    iconsInfoTextFormat.font = "fonts/Ikaros.otf";
    iconsInfoTextFormat.color = Colors.WHITE;

    var iconsInfoText = new TextField();
    iconsInfoText.text = "Icons made by ...\nfrom ...";
    iconsInfoText.defaultTextFormat = iconsInfoTextFormat;
    iconsInfoText.width = Lib.current.stage.stageWidth;
    iconsInfoText.height = iconsInfoTextFormat.size * 3;
    iconsInfoText.x = 0;
    iconsInfoText.y = Lib.current.stage.stageHeight / 3;



How does it look in Flash?

In flash it’s not even centered.

Perhaps it’s something to do with the periods

No, even if I replace those periods I get the same results.

Huh, maybe its something about this font

Thank you so much! The font was the problem.