Skip to content

Commit

Permalink
Add font shadow blur parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurHeitmann committed Jul 7, 2024
1 parent 5a31770 commit 39e1e33
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion assets/FontAtlasGenerator
4 changes: 3 additions & 1 deletion lib/fileTypeUtils/textures/fontAtlasGeneratorTypes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ class CliFontOptions {
final double letYOffset;
final double resolutionScale;
final int strokeWidth;
final double rgbBlurSize;

CliFontOptions(this.fontPath, this.fontHeight, this.letXPadding, this.letYPadding, this.letXOffset, this.letYOffset, this.resolutionScale, this.strokeWidth);
CliFontOptions(this.fontPath, this.fontHeight, this.letXPadding, this.letYPadding, this.letXOffset, this.letYOffset, this.resolutionScale, this.strokeWidth, this.rgbBlurSize);

Map<String, dynamic> toJson() {
return {
Expand All @@ -75,6 +76,7 @@ class CliFontOptions {
"letYOffset": letYOffset,
"resolutionScale": resolutionScale,
"strokeWidth": strokeWidth,
"rgbBlurSize": rgbBlurSize,
};
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/stateManagement/openFiles/types/FtbFileData.dart
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ class FtbData extends ChangeNotifier {
(fontOverride.yOffset.value * heightScale).toDouble(),
1.0,
fontOverride.strokeWidth.value.toInt(),
fontOverride.rgbBlurSize.value.toDouble(),
) : null;
var newFonts = pendingNewChars.map((c) => c.fontPath).toSet();
if (newFonts.length > 1)
Expand All @@ -317,6 +318,7 @@ class FtbData extends ChangeNotifier {
(fontOverride.yOffset.value * heightScale).toDouble(),
1.0,
fontOverride.strokeWidth.value.toInt(),
fontOverride.rgbBlurSize.value.toDouble(),
) : null;
// temporary source texture copies
List<String> sourceTextures = await Future.wait(textures.map((tex) async {
Expand Down
4 changes: 4 additions & 0 deletions lib/stateManagement/openFiles/types/McdFileData.dart
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ class McdFontOverride with HasUuid implements Disposable {
final NumberProp xOffset;
final NumberProp yOffset;
final NumberProp strokeWidth;
final NumberProp rgbBlurSize;
final BoolProp isFallbackOnly;

McdFontOverride(int firstFontId) :
Expand All @@ -316,6 +317,7 @@ class McdFontOverride with HasUuid implements Disposable {
xOffset = NumberProp(0.0, false, fileId: null),
yOffset = NumberProp(0.0, false, fileId: null),
strokeWidth = NumberProp(0, true, fileId: null),
rgbBlurSize = NumberProp(0.0, false, fileId: null),
isFallbackOnly = BoolProp(false, fileId: null);

@override
Expand All @@ -328,6 +330,7 @@ class McdFontOverride with HasUuid implements Disposable {
xOffset.dispose();
heightScale.dispose();
strokeWidth.dispose();
rgbBlurSize.dispose();
isFallbackOnly.dispose();
}
}
Expand Down Expand Up @@ -1071,6 +1074,7 @@ class McdData extends _McdFilePart {
fontOverridesMap[fontId]!.yOffset.value * scaleFact,
McdData.fontAtlasResolutionScale.value.toDouble(),
fontOverridesMap[fontId]!.strokeWidth.value.toInt(),
fontOverridesMap[fontId]!.rgbBlurSize.value.toDouble(),
);
}
imgOperations.add(CliImgOperationDrawFromFont(
Expand Down
10 changes: 8 additions & 2 deletions lib/widgets/filesView/types/fonts/FontsManager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class __McdFontsManagerState extends ChangeNotifierState<FontsManager> {
"xOffset",
"yOffset",
"thickness",
"shadow blur",
"",
""
];
Expand All @@ -72,8 +73,9 @@ class __McdFontsManagerState extends ChangeNotifierState<FontsManager> {
8: FixedColumnWidth(70 + 8),
9: FixedColumnWidth(70 + 8),
10: FixedColumnWidth(70 + 8),
11: FixedColumnWidth(30 + 8),
12: FixedColumnWidth(16),
11: FixedColumnWidth(100 + 8),
12: FixedColumnWidth(30 + 8),
13: FixedColumnWidth(16),
},
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
children: [
Expand Down Expand Up @@ -173,6 +175,10 @@ class __McdFontsManagerState extends ChangeNotifierState<FontsManager> {
McdData.fontOverrides[i].strokeWidth,
const PropTFOptions(hintText: "thickness", constraints: BoxConstraints.tightFor(height: 30)),
),
makePropEditor(
McdData.fontOverrides[i].rgbBlurSize,
const PropTFOptions(hintText: "shadow", constraints: BoxConstraints.tightFor(height: 30)),
),
SmallButton(
onPressed: () => McdData.fontOverrides.removeAt(i).dispose(),
constraints: BoxConstraints.tight(const Size(30, 30)),
Expand Down

0 comments on commit 39e1e33

Please sign in to comment.