import-font.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include <cstdlib>
  3. #include "../core/Shape.h"
  4. namespace msdfgen {
  5. typedef unsigned unicode_t;
  6. class FreetypeHandle;
  7. class FontHandle;
  8. /// Global metrics of a typeface (in font units).
  9. struct FontMetrics {
  10. /// The size of one EM.
  11. double emSize;
  12. /// The vertical position of the ascender and descender relative to the baseline.
  13. double ascenderY, descenderY;
  14. /// The vertical difference between consecutive baselines.
  15. double lineHeight;
  16. /// The vertical position and thickness of the underline.
  17. double underlineY, underlineThickness;
  18. };
  19. /// Initializes the FreeType library.
  20. FreetypeHandle * initializeFreetype();
  21. /// Deinitializes the FreeType library.
  22. void deinitializeFreetype(FreetypeHandle *library);
  23. /// Loads a font file and returns its handle.
  24. FontHandle * loadFont(FreetypeHandle *library, const char *filename);
  25. /// Unloads a font file.
  26. void destroyFont(FontHandle *font);
  27. /// Outputs the metrics of a font file.
  28. bool getFontMetrics(FontMetrics &metrics, FontHandle *font);
  29. /// Outputs the width of the space and tab characters.
  30. bool getFontWhitespaceWidth(double &spaceAdvance, double &tabAdvance, FontHandle *font);
  31. /// Loads the geometry of a glyph from a font file.
  32. bool loadGlyph(Shape &output, FontHandle *font, unicode_t unicode, double *advance = NULL);
  33. /// Outputs the kerning distance adjustment between two specific glyphs.
  34. bool getKerning(double &output, FontHandle *font, unicode_t unicode1, unicode_t unicode2);
  35. }