Finished comicfans mod example

This commit is contained in:
David
2024-04-10 15:02:22 -04:00
parent 6e653bc298
commit 74f1703faa
9 changed files with 1157 additions and 10 deletions
File diff suppressed because it is too large Load Diff
+2 -3
View File
@@ -1,6 +1,5 @@
{
"name": "Comic Fans Font",
"author" : "Example",
"revision": 3,
"description": "Font that was made by damieng. See: https://damieng.com/typography/zx-origins/comic-fans/"
"authors" : ["Example", "Damien Guard"],
"description": "A fun 8x8 font that was created by Damien Guard. See: https://damieng.com/typography/zx-origins/comic-fans/"
}
@@ -1,8 +1,8 @@
{
"compressed": true,
"flags": {
"wrap-s": "Wrap",
"wrap-t": "Wrap"
"wrap-s": "CLAMP",
"wrap-t": "CLAMP"
},
"format": "IA4",
"images": [
Binary file not shown.

Before

Width:  |  Height:  |  Size: 679 B

After

Width:  |  Height:  |  Size: 1.0 KiB

@@ -10,7 +10,7 @@ BuildFonts::BuildFonts(DkrAssetsSettings &settings, BuildInfo &info) : _settings
// "rawDataSize" is the size of the FontData structure with the correct number of fonts.
// Have to do this, since the number of fonts is dynamic.
size_t rawDataSize = FileHelper::align16(4 + numberOfFonts * sizeof(FontFile));
size_t rawDataSize = FileHelper::align16(sizeof(be_uint32_t) + (numberOfFonts * sizeof(FontFile)));
uint8_t *rawData = new uint8_t[rawDataSize];
std::memset(rawData, 0, rawDataSize); // zero out rawData bytes.
@@ -56,9 +56,16 @@ BuildFonts::BuildFonts(DkrAssetsSettings &settings, BuildInfo &info) : _settings
int fontTextureIndex = AssetsHelper::get_asset_index(settings, "ASSET_TEXTURES_2D", texBuildId);
DebugHelper::info(texBuildId, " = ", fontTextureIndex);
outFontFile->textureIndices[texIndex] = fontTextureIndex;
}
// Fills in the rest with nulls
for(size_t texIndex = numTextures; texIndex < FONTS_NUMBER_OF_TEXTURE_INDICES; texIndex++) {
outFontFile->textureIndices[texIndex] = -1;
}
// Assume ASCII by default.
std::string encodingType = fontJson->get_string("/encoding/type", "ASCII");
@@ -69,6 +69,8 @@ BuildTexture::BuildTexture(DkrAssetsSettings &settings, BuildInfo &info) : _sett
header->width = imgWidth;
header->height = imgHeight;
// TODO: Check if width and/or height is greater than 255, and error if it is!
if(writeSize) {
header->textureSize = DataHelper::align16(sizeof(TextureHeader) + ImageHelper::image_size(imgWidth, imgHeight, format));
} else {
@@ -305,6 +305,12 @@ fs::path FileHelper::get_directory(const fs::path &path) {
return path.parent_path();
}
void FileHelper::delete_directory(const fs::path &path) {
if(fs::exists(path)) {
fs::remove_all(path);
}
}
void FileHelper::rename(const fs::path &oldPath, const fs::path &newPath) {
fs::rename(oldPath, newPath);
}
@@ -46,6 +46,8 @@ public:
static fs::path get_directory(const fs::path &path);
static void delete_directory(const fs::path &path);
static void rename(const fs::path &oldPath, const fs::path &newPath);
static void copy(const fs::path &oldPath, const fs::path &newPath, bool recursive = false);
@@ -127,8 +127,10 @@ void CompileAssets::_compile_assets() {
_statFile->set_value<int>("/last-order-size", _modOrderCount);
// First copy the vanilla path to the out path.
// This seems to be the slowest part, mainly limited by IO speed (copying thousands of small files).
// First clear the output directory (if it exists)
FileHelper::delete_directory(_outAssetsPath);
// Copy all the vanilla files over to the output directory
FileHelper::copy(_vanillaAssetsPath, _outAssetsPath, true);
if(_modOrderCount == 0) {