Selaa lähdekoodia

fix for text when no font set

ncannasse 9 vuotta sitten
vanhempi
commit
111276e0e8
1 muutettua tiedostoa jossa 9 lisäystä ja 2 poistoa
  1. 9 2
      h2d/Text.hx

+ 9 - 2
h2d/Text.hx

@@ -70,6 +70,10 @@ class Text extends Drawable {
 	}
 	}
 
 
 	override function draw(ctx:RenderContext) {
 	override function draw(ctx:RenderContext) {
+		if( glyphs == null ) {
+			emitTile(ctx, h2d.Tile.fromColor(0xFF00FF, 16, 16));
+			return;
+		}
 		if( dropShadow != null ) {
 		if( dropShadow != null ) {
 			var oldX = absX, oldY = absY;
 			var oldX = absX, oldY = absY;
 			absX += dropShadow.dx * matA + dropShadow.dy * matC;
 			absX += dropShadow.dx * matA + dropShadow.dy * matC;
@@ -257,9 +261,12 @@ class Text extends Drawable {
 			var size = cachedSize == null ? initGlyphs(text, false) : cachedSize;
 			var size = cachedSize == null ? initGlyphs(text, false) : cachedSize;
 			addBounds(relativeTo, out, 0, 0, size.width, size.height);
 			addBounds(relativeTo, out, 0, 0, size.width, size.height);
 		} else {
 		} else {
-			glyphs.visible = true;
+			if( glyphs != null ) glyphs.visible = true;
 			super.getBoundsRec(relativeTo, out);
 			super.getBoundsRec(relativeTo, out);
-			glyphs.visible = false;
+			if( glyphs != null )
+				glyphs.visible = false;
+			else
+				addBounds(relativeTo, out, 0, 0, 16, 16);
 		}
 		}
 	}
 	}