cpp-bmp-reader/font-lib/psf.h

52 lines
No EOL
928 B
C++

#pragma once
#include <string>
#include <fstream>
#include <cstdint>
#include <map>
#include <memory>
#pragma pack(push, 1)
struct PSF1Header {
char magicNumber[2];
uint8_t mode;
uint8_t glyphSize;
};
#pragma pack(pop)
#pragma pack(push, 1)
struct PSF2Header {
uint8_t magicNumber[4];
uint32_t version;
uint32_t headerSize;
uint32_t flags;
uint32_t numberOfGlyphs;
uint32_t bytesPerGlyph;
uint32_t glyphHeight;
uint32_t glyphWidth;
};
#pragma pack(pop)
class Glyph {
public:
uint8_t **glyph;
uint32_t width;
uint32_t height;
Glyph(uint32_t width, uint32_t height);
};
class Font {
public:
std::map<char16_t, std::shared_ptr<Glyph>> _glyphs;
uint32_t glyphWidth;
uint32_t glyphHeight;
uint32_t glyphsCount;
Font();
explicit Font(uint32_t glyphs, uint32_t glyphWidth, uint32_t glyphHeight);
};
Font readPSF(const std::string &filename);