mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:47:35 +00:00
LibGfx: Add "override" declarations and use east const in BitmapFont.h
This commit is contained in:
parent
006e5998c5
commit
5af4f8041f
1 changed files with 27 additions and 27 deletions
|
@ -26,9 +26,9 @@ enum FontTypes {
|
||||||
__Count
|
__Count
|
||||||
};
|
};
|
||||||
|
|
||||||
class BitmapFont : public Font {
|
class BitmapFont final : public Font {
|
||||||
public:
|
public:
|
||||||
NonnullRefPtr<Font> clone() const;
|
NonnullRefPtr<Font> clone() const override;
|
||||||
static NonnullRefPtr<BitmapFont> create(u8 glyph_height, u8 glyph_width, bool fixed, FontTypes type);
|
static NonnullRefPtr<BitmapFont> create(u8 glyph_height, u8 glyph_width, bool fixed, FontTypes type);
|
||||||
|
|
||||||
static RefPtr<BitmapFont> load_from_file(String const& path);
|
static RefPtr<BitmapFont> load_from_file(String const& path);
|
||||||
|
@ -36,56 +36,56 @@ public:
|
||||||
|
|
||||||
~BitmapFont();
|
~BitmapFont();
|
||||||
|
|
||||||
u8 presentation_size() const { return m_presentation_size; }
|
u8 presentation_size() const override { return m_presentation_size; }
|
||||||
void set_presentation_size(u8 size) { m_presentation_size = size; }
|
void set_presentation_size(u8 size) { m_presentation_size = size; }
|
||||||
|
|
||||||
u16 weight() const { return m_weight; }
|
u16 weight() const override { return m_weight; }
|
||||||
void set_weight(u16 weight) { m_weight = weight; }
|
void set_weight(u16 weight) { m_weight = weight; }
|
||||||
|
|
||||||
Glyph glyph(u32 code_point) const;
|
Glyph glyph(u32 code_point) const override;
|
||||||
bool contains_glyph(u32 code_point) const { return code_point < (u32)glyph_count() && m_glyph_widths[code_point] > 0; }
|
bool contains_glyph(u32 code_point) const override { return code_point < (u32)glyph_count() && m_glyph_widths[code_point] > 0; }
|
||||||
|
|
||||||
u8 glyph_width(size_t ch) const { return m_fixed_width ? m_glyph_width : m_glyph_widths[ch]; }
|
u8 glyph_width(size_t ch) const override { return m_fixed_width ? m_glyph_width : m_glyph_widths[ch]; }
|
||||||
ALWAYS_INLINE int glyph_or_emoji_width(u32 code_point) const
|
ALWAYS_INLINE int glyph_or_emoji_width(u32 code_point) const override
|
||||||
{
|
{
|
||||||
if (m_fixed_width)
|
if (m_fixed_width)
|
||||||
return m_glyph_width;
|
return m_glyph_width;
|
||||||
return glyph_or_emoji_width_for_variable_width_font(code_point);
|
return glyph_or_emoji_width_for_variable_width_font(code_point);
|
||||||
}
|
}
|
||||||
u8 glyph_height() const { return m_glyph_height; }
|
u8 glyph_height() const override { return m_glyph_height; }
|
||||||
int x_height() const { return m_x_height; }
|
int x_height() const override { return m_x_height; }
|
||||||
|
|
||||||
u8 raw_glyph_width(size_t ch) const { return m_glyph_widths[ch]; }
|
u8 raw_glyph_width(size_t ch) const { return m_glyph_widths[ch]; }
|
||||||
|
|
||||||
u8 min_glyph_width() const { return m_min_glyph_width; }
|
u8 min_glyph_width() const override { return m_min_glyph_width; }
|
||||||
u8 max_glyph_width() const { return m_max_glyph_width; }
|
u8 max_glyph_width() const override { return m_max_glyph_width; }
|
||||||
u8 glyph_fixed_width() const { return m_glyph_width; }
|
u8 glyph_fixed_width() const override { return m_glyph_width; }
|
||||||
|
|
||||||
u8 baseline() const { return m_baseline; }
|
u8 baseline() const override { return m_baseline; }
|
||||||
void set_baseline(u8 baseline)
|
void set_baseline(u8 baseline)
|
||||||
{
|
{
|
||||||
m_baseline = baseline;
|
m_baseline = baseline;
|
||||||
update_x_height();
|
update_x_height();
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 mean_line() const { return m_mean_line; }
|
u8 mean_line() const override { return m_mean_line; }
|
||||||
void set_mean_line(u8 mean_line)
|
void set_mean_line(u8 mean_line)
|
||||||
{
|
{
|
||||||
m_mean_line = mean_line;
|
m_mean_line = mean_line;
|
||||||
update_x_height();
|
update_x_height();
|
||||||
}
|
}
|
||||||
|
|
||||||
int width(const StringView&) const;
|
int width(StringView const&) const override;
|
||||||
int width(const Utf8View&) const;
|
int width(Utf8View const&) const override;
|
||||||
int width(const Utf32View&) const;
|
int width(Utf32View const&) const override;
|
||||||
|
|
||||||
String name() const { return m_name; }
|
String name() const override { return m_name; }
|
||||||
void set_name(String name) { m_name = move(name); }
|
void set_name(String name) { m_name = move(name); }
|
||||||
|
|
||||||
bool is_fixed_width() const { return m_fixed_width; }
|
bool is_fixed_width() const override { return m_fixed_width; }
|
||||||
void set_fixed_width(bool b) { m_fixed_width = b; }
|
void set_fixed_width(bool b) { m_fixed_width = b; }
|
||||||
|
|
||||||
u8 glyph_spacing() const { return m_glyph_spacing; }
|
u8 glyph_spacing() const override { return m_glyph_spacing; }
|
||||||
void set_glyph_spacing(u8 spacing) { m_glyph_spacing = spacing; }
|
void set_glyph_spacing(u8 spacing) { m_glyph_spacing = spacing; }
|
||||||
|
|
||||||
void set_glyph_width(size_t ch, u8 width)
|
void set_glyph_width(size_t ch, u8 width)
|
||||||
|
@ -94,18 +94,18 @@ public:
|
||||||
m_glyph_widths[ch] = width;
|
m_glyph_widths[ch] = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t glyph_count() const { return m_glyph_count; }
|
size_t glyph_count() const override { return m_glyph_count; }
|
||||||
|
|
||||||
FontTypes type() { return m_type; }
|
FontTypes type() { return m_type; }
|
||||||
void set_type(FontTypes type);
|
void set_type(FontTypes type);
|
||||||
|
|
||||||
String family() const { return m_family; }
|
String family() const override { return m_family; }
|
||||||
void set_family(String family) { m_family = move(family); }
|
void set_family(String family) { m_family = move(family); }
|
||||||
String variant() const { return String::formatted("{}", weight()); }
|
String variant() const override { return String::number(weight()); }
|
||||||
|
|
||||||
String qualified_name() const;
|
String qualified_name() const override;
|
||||||
|
|
||||||
const Font& bold_variant() const;
|
Font const& bold_variant() const override;
|
||||||
|
|
||||||
static size_t glyph_count_by_type(FontTypes type);
|
static size_t glyph_count_by_type(FontTypes type);
|
||||||
static String type_name_by_type(FontTypes type);
|
static String type_name_by_type(FontTypes type);
|
||||||
|
@ -113,7 +113,7 @@ public:
|
||||||
private:
|
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);
|
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 RefPtr<BitmapFont> load_from_memory(u8 const*);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
int unicode_view_width(T const& view) const;
|
int unicode_view_width(T const& view) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue