OrbitEngine::Graphics::Font class

Represents a single typeface.

Public static functions

static auto HasEmojiPresentation(GlyphCodepoint codepoint) -> bool
Returns whether the provided codepoint has emoji presentation according to the Unicode spec.

Constructors, destructors, conversion operators

Font(const std::string& file)
Load a font file.
~Font()

Public functions

auto getAvailableGlyphs() const -> std::vector<GlyphCodepoint>
Returns a list of all the available code points in the font file.
auto getGlyph(GlyphCodepoint codepoint, FontSize size, GlyphRenderMode mode, BitmapRGBA& bitmap, GlyphMetrics& metrics) -> bool
Get glyph bitmap and metrics.
auto getHorizontalKerning(FontSize size, GlyphCodepoint left, GlyphCodepoint right) -> int
Kerning distance between left and right glyphs at a specific size in unfitted pixels.

Function documentation

bool OrbitEngine::Graphics::Font::getGlyph(GlyphCodepoint codepoint, FontSize size, GlyphRenderMode mode, BitmapRGBA& bitmap, GlyphMetrics& metrics)

Get glyph bitmap and metrics.

Parameters
codepoint in Unicode codepoint
size in target size
mode in render mode. See GlyphRenderMode
bitmap out rendered bitmap
metrics out glyph metrics
Returns Whether the operation was successful

Example: Render glyph **&** at size 100

Font* font = new Font("Font.ttf");

BitmapRGBA bitmap;
GlyphMetrics metrics;

if (font->getGlyph(38, 100, GlyphRenderMode::COLOR, bitmap, metrics)) { // U+0026 or 38 or &
    bitmap.savePNG("&.png");
}