瀏覽代碼

halfSize is now resizeTo

Nicolas Cannasse 12 年之前
父節點
當前提交
aac7e7cac0
共有 1 個文件被更改,包括 7 次插入6 次删除
  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 ) {