diff --git a/lib/stateManagement/otherFileTypes/FtbFileData.dart b/lib/stateManagement/otherFileTypes/FtbFileData.dart index 2d7703a4..c3f1453f 100644 --- a/lib/stateManagement/otherFileTypes/FtbFileData.dart +++ b/lib/stateManagement/otherFileTypes/FtbFileData.dart @@ -183,14 +183,17 @@ class FtbData extends ChangeNotifier { } // generate cli json args + var heightScale = fontOverride.heightScale.value.toDouble(); + var fontHeight = McdData.availableFonts[fontId]!.fontHeight * heightScale; + var scaleFact = 44 / fontHeight; CliFontOptions? font = CliFontOptions( fontOverride.fontPath.value, - chars[0].height, + fontHeight.toInt(), fontOverride.scale.value.toDouble(), - fontOverride.letXPadding.value.toInt(), - fontOverride.letYPadding.value.toInt(), - fontOverride.xOffset.value.toDouble(), - fontOverride.yOffset.value.toDouble(), + (fontOverride.letXPadding.value * scaleFact).toInt(), + (fontOverride.letYPadding.value * scaleFact).toInt(), + (fontOverride.xOffset.value * scaleFact).toDouble(), + (fontOverride.yOffset.value * scaleFact).toDouble(), ); const textureBatchesCount = 4; var charsPerBatch = (chars.length / textureBatchesCount).ceil(); diff --git a/lib/stateManagement/otherFileTypes/McdData.dart b/lib/stateManagement/otherFileTypes/McdData.dart index 51b7698c..c16ad5c5 100644 --- a/lib/stateManagement/otherFileTypes/McdData.dart +++ b/lib/stateManagement/otherFileTypes/McdData.dart @@ -151,6 +151,7 @@ class McdLocalFont extends McdFont { class McdFontOverride with HasUuid { final ValueNestedNotifier fontIds; + final NumberProp heightScale; final StringProp fontPath; final NumberProp scale; final NumberProp letXPadding; @@ -160,6 +161,7 @@ class McdFontOverride with HasUuid { McdFontOverride(int firstFontId) : fontIds = ValueNestedNotifier([firstFontId]), + heightScale = NumberProp(1.0, false), fontPath = StringProp(""), scale = NumberProp(1.0, false), letXPadding = NumberProp(0.0, true), @@ -535,11 +537,19 @@ class McdData extends _McdFilePart { return McdLocalFont.zero(); return usedFonts[id]!; }) - .map((f) => McdFileFont( - f.fontId, - f.fontWidth.toDouble(), f.fontHeight.toDouble(), - f.fontBelow.toDouble(), 0) - ) + .map((f) { + var fontOverrideRes = fontOverrides.where((fo) => fo.fontIds.contains(f.fontId)); + double heightScale = 1.0; + if (fontOverrideRes.isNotEmpty) { + var fontOverride = fontOverrideRes.first; + heightScale = fontOverride.heightScale.value.toDouble(); + } + return McdFileFont( + f.fontId, + f.fontWidth.toDouble(), f.fontHeight * heightScale, + f.fontBelow.toDouble(), 0 + ); + }) .toList(); var exportFontMap = { for (var f in exportFonts) f.id: f }; @@ -720,15 +730,16 @@ class McdData extends _McdFilePart { var symbol = symbols[i]; if (fontOverridesMap.containsKey(symbol.fontId)) { if (!fonts.containsKey(symbol.fontId)) { - var scaleFact = 44 / availableFonts[symbol.fontId]!.fontHeight; + var fontHeight = (availableFonts[symbol.fontId]!.fontHeight * fontOverridesMap[symbol.fontId]!.heightScale.value).toInt(); + var scaleFact = 44 / fontHeight; fonts[symbol.fontId] = CliFontOptions( fontOverridesMap[symbol.fontId]!.fontPath.value, - availableFonts[symbol.fontId]!.fontHeight, + fontHeight, fontOverridesMap[symbol.fontId]!.scale.value.toDouble(), (fontOverridesMap[symbol.fontId]!.letXPadding.value * scaleFact).toInt(), (fontOverridesMap[symbol.fontId]!.letYPadding.value * scaleFact).toInt(), - fontOverridesMap[symbol.fontId]!.xOffset.value.toDouble() * scaleFact, - fontOverridesMap[symbol.fontId]!.yOffset.value.toDouble() * scaleFact, + fontOverridesMap[symbol.fontId]!.xOffset.value * scaleFact, + fontOverridesMap[symbol.fontId]!.yOffset.value * scaleFact, ); } CliImgOperationDrawFromTexture? fallback; @@ -814,6 +825,8 @@ class McdData extends _McdFilePart { Map exportFonts = {}; for (var fontId in generatedSymbols.keys) { var font = availableFonts[fontId]!; + var heightScale = fontOverridesMap[fontId]?.heightScale.value ?? 1.0; + var fontHeight = (font.fontHeight * heightScale).toInt(); Map exportSymbols = {}; for (var genSym in generatedSymbols[fontId]!) { var usedSym = genSym.item1; @@ -826,11 +839,11 @@ class McdData extends _McdFilePart { ); } var fontBelow = atlasInfo.fonts.containsKey(fontId) - ? atlasInfo.fonts[fontId]!.baseline - availableFonts[fontId]!.fontHeight + ? atlasInfo.fonts[fontId]!.baseline - fontHeight : font.fontBelow; fontBelow = min(fontBelow, 0); exportFonts[fontId] = McdLocalFont( - fontId, font.fontWidth, font.fontHeight, + fontId, font.fontWidth, fontHeight, fontBelow , exportSymbols ); } diff --git a/lib/widgets/propEditors/otherFileTypes/FontsManager.dart b/lib/widgets/propEditors/otherFileTypes/FontsManager.dart index eb075c06..21f9e0b7 100644 --- a/lib/widgets/propEditors/otherFileTypes/FontsManager.dart +++ b/lib/widgets/propEditors/otherFileTypes/FontsManager.dart @@ -32,7 +32,7 @@ class __McdFontsManagerState extends ChangeNotifierState { @override Widget build(BuildContext context) { - const columnNames = ["", "Font IDs", "TTF/OTF Path", "", "Scale", "xPadding", "yPadding", "xOffset", "yOffset", "", ""]; + const columnNames = ["", "Font IDs", "absScale", "TTF/OTF Path", "", "locScale", "xPadding", "yPadding", "xOffset", "yOffset", "", ""]; int iStart = 0; int iEnd = McdData.fontOverrides.length; @@ -50,27 +50,29 @@ class __McdFontsManagerState extends ChangeNotifierState { // columns: // X: spacer // 0: fontIDs - // 1: fontFilePath - // 2: file path selector - // 3: scale - // 4: x letter padding - // 5: y letter padding - // 6: y Offset + // 1: height scale + // 2: fontFilePath + // 3: file path selector + // 4: scale + // 5: x letter padding + // 6: y letter padding // 7: y Offset - // 8: remove button + // 8: y Offset + // 9: remove button // X: spacer columnWidths: const { 0: FixedColumnWidth(16), 1: FixedColumnWidth(100 + 8), - 2: FlexColumnWidth(1), - 3: FixedColumnWidth(30 + 8), - 4: FixedColumnWidth(60 + 8), + 2: FixedColumnWidth(60 + 8), + 3: FlexColumnWidth(1), + 4: FixedColumnWidth(30 + 8), 5: FixedColumnWidth(60 + 8), 6: FixedColumnWidth(60 + 8), 7: FixedColumnWidth(60 + 8), 8: FixedColumnWidth(60 + 8), - 9: FixedColumnWidth(30 + 8), - 10: FixedColumnWidth(16), + 9: FixedColumnWidth(60 + 8), + 10: FixedColumnWidth(30 + 8), + 11: FixedColumnWidth(16), }, defaultVerticalAlignment: TableCellVerticalAlignment.middle, children: [ @@ -121,6 +123,10 @@ class __McdFontsManagerState extends ChangeNotifierState { ), ], ), + makePropEditor( + McdData.fontOverrides[i].heightScale, + const PropTFOptions(hintText: "absScale", constraints: BoxConstraints.tightFor(height: 30)), + ), PrimaryPropTextField( prop: McdData.fontOverrides[i].fontPath, options: const PropTFOptions(hintText: "Font Path", constraints: BoxConstraints.tightFor(height: 30)),