mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Stop caching the counter font on Android, which was causing issues when trying to save the files
This commit is contained in:
@@ -65,8 +65,10 @@ public class CardRenderer {
|
|||||||
private static final Map<CounterType, Color> counterColorCache = new HashMap<>();
|
private static final Map<CounterType, Color> counterColorCache = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
if (counterFont == null) {
|
try {
|
||||||
generateFontForCounters();
|
generateFontForCounters();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -707,10 +709,12 @@ public class CardRenderer {
|
|||||||
final FreeTypeFontGenerator.FreeTypeBitmapFontData fontData = generator.generateData(parameter);
|
final FreeTypeFontGenerator.FreeTypeBitmapFontData fontData = generator.generateData(parameter);
|
||||||
final Array<PixmapPacker.Page> pages = packer.getPages();
|
final Array<PixmapPacker.Page> pages = packer.getPages();
|
||||||
|
|
||||||
|
//TODO Cache this
|
||||||
//finish generating font on UI thread
|
//finish generating font on UI thread
|
||||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
TextureRegion[] textureRegions = new TextureRegion[pages.size];
|
TextureRegion[] textureRegions = new TextureRegion[pages.size];
|
||||||
for (int i = 0; i < pages.size; i++) {
|
for (int i = 0; i < pages.size; i++) {
|
||||||
PixmapPacker.Page p = pages.get(i);
|
PixmapPacker.Page p = pages.get(i);
|
||||||
@@ -727,18 +731,9 @@ public class CardRenderer {
|
|||||||
|
|
||||||
counterFont = new BitmapFont(fontData, textureRegions, true);
|
counterFont = new BitmapFont(fontData, textureRegions, true);
|
||||||
|
|
||||||
//create .fnt and .png files for font
|
|
||||||
FileHandle pixmapDir = Gdx.files.absolute(ForgeConstants.FONTS_DIR);
|
|
||||||
if (pixmapDir != null) {
|
|
||||||
FileHandle fontFile = pixmapDir.child("Roboto-Bold.fnt");
|
|
||||||
BitmapFontWriter.setOutputFormat(BitmapFontWriter.OutputFormat.Text);
|
|
||||||
|
|
||||||
String[] pageRefs = BitmapFontWriter.writePixmaps(packer.getPages(), pixmapDir, "Roboto-Bold");
|
|
||||||
BitmapFontWriter.writeFont(counterFont.getData(), pageRefs, fontFile, new BitmapFontWriter.FontInfo("Roboto-Bold", fontSize), 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
generator.dispose();
|
generator.dispose();
|
||||||
packer.dispose();
|
packer.dispose();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user