TTFFontEncoder.h 911 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include <ft2build.h>
  2. #include FT_FREETYPE_H
  3. #include "Font.h"
  4. #define START_INDEX 32
  5. #define END_INDEX 127
  6. #define GLYPH_PADDING 4
  7. namespace gameplay
  8. {
  9. // Structure of TTF Glyph.
  10. class TTFGlyph
  11. {
  12. public:
  13. unsigned int index;
  14. unsigned int width;
  15. int bearingX;
  16. unsigned int advance;
  17. float uvCoords[4];
  18. };
  19. /**
  20. * Writes the font gpb file.
  21. *
  22. * @param inFilePath Input file path to the tiff file.
  23. * @param outFilePath Output file path to write the gpb to.
  24. * @param fontSizes List of sizes to generate for the font.
  25. * @param id ID string of the font in the ref table.
  26. * @param fontpreview True if the pgm font preview file should be written. (For debugging)
  27. *
  28. * @return 0 if successful, -1 if error.
  29. */
  30. int writeFont(const char* inFilePath, const char* outFilePath, std::vector<unsigned int>& fontSize, const char* id, bool fontpreview, Font::FontFormat fontFormat);
  31. }