From 0210e96c7994d1ef0a8aa6efe4d691b4dbc68175 Mon Sep 17 00:00:00 2001 From: hnhhzy Date: Fri, 7 Apr 2023 16:56:06 +0800 Subject: [PATCH 1/2] Update TrueTypeFont.hx --- glyphme/TrueTypeFont.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glyphme/TrueTypeFont.hx b/glyphme/TrueTypeFont.hx index 522142b..67f0d2c 100644 --- a/glyphme/TrueTypeFont.hx +++ b/glyphme/TrueTypeFont.hx @@ -34,7 +34,7 @@ class TrueTypeFont extends h2d.Font { super(null, sizeInPixels, h2d.Font.FontType.SignedDistanceField(Red, alphaCutOff, smoothing)); - super.lineHeight = ascent - lineGap; + super.lineHeight = sizeInPixels; super.baseLine = ascent; super.tile = @:privateAccess new Tile(null, 0, 0, 0, 0); // to avoid null access } From 2e160fc403144b25c13239875989ce330df39e6b Mon Sep 17 00:00:00 2001 From: hnhhzy Date: Wed, 12 Apr 2023 16:32:23 +0800 Subject: [PATCH 2/2] support TextInput support TextInput --- glyphme/TrueTypeFont.hx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/glyphme/TrueTypeFont.hx b/glyphme/TrueTypeFont.hx index 67f0d2c..2c9250f 100644 --- a/glyphme/TrueTypeFont.hx +++ b/glyphme/TrueTypeFont.hx @@ -38,6 +38,16 @@ class TrueTypeFont extends h2d.Font { super.baseLine = ascent; super.tile = @:privateAccess new Tile(null, 0, 0, 0, 0); // to avoid null access } + + private var __forceHasChar:Bool = false; + + override function hasChar(code:Int):Bool { + if(code == Key.BACKSPACE) return false; + if(Key.isDown(Key.CTRL)) return false; + if (__forceHasChar) + return true; + return super.hasChar(code); + } /** Fallbacks are used to look up glyphs from multiple fonts. When a glyph is not found * we try the next font. If you have multiple fallbacks with slightly overlapping glyph support