Class DistanceFieldFont

java.lang.Object
arc.graphics.g2d.Font
arc.graphics.g2d.DistanceFieldFont
All Implemented Interfaces:
Disposable

public class DistanceFieldFont extends Font
Renders bitmap fonts using distance field textures, see the Distance Field Fonts wiki article for usage. Initialize the SpriteBatch with the createDistanceFieldShader() shader.

Attention: The batch is flushed before and after each string is rendered.

  • Constructor Details

    • DistanceFieldFont

      public DistanceFieldFont(Font.FontData data, Seq<TextureRegion> pageRegions, boolean integer)
    • DistanceFieldFont

      public DistanceFieldFont(Font.FontData data, TextureRegion region, boolean integer)
    • DistanceFieldFont

      public DistanceFieldFont(Fi fontFile, boolean flip)
    • DistanceFieldFont

      public DistanceFieldFont(Fi fontFile, Fi imageFile, boolean flip, boolean integer)
    • DistanceFieldFont

      public DistanceFieldFont(Fi fontFile, Fi imageFile, boolean flip)
    • DistanceFieldFont

      public DistanceFieldFont(Fi fontFile, TextureRegion region, boolean flip)
    • DistanceFieldFont

      public DistanceFieldFont(Fi fontFile, TextureRegion region)
    • DistanceFieldFont

      public DistanceFieldFont(Fi fontFile)
  • Method Details

    • createDistanceFieldShader

      public static Shader createDistanceFieldShader()
      Returns a new instance of the distance field shader, see https://github.com/libgdx/libgdx/wiki/Distance-field-fonts if the u_smoothing uniform > 0.0. Otherwise the same code as the default SpriteBatch shader is used.
    • load

      protected void load(Font.FontData data)
      Overrides:
      load in class Font
    • newFontCache

      public FontCache newFontCache()
      Description copied from class: Font
      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 class Font
    • 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.