public final class KnownFonts
extends java.lang.Object
implements com.badlogic.gdx.LifecycleListener
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.
getCozette() or getGentiumSDF() 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.
assets folder like the rest of the files! Most of these fonts are either licensed under the OFL
or some Creative Commons license; the CC ones typically require attribution, but none of the fonts restrict usage to
noncommercial projects, and all are free as in beer as well.
getStandardFamily()
pre-populates a FontFamily so you can switch between different fonts with the [@Sans] syntax.
addEmoji(Font) adds all of Twitter's emoji from the Twemoji
project to a given font, which lets you enter emoji with the [+man scientist, dark skin tone] syntax or the
generally-easier [+👨🏿🔬] syntax. If you want to use names for emoji, you may want to consult "Twemoji.atlas"
for the exact names used; some names changed from the standard because of technical restrictions.| Modifier and Type | Method and Description |
|---|---|
static Font |
addEmoji(Font changing)
Takes a Font and adds the Twemoji icon set to it, making the glyphs available using
[+name] syntax. |
void |
dispose() |
static Font[] |
getAll()
Returns a new array of Font instances, calling each getXyz() method in this class that returns any Font.
|
static Font[] |
getAllMSDF()
Returns a new array of Font instances, calling each getXyz() method in this class that returns any MSDF Font.
|
static Font[] |
getAllSDF()
Returns a new array of Font instances, calling each getXyz() method in this class that returns any SDF Font.
|
static Font[] |
getAllStandard()
Returns a new array of Font instances, calling each getXyz() method in this class that returns any
non-distance-field Font.
|
static Font |
getAStarry()
Returns a very large fixed-width Font already configured to use a square font with 45-degree angled sections,
based on the typeface used on the Atari ST console.
|
static Font |
getAStarryMSDF()
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 |
getBitter()
Returns a Font already configured to use a light-weight variable-width slab serif font with good Latin and
Cyrillic script support, that should scale pretty well from a height of about 160 down to a height of maybe 30.
|
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.
|
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).
|
static Font |
getCozette()
Returns a Font configured to use a cozy fixed-width bitmap font,
Cozette by slavfox.
|
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.
|
static Font |
getGentium()
Returns a Font already configured to use a variable-width serif font with excellent Unicode support, that should
scale well from a height of about 132 down to a height of 34.
|
static Font |
getGentiumSDF()
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 |
getHanazono()
Returns a Font already configured to use a variable-width, narrow font with nearly-complete CJK character
coverage, plus Latin, Greek, and Cyrillic, that shouldm scale pretty well down, but not up.
|
static Font |
getIBM8x16()
Returns a Font configured to use a classic, nostalgic fixed-width bitmap font,
IBM 8x16 from the early, oft-beloved computer line.
|
static Font |
getInconsolata()
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 |
getInconsolataMSDF()
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 |
getIosevka()
Returns a Font already configured to use a highly-legible fixed-width font with good Unicode support
and a sans-serif geometric style.
|
static Font |
getIosevkaMSDF()
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 |
getIosevkaSDF()
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 fairly large sizes (using an SDF technique).
|
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.
|
static Font |
getIosevkaSlabMSDF()
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 |
getIosevkaSlabSDF()
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 fairly large sizes (using an SDF technique).
|
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.
|
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).
|
static Font |
getOpenSans()
Returns a Font configured to use a clean variable-width font, Open Sans.
|
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.
|
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.
|
static Font |
getStandardFamily()
Returns a Font (
getGentium()) with a FontFamily configured so that all non-distance-field Fonts can be
used with syntax like [@Sans]. |
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.
|
void |
pause() |
void |
resume() |
public static Font getAStarry()
public static Font getAStarryMSDF()
public static Font getBitter()
getGentium(), except that Bitter
is quite a bit lighter, with thinner strokes and stylistic flourishes on some glyphs.
This uses a very-large standard bitmap font, which lets it be scaled down nicely but not scaled up very well.
This may work well in a font family with other fonts that do not use a distance field effect. Unlike most other
fonts here, this does not use makeGridGlyphs, because it would make underline and strikethrough much thicker than
other strokes in the font. This does mean that strikethrough starts too far to the left, and extends too far to
the right, unfortunately, but its weight matches.
public static Font getCanada()
public static Font getCascadiaMono()
public static Font getCozette()
Font.integerPosition set to true, which helps keep it pixel-perfect if 1 world unit is 1 pixel, but can
cause major visual issues if 1 world unit corresponds to much more than 1 pixel.
This may work well in a font family with other fonts that do not use a distance field effect.
public static Font getDejaVuSansMono()
public static Font getGentium()
getGentiumSDF(). You may want
to stick using just fonts that avoid distance fields if you have a family of fonts.
public static Font getGentiumSDF()
KnownFonts.getGentium().scaleTo(55, 45).adjustLineHeight(0.8f)
usually works. Caches the result for later calls. The font used is Gentium, an open-source (SIL Open Font
License) typeface by SIL (see SIL's page on Gentium here). 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.
public static Font getHanazono()
public static Font getIBM8x16()
getCozette() for a different bitmap font.
public static Font getInconsolata()
getInconsolataMSDF().
This may work well in a font family with other fonts that do not use a distance field effect.
public static Font getInconsolataMSDF()
public static Font getIosevka()
Font.fitCell(float, float, boolean), and repeated calls to fitCell()
have an unknown effect; you may want to stick to scaling this and not re-fitting if you encounter issues.
This may work well in a font family with other fonts that do not use a distance field effect.
public static Font getIosevkaMSDF()
Font.fitCell(float, float, boolean), and repeated calls to fitCell()
have an unknown effect; you may want to stick to scaling this and not re-fitting if you encounter issues.
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.
However, using a distance field makes it effectively impossible to mix fonts using a FontFamily (any variation in
distance field settings would make some fonts in the family blurry and others too sharp).
public static Font getIosevkaSDF()
Font.fitCell(float, float, boolean), and repeated calls to fitCell()
have an unknown effect; you may want to stick to scaling this and not re-fitting if you encounter issues.
This uses the Signed Distance Field (SDF) technique as opposed to the Multi-channel Signed Distance Field
technique that getIosevkaMSDF() uses, which isn't as sharp at large sizes but can look a little better
at small sizes. However, using a distance field makes it effectively impossible to mix fonts using a FontFamily
(any variation in distance field settings would make some fonts in the family blurry and others too sharp).
public static Font getIosevkaSlab()
Font.fitCell(float, float, boolean), and repeated calls to fitCell()
have an unknown effect; you may want to stick to scaling this and not re-fitting if you encounter issues.
This may work well in a font family with other fonts that do not use a distance field effect.
public static Font getIosevkaSlabMSDF()
Font.fitCell(float, float, boolean), and repeated calls to fitCell()
have an unknown effect; you may want to stick to scaling this and not re-fitting if you encounter issues.
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.
public static Font getIosevkaSlabSDF()
Font.fitCell(float, float, boolean), and repeated calls to fitCell()
have an unknown effect; you may want to stick to scaling this and not re-fitting if you encounter issues.
This uses the Signed Distance Field (SDF) technique as opposed to the Multi-channel Signed Distance Field
technique that getIosevkaSlabMSDF() uses, which isn't as sharp at large sizes but can look a little
better at small sizes.
public static Font getKingthingsFoundation()
public static Font getLibertinusSerif()
public static Font getOpenSans()
public static Font getOxanium()
public static Font getRobotoCondensed()
public static Font getYanoneKaffeesatz()
public static Font addEmoji(Font changing)
[+name] syntax.
You can use the name of an emoji, such as [+clown face], or equivalently use the actual emoji, such as
[+🤡], with the latter preferred because the names can be unwieldy or hard to get right. This caches the
Twemoji atlas for later calls. This tries to load the files "Twemoji.atlas" and "Twemoji.png" from the internal
storage first, and if that fails, it tries to load them from local storage in the current working directory.
getYanoneKaffeesatz())
changing - a Font that will have over 3000 emoji added to it, with more aliaseschanging, after the emoji atlas has been addedpublic void pause()
pause in interface com.badlogic.gdx.LifecycleListenerpublic void resume()
resume in interface com.badlogic.gdx.LifecycleListenerpublic static Font[] getAll()
public static Font[] getAllStandard()
public static Font getStandardFamily()
getGentium()) with a FontFamily configured so that all non-distance-field Fonts can be
used with syntax like [@Sans]. The names this supports can be accessed with code using
getStandardFamily().family.fontAliases.keys(). These names so far are:
Serif, which is getGentium(),Sans, which is getOpenSans(),Mono, which is getInconsolata(),Condensed, which is getRobotoCondensed(),Humanist, which is getYanoneKaffeesatz(),Retro, which is getIBM8x16(),Slab, which is getIosevkaSlab(),Bitter, which is getBitter(),Canada, which is getCanada(),Cozette, which is getCozette(),Iosevka, which is getIosevka(),Medieval, which is getKingthingsFoundation(),Future, which is getOxanium(),Console, which is getAStarry(), andHanazono, which is getHanazono().Font.getName().
Serif, which is getGentium(), will always be the default font used after a reset.
public static Font[] getAllSDF()
public static Font[] getAllMSDF()
public void dispose()
dispose in interface com.badlogic.gdx.LifecycleListener