From fc7cbd846a9b40e8f2c60a4a32331a3272af5531 Mon Sep 17 00:00:00 2001 From: raeleus Date: Mon, 4 Mar 2024 07:29:23 -0800 Subject: [PATCH] Prevent crash when using fonts in a relative resource project. Resolves #143 --- CHANGES.md | 1 + core/src/com/ray3k/skincomposer/dialog/DialogFonts.java | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c9ac2341..cfec95fe 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,7 @@ * Refactored Scene Composer and fixed various errors. Resolves #135. Thanks deviodesign! * Added more finite control of scale in settings. Thanks ChinQingl * Fixed FreeTypeFontGenerator from creating glyphs with the wrong page index if there are multiple pages +* Prevent crash when using fonts in a relative resource project. Resolves #143. Thanks SonicNorg! ### Skin Composer Version 56 ### * Fixed font scaling issues. diff --git a/core/src/com/ray3k/skincomposer/dialog/DialogFonts.java b/core/src/com/ray3k/skincomposer/dialog/DialogFonts.java index cc7a3772..f089ad7b 100644 --- a/core/src/com/ray3k/skincomposer/dialog/DialogFonts.java +++ b/core/src/com/ray3k/skincomposer/dialog/DialogFonts.java @@ -417,9 +417,11 @@ public boolean touchDown(InputEvent event, float x, float y, int pointer, int bu if (bf.imagePaths.length > 0) { FileHandle file = new FileHandle(bf.imagePaths[0]); if (!file.exists()) { - file = bf.fontFile.sibling(bf.fontFile.nameWithoutExtension() + ".png"); + file = font.file.sibling(bf.fontFile.nameWithoutExtension() + ".png"); } - if (Utils.brightness(Utils.averageEdgeColor(file)) < .5f) { + if (!file.exists()) { + bg.setColor(Color.BLACK); + } else if (Utils.brightness(Utils.averageEdgeColor(file)) < .5f) { bg.setColor(Color.WHITE); } else { bg.setColor(Color.BLACK);