Prechádzať zdrojové kódy

prevent newline chars from being displayed as invalid char

ncannasse 7 rokov pred
rodič
commit
266f98bcde
1 zmenil súbory, kde vykonal 4 pridanie a 2 odobranie
  1. 4 2
      h2d/Font.hx

+ 4 - 2
h2d/Font.hx

@@ -54,6 +54,7 @@ class Font {
 	public var tile(default,null) : h2d.Tile;
 	public var tile(default,null) : h2d.Tile;
 	public var charset : hxd.Charset;
 	public var charset : hxd.Charset;
 	var glyphs : Map<Int,FontChar>;
 	var glyphs : Map<Int,FontChar>;
+	var nullChar : FontChar;
 	var defaultChar : FontChar;
 	var defaultChar : FontChar;
 	var initSize:Int;
 	var initSize:Int;
 	var offsetX:Int = 0;
 	var offsetX:Int = 0;
@@ -64,7 +65,7 @@ class Font {
 		this.size = size;
 		this.size = size;
 		this.initSize = size;
 		this.initSize = size;
 		glyphs = new Map();
 		glyphs = new Map();
-		defaultChar = new FontChar(new Tile(null, 0, 0, 0, 0),0);
+		defaultChar = nullChar = new FontChar(new Tile(null, 0, 0, 0, 0),0);
 		charset = hxd.Charset.getDefault();
 		charset = hxd.Charset.getDefault();
 	}
 	}
 
 
@@ -72,7 +73,8 @@ class Font {
 		var c = glyphs.get(code);
 		var c = glyphs.get(code);
 		if( c == null ) {
 		if( c == null ) {
 			c = charset.resolveChar(code, glyphs);
 			c = charset.resolveChar(code, glyphs);
-			if( c == null ) c = defaultChar;
+			if( c == null )
+				c = code == "\r".code || code == "\n".code ? nullChar : defaultChar;
 		}
 		}
 		return c;
 		return c;
 	}
 	}