From bfe83a66cf04174d03f9af427ef557e207886a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drahom=C3=ADr=20Karch=C5=88=C3=A1k?= <drahomir.karchnak@nic.cz> Date: Mon, 21 Mar 2016 10:01:20 +0100 Subject: [PATCH] #274 Fixed problem, when fonts were not loaded on time. Causing application to crash... --- core/src/cz/nic/tablexia/Tablexia.java | 4 +++- .../application/ApplicationFontManager.java | 22 ++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/core/src/cz/nic/tablexia/Tablexia.java b/core/src/cz/nic/tablexia/Tablexia.java index f64728686..1c1ea3c7a 100644 --- a/core/src/cz/nic/tablexia/Tablexia.java +++ b/core/src/cz/nic/tablexia/Tablexia.java @@ -132,11 +132,13 @@ public class Tablexia extends TablexiaApplication { } private void startLoading(Locale locale) { + // Prepare fonts (Fonts need to be loaded before any screen is active) + ApplicationFontManager.getInstance().load(); + // sync loaded screen with loader image setScreen(Utility.getScreenForScreenClass(TablexiaSettings.LOADER_SCREEN, null)); // async internal assets loading - ApplicationFontManager.getInstance().load(); ApplicationTextManager.getInstance().load(locale); ApplicationInternalSoundManager.getInstance().load(); ApplicationInternalTextureManager.getInstance().load(); diff --git a/core/src/cz/nic/tablexia/loader/application/ApplicationFontManager.java b/core/src/cz/nic/tablexia/loader/application/ApplicationFontManager.java index 0dc9ccae9..736bd1045 100644 --- a/core/src/cz/nic/tablexia/loader/application/ApplicationFontManager.java +++ b/core/src/cz/nic/tablexia/loader/application/ApplicationFontManager.java @@ -104,7 +104,15 @@ public class ApplicationFontManager extends AssetManager implements IApplication instance = null; } - private void loadSDFFont() { + public ShaderProgram getDistanceFieldShader() { + return distanceFieldShader; + } + + public DistanceFieldFont getDistanceFieldFont(FontType_NEW fontType) { + return fontType.isBold() ? robotoBoldFont : robotoRegularFont; + } + + public void load() { robotoRegularFont = new DistanceFieldFont(Gdx.files.internal(ROBOTO_REGULAR_FONT_FILE), false); robotoRegularFont.setUseIntegerPositions(false); robotoRegularFont.setDistanceFieldSmoothing(ApplicationFontManager.DISTANCE_FIELD_FONT_SIZE); @@ -119,16 +127,4 @@ public class ApplicationFontManager extends AssetManager implements IApplication // pedantic flag indicating whether attributes & uniforms must be present at all times // distanceFieldShader.pedantic = false; } - - public ShaderProgram getDistanceFieldShader() { - return distanceFieldShader; - } - - public DistanceFieldFont getDistanceFieldFont(FontType_NEW fontType) { - return fontType.isBold() ? robotoBoldFont : robotoRegularFont; - } - - public void load() { - loadSDFFont(); - } } \ No newline at end of file -- GitLab