Skip to content

Commit

Permalink
Update FlxBitmapText.hx to make appendGlyphs work
Browse files Browse the repository at this point in the history
  • Loading branch information
SeiferTim authored Oct 19, 2023
1 parent cd9df9e commit 7e8f8cf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions flixel/text/FlxBitmapText.hx
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ class FlxBitmapText extends FlxSprite

function set_text(value:String):String
{
value = parseExtraGlyphs(value);
if (value != text)
{
text = value;
Expand All @@ -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;
Expand Down

0 comments on commit 7e8f8cf

Please # to comment.