diff --git a/source/funkin/backend/assets/Paths.hx b/source/funkin/backend/assets/Paths.hx index d8c6ba39..1bc880ff 100644 --- a/source/funkin/backend/assets/Paths.hx +++ b/source/funkin/backend/assets/Paths.hx @@ -116,17 +116,28 @@ class Paths return scriptPath; } - static public function chart(song:String, ?difficulty:String = "normal"):String { + static public function chart(song:String, ?difficulty:String = "normal"):String + { difficulty = difficulty.toLowerCase(); song = song.toLowerCase(); return getPath('songs/$song/charts/$difficulty.json', null); } - static public function character(character:String):String { + inline static public function character(character:String):String + { return getPath('data/characters/$character.xml', null); } + /** + * Gets the name of a registered font. + * @param font The font's path (if it's already passed as a font name, the same name will be returned) + */ + inline static public function getFontName(font:String) + { + return OpenFlAssets.exists(font, FONT) ? OpenFlAssets.getFont(font).fontName : font; + } + inline static public function font(key:String) { return getPath('fonts/$key'); diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index 70feb55f..9fd7f3c5 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -582,7 +582,7 @@ class CoolUtil var fmt = new FlxTextFormat(); fmt.format.color = Reflect.hasField(fmtt, "color") ? FlxColor.fromString(fmtt.color) : text.color; - fmt.format.font = Reflect.hasField(fmtt, "font") ? Paths.font(fmtt.font) : text.font; + fmt.format.font = Reflect.hasField(fmtt, "font") ? Paths.getFontName(Paths.font(fmtt.font)) : text.font; fmt.format.size = Reflect.hasField(fmtt, "size") ? Std.parseInt(fmtt.size) : text.size; fmt.format.italic = Reflect.hasField(fmtt, "italic") ? fmtt.italic == "true" : text.italic; fmt.format.bold = Reflect.hasField(fmtt, "bold") ? fmtt.bold == "true" : text.bold;