()
| 394 | } |
| 395 | |
| 396 | private void updateFont() { |
| 397 | String fontName = "f"; |
| 398 | if (scale != 1) { |
| 399 | if (fontSize > MAX_FONT_SIZE) |
| 400 | fontName += MAX_FONT_SIZE; |
| 401 | else |
| 402 | fontName += MIN_FONT_SIZE; |
| 403 | } else { |
| 404 | fontName += fontSize; |
| 405 | } |
| 406 | boolean useCjkFont = Lang.initInstance(Forge.locale).getFontFile() != null; |
| 407 | if (useCjkFont && !Forge.forcedEnglishonCJKMissing) { |
| 408 | fontName += Forge.locale; |
| 409 | } |
| 410 | FileHandle fontFile = Gdx.files.absolute(ForgeConstants.FONTS_DIR + fontName + ".fnt"); |
| 411 | final boolean[] found = {false}; |
| 412 | if (fontFile != null && fontFile.exists()) { |
| 413 | FThreads.invokeInEdtNowOrLater(() -> { //font must be initialized on UI thread |
| 414 | try { |
| 415 | font = Forge.getAssets().manager().get(fontFile.path(), BitmapFont.class, false); |
| 416 | if (font == null && fontFile.toString().endsWith(".fnt")) { |
| 417 | Forge.getAssets().manager().load(fontFile.path(), BitmapFont.class); |
| 418 | Forge.getAssets().manager().finishLoadingAsset(fontFile.path()); |
| 419 | font = Forge.getAssets().manager().get(fontFile.path(), BitmapFont.class, false); |
| 420 | } |
| 421 | if (font != null) |
| 422 | found[0] = true; |
| 423 | } catch (Exception e) { |
| 424 | e.printStackTrace(); |
| 425 | found[0] = false; |
| 426 | } |
| 427 | }); |
| 428 | } |
| 429 | if (found[0]) |
| 430 | return; |
| 431 | //not found generate |
| 432 | if (useCjkFont && !Forge.forcedEnglishonCJKMissing) { |
| 433 | String ttfName = Forge.CJK_Font; |
| 434 | FileHandle ttfFile = Gdx.files.absolute(ForgeConstants.FONTS_DIR + ttfName + ".ttf"); |
| 435 | if (ttfFile != null && ttfFile.exists()) { |
| 436 | generateFont(ttfFile, fontName, fontSize); |
| 437 | } |
| 438 | } else { |
| 439 | generateFont(FSkin.getSkinFile(TTF_FILE), fontName, fontSize); |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | private void generateFont(final FileHandle ttfFile, final String fontName, final int fontSize) { |
| 444 | if (!ttfFile.exists()) { return; } |
no test coverage detected