Skip to content

1. More precise preloader for html5; 2. Fix font preloading in Safari.#866

Merged
jgranick merged 1 commit intoopenfl:developfrom
restorer:more-precise-preloader
Dec 20, 2016
Merged

1. More precise preloader for html5; 2. Fix font preloading in Safari.#866
jgranick merged 1 commit intoopenfl:developfrom
restorer:more-precise-preloader

Conversation

@restorer
Copy link
Copy Markdown
Contributor

@restorer restorer commented Dec 20, 2016

More precise preloader for html5

In latest OpenFL / Lime version preloader din't work as earlier. This PR tries to fix it.

Additionally it adds trace of error, because without it is very difficult to guess why game is not loading (usually this is related because howler can't load .wav or .ogg sound; interestingly, it was working earlier with soundjs, but this is another story...)

Fix font preloading in Safari

It seems that Safari reports that font loaded while font IS NOT actually loaded. There are 2 identical TextView's, first is added immediately, second after some timeout:

screen shot 2016-12-20 at 13 19 26

This is reproduced with last OpenFL / Lime version, this IS NOT related to font preloading issue fixed in 4e8bc03. This happens only in Safari.

Demo: http://pub.zame-dev.org/openfl-safari-font-preloader/canvas/
Full source: http://pub.zame-dev.org/openfl-safari-font-preloader/project.zip

class App extends Sprite {
    public function new() {
        super();

        addTextField(50);

        Timer.delay(function() : Void {
            addTextField(100);
        }, 1000);
    }

    private function addTextField(y : Float) : Void {
        var textField = new TextField();
        textField.borderColor = 0x800000;
        textField.border = true;
        textField.selectable = false;
        textField.wordWrap = false;
        textField.autoSize = TextFieldAutoSize.LEFT;
        textField.x = 50;
        textField.y = y;

        addChild(textField);

        var textFormat = new TextFormat();
        textFormat.font = Assets.getFont("assets/font/MyriadProCond.ttf").fontName;
        textFormat.color = 0xffffff;
        textFormat.size = 24;

        textField.defaultTextFormat = textFormat;
        textField.setTextFormat(textFormat);

        textField.text = "THIS IS THE TEST";

        var width = textField.textWidth + 4;
        var height = textField.textHeight + 4;

        textField.autoSize = TextFieldAutoSize.NONE;
        textField.width = width;
        textField.height = height;
    }
}

@jgranick jgranick merged commit 2e7b1d3 into openfl:develop Dec 20, 2016
@restorer restorer deleted the more-precise-preloader branch December 21, 2016 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants