#pragma once #include #include "../core/Shape.h" namespace msdfgen { typedef unsigned unicode_t; class FreetypeHandle; class FontHandle; /// Global metrics of a typeface (in font units). struct FontMetrics { /// The size of one EM. double emSize; /// The vertical position of the ascender and descender relative to the baseline. double ascenderY, descenderY; /// The vertical difference between consecutive baselines. double lineHeight; /// The vertical position and thickness of the underline. double underlineY, underlineThickness; }; /// Initializes the FreeType library. FreetypeHandle * initializeFreetype(); /// Deinitializes the FreeType library. void deinitializeFreetype(FreetypeHandle *library); /// Loads a font file and returns its handle. FontHandle * loadFont(FreetypeHandle *library, const char *filename); /// Unloads a font file. void destroyFont(FontHandle *font); /// Outputs the metrics of a font file. bool getFontMetrics(FontMetrics &metrics, FontHandle *font); /// Outputs the width of the space and tab characters. bool getFontWhitespaceWidth(double &spaceAdvance, double &tabAdvance, FontHandle *font); /// Loads the geometry of a glyph from a font file. bool loadGlyph(Shape &output, FontHandle *font, unicode_t unicode, double *advance = NULL); /// Outputs the kerning distance adjustment between two specific glyphs. bool getKerning(double &output, FontHandle *font, unicode_t unicode1, unicode_t unicode2); }