Package com.badlogic.gdx.graphics.g2d
Class DistanceFieldFont
- java.lang.Object
-
- com.badlogic.gdx.graphics.g2d.BitmapFont
-
- com.badlogic.gdx.graphics.g2d.DistanceFieldFont
-
- All Implemented Interfaces:
Disposable
public class DistanceFieldFont extends BitmapFont
Renders bitmap fonts using distance field textures, see the Distance Field Fonts wiki article for usage. Initialize the SpriteBatch with thecreateDistanceFieldShader()
shader.Attention: The batch is flushed before and after each string is rendered.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.badlogic.gdx.graphics.g2d.BitmapFont
BitmapFont.BitmapFontData, BitmapFont.Glyph
-
-
Constructor Summary
Constructors Constructor Description DistanceFieldFont(FileHandle fontFile)
DistanceFieldFont(FileHandle fontFile, boolean flip)
DistanceFieldFont(FileHandle fontFile, FileHandle imageFile, boolean flip)
DistanceFieldFont(FileHandle fontFile, FileHandle imageFile, boolean flip, boolean integer)
DistanceFieldFont(FileHandle fontFile, TextureRegion region)
DistanceFieldFont(FileHandle fontFile, TextureRegion region, boolean flip)
DistanceFieldFont(BitmapFont.BitmapFontData data, TextureRegion region, boolean integer)
DistanceFieldFont(BitmapFont.BitmapFontData data, Array<TextureRegion> pageRegions, boolean integer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ShaderProgram
createDistanceFieldShader()
Returns a new instance of the distance field shader, see https://libgdx.com/wiki/graphics/2d/fonts/distance-field-fonts if the u_smoothing uniform > 0.0.float
getDistanceFieldSmoothing()
protected void
load(BitmapFont.BitmapFontData data)
BitmapFontCache
newFontCache()
Creates a new BitmapFontCache for this font.void
setDistanceFieldSmoothing(float distanceFieldSmoothing)
-
Methods inherited from class com.badlogic.gdx.graphics.g2d.BitmapFont
dispose, draw, draw, draw, draw, draw, getAscent, getCache, getCapHeight, getColor, getData, getDescent, getLineHeight, getRegion, getRegion, getRegions, getScaleX, getScaleY, getSpaceXadvance, getXHeight, isFlipped, ownsTexture, setColor, setColor, setFixedWidthGlyphs, setOwnsTexture, setUseIntegerPositions, toString, usesIntegerPositions
-
-
-
-
Constructor Detail
-
DistanceFieldFont
public DistanceFieldFont(BitmapFont.BitmapFontData data, Array<TextureRegion> pageRegions, boolean integer)
-
DistanceFieldFont
public DistanceFieldFont(BitmapFont.BitmapFontData data, TextureRegion region, boolean integer)
-
DistanceFieldFont
public DistanceFieldFont(FileHandle fontFile, boolean flip)
-
DistanceFieldFont
public DistanceFieldFont(FileHandle fontFile, FileHandle imageFile, boolean flip, boolean integer)
-
DistanceFieldFont
public DistanceFieldFont(FileHandle fontFile, FileHandle imageFile, boolean flip)
-
DistanceFieldFont
public DistanceFieldFont(FileHandle fontFile, TextureRegion region, boolean flip)
-
DistanceFieldFont
public DistanceFieldFont(FileHandle fontFile, TextureRegion region)
-
DistanceFieldFont
public DistanceFieldFont(FileHandle fontFile)
-
-
Method Detail
-
load
protected void load(BitmapFont.BitmapFontData data)
- Overrides:
load
in classBitmapFont
-
newFontCache
public BitmapFontCache newFontCache()
Description copied from class:BitmapFont
Creates a new BitmapFontCache for this font. Using this method allows the font to provide the BitmapFontCache implementation to customize rendering.Note this method is called by the BitmapFont constructors. If a subclass overrides this method, it will be called before the subclass constructors.
- Overrides:
newFontCache
in classBitmapFont
-
getDistanceFieldSmoothing
public float getDistanceFieldSmoothing()
- Returns:
- The distance field smoothing factor for this font.
-
setDistanceFieldSmoothing
public void setDistanceFieldSmoothing(float distanceFieldSmoothing)
- Parameters:
distanceFieldSmoothing
- Set the distance field smoothing factor for this font. SpriteBatch needs to have this shader set for rendering distance field fonts.
-
createDistanceFieldShader
public static ShaderProgram createDistanceFieldShader()
Returns a new instance of the distance field shader, see https://libgdx.com/wiki/graphics/2d/fonts/distance-field-fonts if the u_smoothing uniform > 0.0. Otherwise the same code as the default SpriteBatch shader is used.
-
-