mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:47:34 +00:00
LibGfx: Add a count to FontTypes and a helper to return type names
This commit is contained in:
parent
25bd4b33a7
commit
c283429196
2 changed files with 23 additions and 5 deletions
|
@ -175,6 +175,21 @@ size_t BitmapFont::glyph_count_by_type(FontTypes type)
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
String BitmapFont::type_name_by_type(FontTypes type)
|
||||
{
|
||||
if (type == FontTypes::Default)
|
||||
return "Default";
|
||||
|
||||
if (type == FontTypes::LatinExtendedA)
|
||||
return "LatinExtendedA";
|
||||
|
||||
if (type == FontTypes::Cyrillic)
|
||||
return "Cyrillic";
|
||||
|
||||
dbgln("Unknown font type: {}", (int)type);
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
RefPtr<BitmapFont> BitmapFont::load_from_file(const StringView& path)
|
||||
{
|
||||
if (Core::File::is_device(path))
|
||||
|
|
|
@ -36,12 +36,13 @@
|
|||
|
||||
namespace Gfx {
|
||||
|
||||
// Note: Perhaps put glyph count directly in header
|
||||
// and sidestep FontType conflation/sync maintenance
|
||||
enum FontTypes {
|
||||
Default = 0,
|
||||
LatinExtendedA = 1,
|
||||
// There are many blocks between LatinExtendedA and Cyrrilic that has to be added later.
|
||||
// Cyrrilic has to be switched to another number
|
||||
Cyrillic = 2
|
||||
LatinExtendedA,
|
||||
Cyrillic,
|
||||
__Count
|
||||
};
|
||||
|
||||
class BitmapFont : public Font {
|
||||
|
@ -118,11 +119,13 @@ public:
|
|||
|
||||
const Font& bold_variant() const;
|
||||
|
||||
static size_t glyph_count_by_type(FontTypes type);
|
||||
static String type_name_by_type(FontTypes type);
|
||||
|
||||
private:
|
||||
BitmapFont(String name, String family, unsigned* rows, u8* widths, bool is_fixed_width, u8 glyph_width, u8 glyph_height, u8 glyph_spacing, FontTypes type, u8 baseline, u8 mean_line, u8 presentation_size, u16 weight, bool owns_arrays = false);
|
||||
|
||||
static RefPtr<BitmapFont> load_from_memory(const u8*);
|
||||
static size_t glyph_count_by_type(FontTypes type);
|
||||
|
||||
void update_x_height() { m_x_height = m_baseline - m_mean_line; };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue