Don't crash when font glyphs are missing

This commit is contained in:
Anuken
2021-07-14 21:40:47 -04:00
parent a9f9ddcacf
commit 0c3d7e09e0
2 changed files with 7 additions and 3 deletions

View File

@@ -236,8 +236,12 @@ public class Fonts{
} }
public static TextureRegionDrawable getGlyph(Font font, char glyph){ public static TextureRegionDrawable getGlyph(Font font, char glyph){
Glyph g = font.getData().getGlyph(glyph); Glyph found = font.getData().getGlyph(glyph);
if(g == null) throw new IllegalArgumentException("No glyph: " + glyph + " (" + (int)glyph + ")"); if(found == null){
Log.warn("No icon found for glyph: @ (@)", glyph, (int)glyph);
found = font.getData().getGlyph('F');
}
Glyph g = found;
float size = Math.max(g.width, g.height); float size = Math.max(g.width, g.height);
TextureRegionDrawable draw = new TextureRegionDrawable(new TextureRegion(font.getRegion().texture, g.u, g.v2, g.u2, g.v)){ TextureRegionDrawable draw = new TextureRegionDrawable(new TextureRegion(font.getRegion().texture, g.u, g.v2, g.u2, g.v)){

View File

@@ -10,4 +10,4 @@ kapt.include.compile.classpath=false
kotlin.stdlib.default.dependency=false kotlin.stdlib.default.dependency=false
#needed for android compilation #needed for android compilation
android.useAndroidX=true android.useAndroidX=true
archash=b8db131172548e1f10ba86392e09819c34296711 archash=fbdfa0307101b881e208f53666c1f4b7ebf0fe90