diff --git a/jme3-core/src/main/java/com/jme3/app/DetailedProfilerState.java b/jme3-core/src/main/java/com/jme3/app/DetailedProfilerState.java index 7a3e0393cc..6de1dd4c78 100644 --- a/jme3-core/src/main/java/com/jme3/app/DetailedProfilerState.java +++ b/jme3-core/src/main/java/com/jme3/app/DetailedProfilerState.java @@ -108,8 +108,8 @@ protected void initialize(Application app) { ui.attachChild(darkenStats); ui.setLocalTranslation(app.getCamera().getWidth() - PANEL_WIDTH, app.getCamera().getHeight(), 0); - font = app.getAssetManager().loadFont("Interface/Fonts/Console.fnt"); - bigFont = app.getAssetManager().loadFont("Interface/Fonts/Default.fnt"); + font = app.getAssetManager().loadFont("Interface/Fonts/Console.j3o"); + bigFont = app.getAssetManager().loadFont("Interface/Fonts/Default.j3o"); prof.setRenderer(app.getRenderer()); rootLine = new StatLineView("Frame"); rootLine.attachTo(ui); diff --git a/jme3-core/src/main/java/com/jme3/app/SimpleApplication.java b/jme3-core/src/main/java/com/jme3/app/SimpleApplication.java index ced517be5f..3400dc0cb6 100644 --- a/jme3-core/src/main/java/com/jme3/app/SimpleApplication.java +++ b/jme3-core/src/main/java/com/jme3/app/SimpleApplication.java @@ -248,7 +248,7 @@ public void setShowSettings(boolean showSettings) { * @return the loaded BitmapFont */ protected BitmapFont loadGuiFont() { - return assetManager.loadFont("Interface/Fonts/Default.fnt"); + return assetManager.loadFont("Interface/Fonts/Default.j3o"); } @Override diff --git a/jme3-core/src/main/java/com/jme3/app/StatsAppState.java b/jme3-core/src/main/java/com/jme3/app/StatsAppState.java index 2078626a9c..54ca80fb93 100644 --- a/jme3-core/src/main/java/com/jme3/app/StatsAppState.java +++ b/jme3-core/src/main/java/com/jme3/app/StatsAppState.java @@ -155,7 +155,7 @@ public void initialize(AppStateManager stateManager, Application app) { } if (guiFont == null) { - guiFont = app.getAssetManager().loadFont("Interface/Fonts/Default.fnt"); + guiFont = app.getAssetManager().loadFont("Interface/Fonts/Default.j3o"); } loadFpsText(); diff --git a/jme3-core/src/main/java/com/jme3/app/StatsView.java b/jme3-core/src/main/java/com/jme3/app/StatsView.java index 8e274e97b5..514cae82b8 100644 --- a/jme3-core/src/main/java/com/jme3/app/StatsView.java +++ b/jme3-core/src/main/java/com/jme3/app/StatsView.java @@ -82,7 +82,7 @@ public StatsView(String name, AssetManager manager, Statistics stats) { statLabels = statistics.getLabels(); statData = new int[statLabels.length]; - BitmapFont font = manager.loadFont("Interface/Fonts/Console.fnt"); + BitmapFont font = manager.loadFont("Interface/Fonts/Console.j3o"); statText = new BitmapText(font); statText.setLocalTranslation(0, statText.getLineHeight() * statLabels.length, 0); attachChild(statText); diff --git a/jme3-core/src/main/java/com/jme3/input/virtual/VirtualJoystickTheme.java b/jme3-core/src/main/java/com/jme3/input/virtual/VirtualJoystickTheme.java index 4c16af3009..cb37a9333d 100644 --- a/jme3-core/src/main/java/com/jme3/input/virtual/VirtualJoystickTheme.java +++ b/jme3-core/src/main/java/com/jme3/input/virtual/VirtualJoystickTheme.java @@ -45,7 +45,7 @@ */ public class VirtualJoystickTheme implements Savable { - private static final String DEFAULT_FONT = "Interface/Fonts/Default.fnt"; + private static final String DEFAULT_FONT = "Interface/Fonts/Default.j3o"; public enum TextureKey { BUTTON, diff --git a/jme3-core/src/main/resources/Interface/Fonts/Console.j3o b/jme3-core/src/main/resources/Interface/Fonts/Console.j3o new file mode 100644 index 0000000000..94a18c724f Binary files /dev/null and b/jme3-core/src/main/resources/Interface/Fonts/Console.j3o differ diff --git a/jme3-core/src/main/resources/Interface/Fonts/Default.j3o b/jme3-core/src/main/resources/Interface/Fonts/Default.j3o new file mode 100644 index 0000000000..3b62130002 Binary files /dev/null and b/jme3-core/src/main/resources/Interface/Fonts/Default.j3o differ diff --git a/jme3-core/src/test/java/com/jme3/asset/DefaultFontJ3oTest.java b/jme3-core/src/test/java/com/jme3/asset/DefaultFontJ3oTest.java new file mode 100644 index 0000000000..a58e60df97 --- /dev/null +++ b/jme3-core/src/test/java/com/jme3/asset/DefaultFontJ3oTest.java @@ -0,0 +1,47 @@ +package com.jme3.asset; + +import com.jme3.asset.plugins.ClasspathLocator; +import com.jme3.export.binary.BinaryLoader; +import com.jme3.font.BitmapFont; +import com.jme3.material.plugins.J3MLoader; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +/** + * Verifies that Default.j3o (with embedded image data) can be loaded using only + * the loaders available in jme3-core, without depending on the PNG loader from + * jme3-plugins. This is needed for Android/iOS which don't depend on jme3-plugins. + */ +public class DefaultFontJ3oTest { + + private static DesktopAssetManager createCoreOnlyAssetManager() { + DesktopAssetManager assetManager = new DesktopAssetManager(false); + assetManager.registerLocator("/", ClasspathLocator.class); + assetManager.registerLoader(BinaryLoader.class, "j3o", "j3f"); + assetManager.registerLoader(J3MLoader.class, "j3m", "j3md"); + return assetManager; + } + + private static void assertFontLoaded(DesktopAssetManager assetManager, String path) { + BitmapFont font = assetManager.loadFont(path); + assertNotNull(font, path + " should load without a PNG loader"); + assertNotNull(font.getPage(0), path + " should have at least one material page"); + assertNotNull(font.getPage(0).getTextureParam("ColorMap"), + path + " material page should have a ColorMap texture"); + assertNotNull(font.getPage(0).getTextureParam("ColorMap").getTextureValue().getImage(), + path + " texture should have embedded image data (no key needed)"); + } + + @Test + public void testDefaultFontJ3oLoadsWithoutPngLoader() { + // This should succeed: Default.j3o has embedded image data (no PNG loader needed) + assertFontLoaded(createCoreOnlyAssetManager(), "Interface/Fonts/Default.j3o"); + } + + @Test + public void testConsoleFontJ3oLoadsWithoutPngLoader() { + // This should succeed: Console.j3o has embedded image data (no PNG loader needed) + assertFontLoaded(createCoreOnlyAssetManager(), "Interface/Fonts/Console.j3o"); + } +}