Enum Class Font.DistanceFieldType

java.lang.Object
java.lang.Enum<Font.DistanceFieldType>
com.github.tommyettinger.textra.Font.DistanceFieldType
All Implemented Interfaces:
Serializable, Comparable<Font.DistanceFieldType>, Constable
Enclosing class:
Font

public static enum Font.DistanceFieldType extends Enum<Font.DistanceFieldType>
Defines what types of distance field font this can use and render.
  • STANDARD has no distance field.
  • SDF is the signed distance field technique Hiero is compatible with, and uses only an alpha channel.
  • MSDF is the multi-channel signed distance field technique, which is sharper but uses the RGB channels.
  • SDF_OUTLINE can use the same font files as SDF, but draws them with a black outline.
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Used by Multi-channel Signed Distance Field fonts, which are typically created by fontwriter or msdf-atlas-gen and can sometimes be more crisp than SDF fonts MSDF produces hard corners where the corners were hard in the original font.
    Used by Signed Distance Field fonts that are compatible with DistanceFieldFont, and may be created by Hiero with its Distance Field effect, fontwriter or the tool it uses and builds upon, msdf-atlas-gen.
    Very similar to SDF, except that this draws a moderately-thick black outline around all SDF glyphs.
    Used by normal fonts with no distance field effect.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Font.DistanceFieldType[]
     
    final String
    The part of a filename before the extension that is used to look up fonts with this DistanceFieldType.
    final String
    The part of the typical name of a Font that says what distance field that Font has, if any.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • STANDARD

      public static final Font.DistanceFieldType STANDARD
      Used by normal fonts with no distance field effect. If the font has a large image that is downscaled, you may want to call Font.setTextureFilter(). You can optionally set a custom ShaderProgram this can use by setting Font.shader.
    • SDF

      public static final Font.DistanceFieldType SDF
      Used by Signed Distance Field fonts that are compatible with DistanceFieldFont, and may be created by Hiero with its Distance Field effect, fontwriter or the tool it uses and builds upon, msdf-atlas-gen. You may want to set the Font.distanceFieldCrispness field to a higher or lower value depending on how thick the stroke is in the font; this can take experimentation, but the default is 1 and higher values have sharper edges (risking getting pixelated if too high).
    • MSDF

      public static final Font.DistanceFieldType MSDF
      Used by Multi-channel Signed Distance Field fonts, which are typically created by fontwriter or msdf-atlas-gen and can sometimes be more crisp than SDF fonts MSDF produces hard corners where the corners were hard in the original font. Creating MSDF fonts can be done with fontwriter or the tool it uses and builds upon, msdf-atlas-gen. You may want to set the Font.distanceFieldCrispness field to a higher or lower value than its default of 1 based on preference, with higher values making more crisp (possibly aliased) fonts and lower values making softer (possibly blurry) fonts.
    • SDF_OUTLINE

      public static final Font.DistanceFieldType SDF_OUTLINE
      Very similar to SDF, except that this draws a moderately-thick black outline around all SDF glyphs. It won't necessarily draw the outline correctly for inline images without a distance field effect. The outline will respect the transparency of the glyph (unlike Font.BLACK_OUTLINE mode). This can use the same font files as SDF; just set Font.distanceField to SDF_OUTLINE.
  • Field Details

    • ALL

      public static final Font.DistanceFieldType[] ALL
    • filePart

      public final String filePart
      The part of a filename before the extension that is used to look up fonts with this DistanceFieldType. Always one of "-standard", "-sdf", or "-msdf".
    • namePart

      public final String namePart
      The part of the typical name of a Font that says what distance field that Font has, if any.
  • Method Details

    • values

      public static Font.DistanceFieldType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Font.DistanceFieldType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null