1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:17:46 +00:00

Support font files.

This only works with the userspace build of SharedGraphics so far.
It's also very slow at loading fonts, but that's easy to fix.

Let's put fonts in /res/fonts/.
This commit is contained in:
Andreas Kling 2019-02-02 23:13:12 +01:00
parent 655753c557
commit 7f91aec25c
7 changed files with 170 additions and 10 deletions

View file

@ -3,6 +3,7 @@
#include "CharacterBitmap.h"
#include <AK/Retainable.h>
#include <AK/RetainPtr.h>
#include <AK/AKString.h>
#include <AK/Types.h>
class Font : public Retainable<Font> {
@ -11,6 +12,11 @@ public:
RetainPtr<Font> clone() const;
#ifdef USERLAND
static RetainPtr<Font> load_from_file(const String& path);
bool write_to_file(const String& path);
#endif
~Font();
const CharacterBitmap& glyph_bitmap(char ch) const { return *m_bitmaps[(byte)ch]; }
@ -21,7 +27,9 @@ public:
static void initialize();
private:
Font(const char* const* glyphs, byte glyph_width, byte glyph_height, byte first_glyph, byte last_glyph);
Font(const String& name, const char* const* glyphs, byte glyph_width, byte glyph_height, byte first_glyph, byte last_glyph);
String m_name;
const char* const* m_glyphs { nullptr };
mutable RetainPtr<CharacterBitmap> m_bitmaps[256];