MsdfFontFace
final class MsdfFontFace
Implements: IFontFace
Package: dev.joid.lib.font.impl.msdf · Module: core · Source: MsdfFontFace.java
One face of an MsdfFont, with its atlas texture, its metrics, its glyphs and its kerning.
Description
Section titled “Description”An IMsdfSource reads it; MsdfFontLoader does that for you.
Metrics, advances and kerning are on 1 of the font size.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
MsdfFontFace | of(MsdfAtlas atlas, MsdfMetrics metrics, Map<Integer,MsdfGlyph> glyphs, Map<Long,Float> kerningPairs, BufferedImage image, String name, FontWeight weight, boolean italic) factory | Creates a face from its atlas, its metrics, its glyphs by codepoint, its kerning pairs keyed by pair(previous, current), the atlas image, its name, its weight and its style. |
Methods
Section titled “Methods”Queries
Section titled “Queries”| Returns | Signature | Summary |
|---|---|---|
float | getAscender() | Returns the ascender of the face, on 1 of the font size. |
float | getDescender() | Returns the descender of the face, on 1 of the font size, negative below the baseline. |
float | getLineHeight() | Returns the line height of the face, on 1 of the font size. |
float | getUnderlineY() | Returns the position of an underline relative to the baseline, on 1 of the font size. |
float | getUnderlineThickness() | Returns the thickness of an underline, on 1 of the font size. |
float | getAdvance(int codepoint) | Returns the advance of codepoint, on 1 of the font size, 0F for a codepoint the face does not have. |
float | getKerning(int previous, int current) | Returns the kerning between previous and current, on 1 of the font size, 0F for none. |
boolean | hasGlyph(int codepoint) | If true, the face has a glyph for codepoint, a space included. |
MsdfGlyph | getGlyph(int codepoint) | Returns the MsdfGlyph of codepoint, or null when the face does not have it. |
Map<Integer,MsdfGlyph> | getGlyphs() | Returns the glyphs by codepoint, as a map you cannot change. |
Map<Long,Float> | getKerningPairs() | Returns the kerning by pair of codepoints, keyed by pair(previous, current), as a map you cannot change. |
String | getName() | Returns the name of the font of this face. |
float | getXHeight() | Returns the height of a lowercase x, on 1 of the font size, 0F when the face has none. |
boolean | isItalic() | If true, the face is italic. |
MsdfAtlas | getAtlas() | Returns the size and the distance range of the atlas. |
Resource | getTexture() | Returns the atlas as a Resource. |
FontWeight | getWeight() | Returns the weight of the face. |
MsdfMetrics | getMetrics() | Returns the vertical metrics of the face. |
Actions
Section titled “Actions”| Returns | Signature | Summary |
|---|---|---|
long | pair(int previous, int current) static | Returns the key of the kerning pair previous, current in getKerningPairs(). |
MsdfFontFace | style(FontWeight weight, boolean italic) | Returns the same face, sharing its atlas and glyphs, declared with another weight and style. |
Creation details
Section titled “Creation details”MsdfFontFace of(MsdfAtlas atlas, MsdfMetrics metrics, Map<Integer,MsdfGlyph> glyphs, Map<Long,Float> kerningPairs, BufferedImage image, String name, FontWeight weight, boolean italic) factory
Throws:
IllegalArgumentException: A font face needs a name, got an empty one: give the face the name of its font
Creates a face from its atlas, its metrics, its glyphs by codepoint, its kerning pairs keyed by pair(previous, current), the atlas image, its name, its weight and its style.
The image becomes a linear texture without mipmaps, uploaded the first time the face draws.
Throws IllegalArgumentException when name is empty.
Method details
Section titled “Method details”getAscender
Section titled “getAscender”float getAscender()
Returns the ascender of the face, on 1 of the font size.
getDescender
Section titled “getDescender”float getDescender()
Returns the descender of the face, on 1 of the font size, negative below the baseline.
getLineHeight
Section titled “getLineHeight”float getLineHeight()
Returns the line height of the face, on 1 of the font size.
getUnderlineY
Section titled “getUnderlineY”float getUnderlineY()
Returns the position of an underline relative to the baseline, on 1 of the font size.
getUnderlineThickness
Section titled “getUnderlineThickness”float getUnderlineThickness()
Returns the thickness of an underline, on 1 of the font size.
getAdvance
Section titled “getAdvance”float getAdvance(int codepoint)
Returns the advance of codepoint, on 1 of the font size, 0F for a codepoint the face does not have.
getKerning
Section titled “getKerning”float getKerning(int previous, int current)
Returns the kerning between previous and current, on 1 of the font size, 0F for none.
hasGlyph
Section titled “hasGlyph”boolean hasGlyph(int codepoint)
If true, the face has a glyph for codepoint, a space included.
getGlyph
Section titled “getGlyph”MsdfGlyph getGlyph(int codepoint)
Returns the MsdfGlyph of codepoint, or null when the face does not have it.
getGlyphs
Section titled “getGlyphs”Map<Integer,MsdfGlyph> getGlyphs()
Returns the glyphs by codepoint, as a map you cannot change.
getKerningPairs
Section titled “getKerningPairs”Map<Long,Float> getKerningPairs()
Returns the kerning by pair of codepoints, keyed by pair(previous, current), as a map you cannot change.
getName
Section titled “getName”String getName()
Returns the name of the font of this face.
getXHeight
Section titled “getXHeight”float getXHeight()
Returns the height of a lowercase x, on 1 of the font size, 0F when the face has none.
isItalic
Section titled “isItalic”boolean isItalic()
If true, the face is italic.
getAtlas
Section titled “getAtlas”MsdfAtlas getAtlas()
Returns the size and the distance range of the atlas.
getTexture
Section titled “getTexture”Resource getTexture()
Returns the atlas as a Resource.
getWeight
Section titled “getWeight”FontWeight getWeight()
Returns the weight of the face.
getMetrics
Section titled “getMetrics”MsdfMetrics getMetrics()
Returns the vertical metrics of the face.
long pair(int previous, int current) static
Returns the key of the kerning pair previous, current in getKerningPairs().
MsdfFontFace style(FontWeight weight, boolean italic)
Returns the same face, sharing its atlas and glyphs, declared with another weight and style.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
