ladybird/SharedGraphics/Font.h

50 lines
1.2 KiB
C
Raw Normal View History

2018-10-12 00:45:57 +03:00
#pragma once
2019-01-10 07:41:49 +03:00
#include "CharacterBitmap.h"
2018-10-12 00:45:57 +03:00
#include <AK/Retainable.h>
#include <AK/RetainPtr.h>
#include <AK/AKString.h>
2018-10-12 00:45:57 +03:00
#include <AK/Types.h>
class Font : public Retainable<Font> {
public:
static Font& default_font();
static Font& default_bold_font();
2018-10-12 00:45:57 +03:00
RetainPtr<Font> clone() const;
static RetainPtr<Font> load_from_memory(const byte*);
#ifdef USERLAND
static RetainPtr<Font> load_from_file(const String& path);
bool write_to_file(const String& path);
#endif
2018-10-12 00:45:57 +03:00
~Font();
const CharacterBitmap& glyph_bitmap(char ch) const { return *m_bitmaps[(byte)ch]; }
2018-10-12 00:45:57 +03:00
byte glyph_width() const { return m_glyph_width; }
byte glyph_height() const { return m_glyph_height; }
2018-10-12 00:45:57 +03:00
String name() const { return m_name; }
void set_name(const String& name) { m_name = name; }
static void initialize();
2018-10-12 00:45:57 +03:00
private:
Font(const String& name, const char* const* glyphs, byte glyph_width, byte glyph_height, byte first_glyph, byte last_glyph);
String m_name;
2018-10-12 00:45:57 +03:00
const char* const* m_glyphs { nullptr };
2019-01-10 07:41:49 +03:00
mutable RetainPtr<CharacterBitmap> m_bitmaps[256];
RetainPtr<CharacterBitmap> m_error_bitmap;
2018-10-12 00:45:57 +03:00
byte m_glyph_width { 0 };
byte m_glyph_height { 0 };
2018-10-12 00:45:57 +03:00
byte m_first_glyph { 0 };
byte m_last_glyph { 0 };
2018-10-12 00:45:57 +03:00
};