#pragma once
#include <cstdlib>
#include "../core/Shape.h"
namespace msdfgen {
typedef unsigned char byte;
typedef unsigned unicode_t;
class FreetypeHandle;
class FontHandle;
class GlyphIndex {
public:
explicit GlyphIndex(unsigned index = 0);
unsigned getIndex() const;
private:
unsigned index;
};
struct FontMetrics {
double emSize;
double ascenderY, descenderY;
double lineHeight;
double underlineY, underlineThickness;
};
FreetypeHandle * initializeFreetype();
void deinitializeFreetype(FreetypeHandle *library);
#ifdef FT_FREETYPE_H
FontHandle * adoptFreetypeFont(FT_Face ftFace);
#endif
FontHandle * loadFont(FreetypeHandle *library, const char *filename);
FontHandle * loadFontData(FreetypeHandle *library, const byte *data, int length);
void destroyFont(FontHandle *font);
bool getFontMetrics(FontMetrics &metrics, FontHandle *font);
bool getFontWhitespaceWidth(double &spaceAdvance, double &tabAdvance, FontHandle *font);
bool getGlyphIndex(GlyphIndex &glyphIndex, FontHandle *font, unicode_t unicode);
bool loadGlyph(Shape &output, FontHandle *font, GlyphIndex glyphIndex, double *advance = NULL);
bool loadGlyph(Shape &output, FontHandle *font, unicode_t unicode, double *advance = NULL);
bool getKerning(double &output, FontHandle *font, GlyphIndex glyphIndex1, GlyphIndex glyphIndex2);
bool getKerning(double &output, FontHandle *font, unicode_t unicode1, unicode_t unicode2);
}