Class KnownFonts

java.lang.Object
com.github.tommyettinger.textra.KnownFonts
All Implemented Interfaces:
com.badlogic.gdx.LifecycleListener

public class KnownFonts extends Object implements com.badlogic.gdx.LifecycleListener
Preconfigured static Font instances, with any important metric adjustments already applied. This uses a singleton to ensure each font exists at most once, and implements LifecycleListener to ensure that when the disposal stage of the lifecycle is called, then all Font instances here will be disposed and assigned null. This may do more regarding its LifecycleListener code in the future, if Android turns out to need more work.
Typical usage involves calling one of the static methods like getCozette() or getGentium() to get a particular Font. This knows a fair amount of fonts, but it doesn't require the image assets for all of those to be present in a game -- only the files mentioned in the documentation for a method are needed, and only if you call that method. It's likely that many games would only use one Font, and so would generally only need a .fnt file, a .png file, and some kind of license file. They could ignore all other assets required by other fonts.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    static Font
    Returns a Font already configured to use a square font with 45-degree angled sections, based on the typeface used on the Atari ST console, that should scale cleanly to many sizes.
    static Font
    Returns a Font already configured to use a very-legible variable-width font with strong support for Canadian Aboriginal Syllabic, that should scale pretty well from a height of about 86 down to a height of maybe 30.
    static Font
    Returns a Font already configured to use a quirky fixed-width font with good Unicode support and a humanist style, that should scale cleanly to even very large sizes (using an MSDF technique).
    static Font
    Returns a Font configured to use a cozy fixed-width bitmap font, Cozette by slavfox.
    static Font
    A nice old standby font with very broad language support, DejaVu Sans Mono is fixed-width and can be clearly readable but doesn't do anything unusual stylistically.
    static Font
    Returns a Font already configured to use a variable-width serif font with excellent Unicode support, that should scale cleanly to even very large sizes (using an SDF technique).
    static Font
    A customized version of Inconsolata LGC, a fixed-width geometric font that supports a large range of Latin, Greek, and Cyrillic glyphs, plus box drawing and some dingbat characters (like zodiac signs).
    static Font
    Returns a Font already configured to use a highly-legible fixed-width font with good Unicode support and a sans-serif geometric style, that should scale cleanly to even very large sizes (using an MSDF technique).
    static Font
    Returns a Font already configured to use a highly-legible fixed-width font with good Unicode support and a slab-serif geometric style, that should scale cleanly to even very large sizes (using an MSDF technique).
    static Font
    Returns a Font already configured to use a fairly-legible variable-width ornamental/medieval font, that should scale pretty well from a height of about 90 down to a height of maybe 30.
    static Font
    Returns a Font already configured to use a variable-width serif font with good Unicode support, that should scale cleanly to even very large sizes (using an MSDF technique).
    static Font
    Returns a Font configured to use a clean variable-width font, Open Sans.
    static Font
    Returns a Font already configured to use a variable-width "science-fiction/high-tech" font, that should scale pretty well down, but not up.
    static Font
    Returns a Font already configured to use a very-legible condensed variable-width font with excellent Unicode support, that should scale pretty well from a height of about 62 down to a height of maybe 20.
    static Font
    Returns a Font already configured to use a variable-width, narrow, humanist font, that should scale pretty well down, but not up.
    void
     
    void
     

    Methods inherited from class java.lang.Object

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

    • getCozette

      public static Font getCozette()
      Returns a Font configured to use a cozy fixed-width bitmap font, Cozette by slavfox. Cozette has broad coverage of Unicode, including Greek, Cyrillic, Braille, and tech-related icons. This does not scale except to integer multiples, but it should look very crisp at its default size of 7x13 pixels.

      Needs files:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Cozette.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Cozette.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Cozette-license.txt
      Returns:
      the Font object that represents the 7x13px font Cozette
    • getOpenSans

      public static Font getOpenSans()
      Returns a Font configured to use a clean variable-width font, Open Sans. This makes an especially large font by default, but can be scaled down nicely.

      Needs files:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/OpenSans.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/OpenSans.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/OpenSans-License.txt
      Returns:
      the Font object that represents the variable-width font OpenSans
    • getAStarry

      public static Font getAStarry()
      Returns a Font already configured to use a square font with 45-degree angled sections, based on the typeface used on the Atari ST console, that should scale cleanly to many sizes. This font only supports ASCII, but it supports all of it. Caches the result for later calls. The font is "a-starry", based on "Atari ST (low-res)" by Damien Guard; it is available under a CC-BY-SA-3.0 license, which requires attribution to Damien Guard (and technically Tommy Ettinger, because he made changes in a-starry) if you use it.

      Needs files:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/AStarry-msdf.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/AStarry-msdf.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/AStarry-license.txt
      Returns:
      the Font object that can represent many sizes of the font A Starry using MSDF
    • getCascadiaMono

      public static Font getCascadiaMono()
      Returns a Font already configured to use a quirky fixed-width font with good Unicode support and a humanist style, that should scale cleanly to even very large sizes (using an MSDF technique). Caches the result for later calls. The font used is Cascadia Code Mono, an open-source (SIL Open Font License) typeface by Microsoft (see https://github.com/microsoft/cascadia-code ). It supports a lot of glyphs, including most extended Latin (though it doesn't support a handful of chars used by FakeLanguageGen), Greek, Braille, and Cyrillic, but also the necessary box drawing characters. This uses the Multi-channel Signed Distance Field (MSDF) technique as opposed to the normal Signed Distance Field technique, which gives the rendered font sharper edges and precise corners instead of rounded tips on strokes.

      Needs files:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/CascadiaMono-msdf.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/CascadiaMono-msdf.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Cascadia-license.txt
      Returns:
      the Font object that can represent many sizes of the font Cascadia Code Mono using MSDF
    • getDejaVuSansMono

      public static Font getDejaVuSansMono()
      A nice old standby font with very broad language support, DejaVu Sans Mono is fixed-width and can be clearly readable but doesn't do anything unusual stylistically. It really does handle a lot of glyphs; not only does this have practically all Latin glyphs in Unicode (enough to support everything from Icelandic to Vietnamese), it has Greek (including Extended), Cyrillic (including some optional glyphs), IPA, Armenian (maybe the only font here to do so), Georgian (which won't be treated correctly by some case-insensitive code, so it should only be used if case doesn't matter), and Lao. It has full box drawing and Braille support, handles a wide variety of math symbols, technical marks, and dingbats, etc.
      Needs files:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/DejaVuSansMono-msdf.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/DejaVuSansMono-msdf.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/DejaVuSansMono-License.txt
      Returns:
      the Font object that can represent many sizes of the font Inconsolata LGC using MSDF
    • getInconsolataLGC

      public static Font getInconsolataLGC()
      A customized version of Inconsolata LGC, a fixed-width geometric font that supports a large range of Latin, Greek, and Cyrillic glyphs, plus box drawing and some dingbat characters (like zodiac signs). The original font Inconsolata is by Raph Levien, and various other contributors added support for other languages.
      Needs files:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Inconsolata-LGC-Custom-msdf.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Inconsolata-LGC-Custom-msdf.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Inconsolata-LGC-License.txt
      Returns:
      the Font object that can represent many sizes of the font Inconsolata LGC using MSDF
    • getIosevka

      public static Font getIosevka()
      Returns a Font already configured to use a highly-legible fixed-width font with good Unicode support and a sans-serif geometric style, that should scale cleanly to even very large sizes (using an MSDF technique). Caches the result for later calls. The font used is Iosevka, an open-source (SIL Open Font License) typeface by Belleve Invis (see https://be5invis.github.io/Iosevka/ ), and it uses several customizations thanks to Iosevka's special build process. It supports a lot of glyphs, including quite a bit of extended Latin, Greek, and Cyrillic, but also the necessary box drawing characters. This uses the Multi-channel Signed Distance Field (MSDF) technique as opposed to the normal Signed Distance Field technique, which gives the rendered font sharper edges and precise corners instead of rounded tips on strokes.
      Preview: Image link
      Needs files:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Iosevka-msdf.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Iosevka-msdf.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Iosevka-License.md
      Returns:
      the Font object that can represent many sizes of the font Iosevka.ttf using MSDF
    • getIosevkaSlab

      public static Font getIosevkaSlab()
      Returns a Font already configured to use a highly-legible fixed-width font with good Unicode support and a slab-serif geometric style, that should scale cleanly to even very large sizes (using an MSDF technique). Caches the result for later calls. The font used is Iosevka with Slab style, an open-source (SIL Open Font License) typeface by Belleve Invis (see https://be5invis.github.io/Iosevka/ ), and it uses several customizations thanks to Iosevka's special build process. It supports a lot of glyphs, including quite a bit of extended Latin, Greek, and Cyrillic, but also the necessary box drawing characters. This uses the Multi-channel Signed Distance Field (MSDF) technique as opposed to the normal Signed Distance Field technique, which gives the rendered font sharper edges and precise corners instead of rounded tips on strokes.
      Preview: Image link
      Needs files:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Iosevka-Slab-msdf.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Iosevka-Slab-msdf.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Iosevka-License.md
      Returns:
      the Font object that can represent many sizes of the font Iosevka-Slab.ttf using MSDF
    • getGentium

      public static Font getGentium()
      Returns a Font already configured to use a variable-width serif font with excellent Unicode support, that should scale cleanly to even very large sizes (using an SDF technique). Caches the result for later calls. The font used is Gentium, an open-source (SIL Open Font License) typeface by SIL (see https://software.sil.org/gentium/ ). It supports a lot of glyphs, including quite a bit of extended Latin, Greek, and Cyrillic, as well as some less-common glyphs from various real languages. This uses the Signed Distance Field (SDF) technique, which may be slightly fuzzy when zoomed in heavily, but should be crisp enough when zoomed out.
      Preview: Image link
      Needs files:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Gentium-sdf.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Gentium-sdf.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Gentium-license.txt
      Returns:
      the Font object that can represent many sizes of the font Gentium.ttf using SDF
    • getLibertinusSerif

      public static Font getLibertinusSerif()
      Returns a Font already configured to use a variable-width serif font with good Unicode support, that should scale cleanly to even very large sizes (using an MSDF technique). Caches the result for later calls. The font used is Libertinus Serif, an open-source (SIL Open Font License) typeface. It supports a lot of glyphs, including quite a bit of extended Latin, Greek, and Cyrillic. This uses the Multi-channel Signed Distance Field (MSDF) technique, which should be very sharp. This probably needs to be scaled so that it has much larger width than height; the default is 150x32.
      Preview: Image link
      Needs files:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/LibertinusSerif-Regular-msdf.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/LibertinusSerif-Regular-msdf.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/LibertinusSerif-License.txt
      Returns:
      the Font object that can represent many sizes of the font LibertinusSerif.ttf using MSDF
    • getKingthingsFoundation

      public static Font getKingthingsFoundation()
      Returns a Font already configured to use a fairly-legible variable-width ornamental/medieval font, that should scale pretty well from a height of about 90 down to a height of maybe 30. Caches the result for later calls. The font used is Kingthings Foundation, a free (custom permissive license) typeface; this has faux-bold applied already in order to make some ornamental curls visible at more sizes. You can still apply bold again using markup. It supports only ASCII. This uses a very-large standard bitmap font, which lets it be scaled down nicely but not scaled up very well.
      Preview: Image link (uses width=45, height=60)
      Needs files:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/KingthingsFoundation-bold.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/KingthingsFoundation-bold.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Kingthings-License.txt
      You may instead want the non-bold version, but this doesn't have a pre-made instance in KnownFonts:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/KingthingsFoundation-standard.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/KingthingsFoundation-standard.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Kingthings-License.txt
      Returns:
      the Font object that can represent many sizes of the font KingthingsFoundation.ttf
    • getOxanium

      public static Font getOxanium()
      Returns a Font already configured to use a variable-width "science-fiction/high-tech" font, that should scale pretty well down, but not up. Caches the result for later calls. The font used is Oxanium, a free (OFL) typeface. It supports a lot of Latin and extended Latin, but not Greek or Cyrillic. This uses a very-large standard bitmap font, which lets it be scaled down nicely but not scaled up very well.
      Preview: Image link (uses width=40, height=50)
      Needs files:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Oxanium-standard.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Oxanium-standard.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Oxanium-License.txt
      Returns:
      the Font object that can represent many sizes of the font Oxanium.ttf
    • getYanoneKaffeesatz

      public static Font getYanoneKaffeesatz()
      Returns a Font already configured to use a variable-width, narrow, humanist font, that should scale pretty well down, but not up. Caches the result for later calls. The font used is Yanone Kaffeesatz, a free (OFL) typeface. It supports a lot of Latin, Cyrillic, and some extended Latin, but not Greek. This uses a very-large standard bitmap font, which lets it be scaled down nicely but not scaled up very well.
      Preview: Image link (uses width=45, height=60)
      Needs files:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/YanoneKaffeesatz-standard.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/YanoneKaffeesatz-standard.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/YanoneKaffeesatz-License.txt
      Returns:
      the Font object that can represent many sizes of the font YanoneKaffeesatz.ttf
    • getCanada

      public static Font getCanada()
      Returns a Font already configured to use a very-legible variable-width font with strong support for Canadian Aboriginal Syllabic, that should scale pretty well from a height of about 86 down to a height of maybe 30. Caches the result for later calls. The font used is Canada1500, a free (public domain, via CC0) typeface by Ray Larabie. It supports quite a lot of Latin-based scripts, Greek, Cyrillic, Canadian Aboriginal Syllabic, arrows, many dingbats, and more. This font can look good at its natural size, which uses width roughly equal to height, or narrowed down so width is smaller. This uses a very-large standard bitmap font, which lets it be scaled down nicely but not scaled up very well.
      Preview: Image link (uses width=40, height=58)
      Needs files:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Canada1500-standard.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Canada1500-standard.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/Canada1500-License.txt
      Returns:
      the Font object that can represent many sizes of the font Canada1500.ttf
    • getRobotoCondensed

      public static Font getRobotoCondensed()
      Returns a Font already configured to use a very-legible condensed variable-width font with excellent Unicode support, that should scale pretty well from a height of about 62 down to a height of maybe 20. Caches the result for later calls. The font used is Roboto Condensed, a free (Apache 2.0) typeface by Christian Robertson. It supports Latin-based scripts almost entirely, plus Greek, (extended) Cyrillic, and more. This font is meant to be condensed in its natural appearance, but can be scaled to be wider if desired. This uses a very-large standard bitmap font, which lets it be scaled down nicely but not scaled up very well.
      Preview: Image link (uses width=40, height=58)
      Needs files:
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/RobotoCondensed-standard.fnt
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/RobotoCondensed-standard.png
      • https://github.com/tommyettinger/textratypist/blob/main/knownFonts/RobotoCondensed-License.txt
      Returns:
      the Font object that can represent many sizes of the font RobotoCondensed.ttf
    • pause

      public void pause()
      Specified by:
      pause in interface com.badlogic.gdx.LifecycleListener
    • resume

      public void resume()
      Specified by:
      resume in interface com.badlogic.gdx.LifecycleListener
    • dispose

      public void dispose()
      Specified by:
      dispose in interface com.badlogic.gdx.LifecycleListener