Package com.github.tommyettinger.textra
Class BitmapFontSupport
java.lang.Object
com.github.tommyettinger.textra.BitmapFontSupport
A utility class for loading
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.
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 ClassesModifier and TypeClassDescriptionstatic class
Mainly for internal use; allows loading BitmapFontData from a Structured JSON Font instead of a .fnt file. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.
-
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 needsflip
- 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 (fromjsonFont
) 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 fromjsonFont
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 (fromjsonFont
) 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 fromjsonFont
to the image file the JSON needsflip
- true if this BitmapFont has been flipped for use with a y-down coordinate system- Returns:
- a new BitmapFont loaded from
jsonFont
-