From 7e8f8cff18c4e0bcef4d0fca7bf89b012ded1158 Mon Sep 17 00:00:00 2001 From: Tim I Hely Date: Thu, 19 Oct 2023 14:04:16 -0500 Subject: [PATCH] Update `FlxBitmapText.hx` to make `appendGlyphs` work --- flixel/text/FlxBitmapText.hx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/flixel/text/FlxBitmapText.hx b/flixel/text/FlxBitmapText.hx index 977d028b58..34ae9e3f69 100644 --- a/flixel/text/FlxBitmapText.hx +++ b/flixel/text/FlxBitmapText.hx @@ -570,6 +570,7 @@ class FlxBitmapText extends FlxSprite function set_text(value:String):String { + value = parseExtraGlyphs(value); if (value != text) { text = value; @@ -579,6 +580,19 @@ class FlxBitmapText extends FlxSprite return value; } + function parseExtraGlyphs(?value:String = ""):String + { + var regex:EReg = new EReg("{{([a-zA-Z0-9 ]+)}}", "g"); + + return regex.map(value, (r) -> + { + var unicode:String = font.lookupTable.get(r.matched(1)); + if (unicode == null) + unicode = "!"; + return unicode; + }); + } + function updateText():Void { var tmp:String = (autoUpperCase) ? text.toUpperCase() : text;