2020-11-28 21:16:20 +08:00
|
|
|
#ifndef ZM_FONT_H
|
|
|
|
#define ZM_FONT_H
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
struct ZMFONT_BH{
|
2020-11-29 12:55:06 +08:00
|
|
|
uint16_t charHeight; // Height of every character
|
|
|
|
uint16_t charWidth; // Width of every character
|
|
|
|
uint32_t numberofCodePoints; // number of codepoints max 255 for now
|
|
|
|
uint32_t idx; // idx in data where data for the bitmap starts
|
|
|
|
uint32_t pad; // padding to round of the size
|
2020-11-28 21:16:20 +08:00
|
|
|
};
|
2016-04-04 22:11:48 +08:00
|
|
|
|
2020-11-28 21:16:20 +08:00
|
|
|
struct ZMFONT {
|
2020-11-29 12:55:06 +08:00
|
|
|
char MAGIC[6]; // ZMFNT\0
|
2020-11-28 21:16:20 +08:00
|
|
|
char pad[2];
|
|
|
|
ZMFONT_BH header[4];
|
|
|
|
uint64_t *data;
|
|
|
|
};
|
2016-04-04 22:11:48 +08:00
|
|
|
|
2020-11-28 21:16:20 +08:00
|
|
|
class ZmFont {
|
2020-11-29 12:55:06 +08:00
|
|
|
public:
|
2020-11-30 20:27:59 +08:00
|
|
|
~ZmFont();
|
2020-11-29 12:55:06 +08:00
|
|
|
int ReadFontFile(const std::string &loc);
|
|
|
|
ZMFONT *GetFont() { return font; }
|
|
|
|
void SetFontSize(int _size) { size = _size; }
|
|
|
|
uint64_t *GetBitmapData();
|
|
|
|
uint16_t GetCharWidth() { return font->header[size].charWidth; }
|
|
|
|
uint16_t GetCharHeight() { return font->header[size].charHeight; }
|
2003-03-26 20:03:37 +08:00
|
|
|
|
2020-11-29 12:55:06 +08:00
|
|
|
private:
|
|
|
|
int size = 0;
|
|
|
|
size_t datasize = 0;
|
|
|
|
ZMFONT *font = nullptr;
|
2003-03-26 20:03:37 +08:00
|
|
|
};
|
2020-11-28 21:16:20 +08:00
|
|
|
|
2020-11-29 12:55:06 +08:00
|
|
|
#endif
|