diff --git a/assets/ui/fonts/alphabet/bold.json b/assets/ui/fonts/alphabet/bold.json new file mode 100644 index 0000000..4663577 --- /dev/null +++ b/assets/ui/fonts/alphabet/bold.json @@ -0,0 +1,3 @@ +{ + "offsets": [] +} \ No newline at end of file diff --git a/assets/ui/fonts/alphabet/default.json b/assets/ui/fonts/alphabet/default.json new file mode 100644 index 0000000..6103db8 --- /dev/null +++ b/assets/ui/fonts/alphabet/default.json @@ -0,0 +1,9 @@ +{ + "offsets": [ + { + "character": "-", + "x": 0, + "y": -12 + } + ] +} \ No newline at end of file diff --git a/src/funkin/objects/ui/Alphabet.hx b/src/funkin/objects/ui/Alphabet.hx index 87ee028..496511e 100644 --- a/src/funkin/objects/ui/Alphabet.hx +++ b/src/funkin/objects/ui/Alphabet.hx @@ -1,9 +1,16 @@ package funkin.objects.ui; import flixel.graphics.frames.FlxFramesCollection; +import funkin.structures.AlphabetStructure; +import haxe.Json; class Alphabet extends FlxTypedSpriteGroup { + /** + * Data for the current letter type. + */ + public var data:AlphabetStructure; + /** * The text that this group displays. */ @@ -23,6 +30,8 @@ class Alphabet extends FlxTypedSpriteGroup { super(x, y); + data = cast Json.parse(Paths.content.json(letterType.getPath())); + this.letterType = letterType; this.text = text; } @@ -99,6 +108,16 @@ class Alphabet extends FlxTypedSpriteGroup letterSpr.setPosition(letterX, letterY + maxHeight - letterSpr.height); add(letterSpr); + for (offsetObj in data.offsets) + { + if (offsetObj?.character == letter) + { + letterSpr.x += offsetObj?.x ?? 0; + letterSpr.y += offsetObj?.y ?? 0; + break; + } + } + letterX += Math.floor(letterSpr.width); } }