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

51 lines
No EOL
965 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <string>
#include <fstream>
#include <cstdint>
#include <map>
#include <memory>
static_assert(true); //Обход clangd бага
#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;
explicit Font(uint32_t glyphs, uint32_t glyphWidth, uint32_t glyphHeight);
};
Font readPSF(const std::string &filename);