From b6676856f593cc15524369fad8ebe85119ad4f9d Mon Sep 17 00:00:00 2001 From: nockawa Date: Wed, 22 Feb 2017 11:47:14 +0100 Subject: [PATCH] Canvas2D: Attempt #1 to fix Delayed FontTexture in Text2D [Trello Card](https://trello.com/c/rhriSGcf) --- canvas2D/src/Engine/babylon.text2d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/canvas2D/src/Engine/babylon.text2d.ts b/canvas2D/src/Engine/babylon.text2d.ts index 1d1a3800c60..3989726e470 100644 --- a/canvas2D/src/Engine/babylon.text2d.ts +++ b/canvas2D/src/Engine/babylon.text2d.ts @@ -462,6 +462,15 @@ this._fontName = null; this._fontSuperSample = false; this._fontSDF = false; + + let ft = this._fontTexture; + if (ft != null && !ft.isReady()) { + ft.onLoadObservable.add(() => { + this._positioningDirty(); + this._setLayoutDirty(); + this._instanceDirtyFlags |= Prim2DBase.originProperty.flagId; // To make sure the Text2D is issued again for render + }); + } } else { this._fontName = (settings.fontName==null) ? "12pt Arial" : settings.fontName; this._fontSuperSample= (settings.fontSuperSample!=null && settings.fontSuperSample);