Ver código fonte

halfSize is now resizeTo

Nicolas Cannasse 12 anos atrás
pai
commit
aac7e7cac0
1 arquivos alterados com 7 adições e 6 exclusões
  1. 7 6
      h2d/Font.hx

+ 7 - 6
h2d/Font.hx

@@ -67,15 +67,16 @@ class Font {
 	}
 	
 	/**
-		Divides by two the glyphs size. This is meant to create smoother fonts by creating them with double size
-		while still keeping the original glyph size.
+		This is meant to create smoother fonts by creating them with double size while still keeping the original glyph size.
 	**/
-	public function halfSize() {
+	public function resizeTo( size : Int ) {
+		var ratio = size / this.size;
 		for( c in glyphs ) {
-			c.width >>= 1;
-			c.t.scaleToSize(c.t.width >> 1, c.t.height >> 1);
+			c.width = Std.int(c.width * ratio);
+			c.t.scaleToSize(Std.int(c.t.width * ratio), Std.int(c.t.height * ratio));
 		}
-		lineHeight >>= 1;
+		lineHeight = Std.int(lineHeight * ratio);
+		this.size = size;
 	}
 	
 	public function hasChar( code : Int ) {