|
@@ -16,6 +16,11 @@ class BitmapFont extends Resource {
|
|
|
this.loader = hxd.res.Loader.currentInstance;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ Load and cache the font instance.
|
|
|
+
|
|
|
+ Because font instance is cached, operations like `resizeTo` should be performed on a copy of the font, to avoid affecting other text fields.
|
|
|
+ **/
|
|
|
public function toFont() : h2d.Font {
|
|
|
if ( font == null ) {
|
|
|
font = hxd.fmt.bfnt.FontParser.parse(entry.getBytes(), entry.path, resolveTile);
|
|
@@ -24,11 +29,17 @@ class BitmapFont extends Resource {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- Load and cache Signed Distance Field font with specified size, channel, alphaCutoff and smoothing. ( default : initial size, red, 0.5, 1 / 32 )
|
|
|
+ Load and cache Signed Distance Field font with specified size, channel, alphaCutoff and smoothing. ( default : initial size, red, 0.5, -1 )
|
|
|
For more information on SDF texture generation refer to this page: https://github.com/libgdx/libgdx/wiki/Distance-field-fonts
|
|
|
For more information on MSDF texture generation refer to this page: https://github.com/Chlumsky/msdfgen
|
|
|
+
|
|
|
+ Because font instance is cached, operations like `resizeTo` should be performed on a copy of the font, to avoid affecting other text fields.
|
|
|
+
|
|
|
+ @param channel The channel that serves as distance data source.
|
|
|
+ @param alphaCutoff The distance value that is considered to be the edge. Usually should be 0.5.
|
|
|
+ @param smoothing The smoothing of edge. Lower value lead to sharper edges. Value of -1 sets it to automatic.
|
|
|
**/
|
|
|
- public function toSdfFont(?size:Int, channel : h2d.Font.SDFChannel = 0, alphaCutoff : Float = 0.5, smoothing : Float = 1 / 32 ) {
|
|
|
+ public function toSdfFont(?size:Int, channel : h2d.Font.SDFChannel = 0, alphaCutoff : Float = 0.5, smoothing : Float = -1 ) {
|
|
|
if ( sdfFonts == null ) sdfFonts = new Array();
|
|
|
if ( size == null ) size = toFont().size;
|
|
|
for ( font in sdfFonts ) {
|