Class BitmapFontSupport

java.lang.Object
com.github.tommyettinger.textra.BitmapFontSupport

public class BitmapFontSupport extends Object
A utility class for loading BitmapFont instances from Structured JSON files (which use .json, .dat, .ubj, .json.lzma, or .ubj.lzma as their file extension). Font instances can already be loaded using some of the constructors there.
Note: While .ubj and .ubj.lzma files are supported by this on most platforms, libGDX 1.13.1 and older do not parse many UBJSON files correctly on GWT. Even though .ubj.lzma is typically the format that gets the best compression ratios here, .json.lzma is preferred because it compresses almost as well and works on GWT.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Mainly for internal use; allows loading BitmapFontData from a Structured JSON Font instead of a .fnt file.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.badlogic.gdx.graphics.g2d.BitmapFont
    loadStructuredJson(com.badlogic.gdx.files.FileHandle jsonFont, com.badlogic.gdx.graphics.g2d.TextureRegion region)
    Creates a BitmapFont by loading it from a Structured JSON Font, which is typically a .json, .dat, .ubj, .json.lzma, or .ubj.lzma file produced by FontWriter or a related tool.
    static com.badlogic.gdx.graphics.g2d.BitmapFont
    loadStructuredJson(com.badlogic.gdx.files.FileHandle jsonFont, com.badlogic.gdx.graphics.g2d.TextureRegion region, boolean flip)
    Creates a BitmapFont by loading it from a Structured JSON Font, which is typically a .json, .dat, .ubj, .json.lzma, or .ubj.lzma file produced by FontWriter or a related tool.
    static com.badlogic.gdx.graphics.g2d.BitmapFont
    loadStructuredJson(com.badlogic.gdx.files.FileHandle jsonFont, String imagePath)
    Creates a BitmapFont by loading it from a Structured JSON Font, which is typically a .json, .dat, .ubj, .json.lzma, or .ubj.lzma file produced by FontWriter or a related tool.
    static com.badlogic.gdx.graphics.g2d.BitmapFont
    loadStructuredJson(com.badlogic.gdx.files.FileHandle jsonFont, String imagePath, boolean flip)
    Creates a BitmapFont by loading it from a Structured JSON Font, which is typically a .json, .dat, .ubj, .json.lzma, or .ubj.lzma file produced by FontWriter or a related tool.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BitmapFontSupport

      public BitmapFontSupport()
  • Method Details

    • loadStructuredJson

      public static com.badlogic.gdx.graphics.g2d.BitmapFont loadStructuredJson(com.badlogic.gdx.files.FileHandle jsonFont, com.badlogic.gdx.graphics.g2d.TextureRegion region)
      Creates a BitmapFont by loading it from a Structured JSON Font, which is typically a .json, .dat, .ubj, .json.lzma, or .ubj.lzma file produced by FontWriter or a related tool. This overload takes a TextureRegion for the image the JSON needs; this region is often part of an atlas.
      Parameters:
      jsonFont - a FileHandle with the path to a Structured JSON Font (typically a .json.lzma file)
      region - a TextureRegion, often part of a shared atlas, holding the image the JSON needs
      Returns:
      a new BitmapFont loaded from jsonFont
    • loadStructuredJson

      public static com.badlogic.gdx.graphics.g2d.BitmapFont loadStructuredJson(com.badlogic.gdx.files.FileHandle jsonFont, com.badlogic.gdx.graphics.g2d.TextureRegion region, boolean flip)
      Creates a BitmapFont by loading it from a Structured JSON Font, which is typically a .json, .dat, .ubj, .json.lzma, or .ubj.lzma file produced by FontWriter or a related tool. This overload takes a TextureRegion for the image the JSON needs; this region is often part of an atlas.
      Parameters:
      jsonFont - a FileHandle with the path to a Structured JSON Font (typically a .json.lzma file)
      region - a TextureRegion, often part of a shared atlas, holding the image the JSON needs
      flip - true if this BitmapFont has been flipped for use with a y-down coordinate system
      Returns:
      a new BitmapFont loaded from jsonFont
    • loadStructuredJson

      public static com.badlogic.gdx.graphics.g2d.BitmapFont loadStructuredJson(com.badlogic.gdx.files.FileHandle jsonFont, String imagePath)
      Creates a BitmapFont by loading it from a Structured JSON Font, which is typically a .json, .dat, .ubj, .json.lzma, or .ubj.lzma file produced by FontWriter or a related tool. This overload takes a relative path (from jsonFont) to the necessary image file, with the path as a String.
      Parameters:
      jsonFont - a FileHandle with the path to a Structured JSON Font (typically a .json.lzma file)
      imagePath - a String holding the relative path from jsonFont to the image file the JSON needs
      Returns:
      a new BitmapFont loaded from jsonFont
    • loadStructuredJson

      public static com.badlogic.gdx.graphics.g2d.BitmapFont loadStructuredJson(com.badlogic.gdx.files.FileHandle jsonFont, String imagePath, boolean flip)
      Creates a BitmapFont by loading it from a Structured JSON Font, which is typically a .json, .dat, .ubj, .json.lzma, or .ubj.lzma file produced by FontWriter or a related tool. This overload takes a relative path (from jsonFont) to the necessary image file, with the path as a String.
      Parameters:
      jsonFont - a FileHandle with the path to a Structured JSON Font (typically a .json.lzma file)
      imagePath - a String holding the relative path from jsonFont to the image file the JSON needs
      flip - true if this BitmapFont has been flipped for use with a y-down coordinate system
      Returns:
      a new BitmapFont loaded from jsonFont