Support BitmapFonts with multiple regions

This commit is contained in:
fgnm
2022-04-12 18:34:37 +02:00
parent 4baddf1259
commit bb28ebdc75
3 changed files with 9 additions and 4 deletions
@@ -254,8 +254,12 @@ public class ResourceManager extends Proxy implements IResourceRetriever {
String filename = file.getName();
if (file.isDirectory() || filename.endsWith(".DS_Store")) continue;
BitmapFont bitmapFont = new BitmapFont(Gdx.files.internal(file.getAbsolutePath()), getTextureRegion(entry.nameWithoutExtension()));
bitmapFont.setUseIntegerPositions(false);
Array<TextureRegion> pages = new Array<>();
BitmapFont.BitmapFontData bitmapFontData = new BitmapFont.BitmapFontData(Gdx.files.internal(file.getAbsolutePath()), false);
for (String page : bitmapFontData.imagePaths) {
pages.add(getTextureRegion(FilenameUtils.getBaseName(page)));
}
BitmapFont bitmapFont = new BitmapFont(bitmapFontData, pages, false);
bitmapFonts.put(bitmapFont.getData().name, bitmapFont);
}
}
@@ -14,6 +14,7 @@ import games.rednblack.editor.view.stage.Sandbox;
import games.rednblack.h2d.common.ProgressHandler;
import games.rednblack.h2d.common.vo.ExportMapperVO;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import java.io.File;
import java.io.IOException;
@@ -100,7 +101,7 @@ public class BitmapFontAsset extends Asset {
exportMapperVO.mapper.add(new ExportMapperVO.ExportedAsset(AssetsUtils.TYPE_BITMAP_FONT, fileSrc.getName()));
BitmapFont.BitmapFontData bitmapFontData = new BitmapFont.BitmapFontData(new FileHandle(fileSrc), false);
for (String textureName : bitmapFontData.imagePaths) {
File f = new File(currentProjectPath + ProjectManager.IMAGE_DIR_PATH + File.separator + textureName);
File f = new File(currentProjectPath + ProjectManager.IMAGE_DIR_PATH + File.separator + FilenameUtils.getName(textureName));
FileUtils.copyFileToDirectory(f, tmpDir);
}
return true;