ncannasse vor 9 Jahren
Ursprung
Commit
513c33ce29
1 geänderte Dateien mit 16 neuen und 0 gelöschten Zeilen
  1. 16 0
      h2d/Font.hx

+ 16 - 0
h2d/Font.hx

@@ -66,6 +66,22 @@ class Font {
 		}
 		return c;
 	}
+	
+	public function clone() {
+		var f = new Font(name, size);
+		f.baseLine = baseLine;
+		f.lineHeight = lineHeight;
+		f.tile = tile.clone();
+		f.charset = charset;
+		f.defaultChar.t = defaultChar.t.clone();
+		for( g in glyphs.keys() ) {
+			var c = glyphs.get(g);
+			var c2 = new FontChar(c.t.clone(), c.width);
+			@:privateAccess (c2.kerning = c.kerning);
+			f.glyphs.set(g, c2);
+		}
+		return f;
+	}
 
 	/**
 		This is meant to create smoother fonts by creating them with double size while still keeping the original glyph size.