mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:07:44 +00:00
LibGfx: Remove Gfx::FontDatabase::default_bold_fixed_width_font()
Ask for a bold_variant() of the default_fixed_width_font() instead.
This commit is contained in:
parent
6a012ad79f
commit
8a6c37deef
7 changed files with 4 additions and 22 deletions
|
@ -46,11 +46,6 @@ TEST_CASE(test_default_fixed_width_font)
|
||||||
EXPECT(!Gfx::FontDatabase::default_fixed_width_font().name().is_null());
|
EXPECT(!Gfx::FontDatabase::default_fixed_width_font().name().is_null());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(test_default_bold_fixed_width_font)
|
|
||||||
{
|
|
||||||
EXPECT(!Gfx::FontDatabase::default_bold_fixed_width_font().name().is_null());
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE(test_clone)
|
TEST_CASE(test_clone)
|
||||||
{
|
{
|
||||||
u8 glyph_height = 1;
|
u8 glyph_height = 1;
|
||||||
|
|
|
@ -149,7 +149,7 @@ void Canvas::draw()
|
||||||
painter.draw_text({ 520, 415, 240, 20 }, "Normal text", Gfx::FontDatabase::default_font(), Gfx::TextAlignment::CenterLeft, Color::Red);
|
painter.draw_text({ 520, 415, 240, 20 }, "Normal text", Gfx::FontDatabase::default_font(), Gfx::TextAlignment::CenterLeft, Color::Red);
|
||||||
painter.draw_text({ 520, 430, 240, 20 }, "Bold text", Gfx::FontDatabase::default_font().bold_variant(), Gfx::TextAlignment::CenterLeft, Color::Green);
|
painter.draw_text({ 520, 430, 240, 20 }, "Bold text", Gfx::FontDatabase::default_font().bold_variant(), Gfx::TextAlignment::CenterLeft, Color::Green);
|
||||||
painter.draw_text({ 520, 450, 240, 20 }, "Normal text (fixed width)", Gfx::FontDatabase::default_fixed_width_font(), Gfx::TextAlignment::CenterLeft, Color::Blue);
|
painter.draw_text({ 520, 450, 240, 20 }, "Normal text (fixed width)", Gfx::FontDatabase::default_fixed_width_font(), Gfx::TextAlignment::CenterLeft, Color::Blue);
|
||||||
painter.draw_text({ 520, 465, 240, 20 }, "Bold text (fixed width)", Gfx::FontDatabase::default_bold_fixed_width_font(), Gfx::TextAlignment::CenterLeft, Color::Yellow);
|
painter.draw_text({ 520, 465, 240, 20 }, "Bold text (fixed width)", Gfx::FontDatabase::default_fixed_width_font().bold_variant(), Gfx::TextAlignment::CenterLeft, Color::Yellow);
|
||||||
|
|
||||||
auto font = Gfx::BitmapFont::load_from_file("/res/fonts/PebbletonBold14.font");
|
auto font = Gfx::BitmapFont::load_from_file("/res/fonts/PebbletonBold14.font");
|
||||||
painter.draw_rect({ 520, 510, 240, 30 }, Color::DarkGray);
|
painter.draw_rect({ 520, 510, 240, 30 }, Color::DarkGray);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
SnakeGame::SnakeGame()
|
SnakeGame::SnakeGame()
|
||||||
{
|
{
|
||||||
set_font(Gfx::FontDatabase::default_bold_fixed_width_font());
|
set_font(Gfx::FontDatabase::default_fixed_width_font().bold_variant());
|
||||||
m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/paprika.png"));
|
m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/paprika.png"));
|
||||||
m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/eggplant.png"));
|
m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/eggplant.png"));
|
||||||
m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/cauliflower.png"));
|
m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/cauliflower.png"));
|
||||||
|
|
|
@ -44,16 +44,6 @@ Font& FontDatabase::default_fixed_width_font()
|
||||||
return *font;
|
return *font;
|
||||||
}
|
}
|
||||||
|
|
||||||
Font& FontDatabase::default_bold_fixed_width_font()
|
|
||||||
{
|
|
||||||
static Font* font;
|
|
||||||
if (!font) {
|
|
||||||
font = FontDatabase::the().get_by_name("Csilla 10 700");
|
|
||||||
VERIFY(font);
|
|
||||||
}
|
|
||||||
return *font;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct FontDatabase::Private {
|
struct FontDatabase::Private {
|
||||||
HashMap<String, RefPtr<Gfx::Font>> full_name_to_font_map;
|
HashMap<String, RefPtr<Gfx::Font>> full_name_to_font_map;
|
||||||
Vector<RefPtr<Typeface>> typefaces;
|
Vector<RefPtr<Typeface>> typefaces;
|
||||||
|
|
|
@ -35,9 +35,7 @@ public:
|
||||||
static FontDatabase& the();
|
static FontDatabase& the();
|
||||||
|
|
||||||
static Font& default_font();
|
static Font& default_font();
|
||||||
|
|
||||||
static Font& default_fixed_width_font();
|
static Font& default_fixed_width_font();
|
||||||
static Font& default_bold_fixed_width_font();
|
|
||||||
|
|
||||||
RefPtr<Gfx::Font> get(const String& family, unsigned size, unsigned weight);
|
RefPtr<Gfx::Font> get(const String& family, unsigned size, unsigned weight);
|
||||||
RefPtr<Gfx::Font> get(const String& family, const String& variant, unsigned size);
|
RefPtr<Gfx::Font> get(const String& family, const String& variant, unsigned size);
|
||||||
|
|
|
@ -1063,8 +1063,7 @@ void TerminalWidget::did_change_font()
|
||||||
GUI::Frame::did_change_font();
|
GUI::Frame::did_change_font();
|
||||||
m_line_height = font().glyph_height() + m_line_spacing;
|
m_line_height = font().glyph_height() + m_line_spacing;
|
||||||
|
|
||||||
// TODO: try to find a bold version of the new font (e.g. CsillaThin7x10 -> CsillaBold7x10)
|
const Gfx::Font& bold_font = font().bold_variant();
|
||||||
const Gfx::Font& bold_font = Gfx::FontDatabase::default_bold_fixed_width_font();
|
|
||||||
|
|
||||||
if (bold_font.glyph_height() == font().glyph_height() && bold_font.glyph_width(' ') == font().glyph_width(' '))
|
if (bold_font.glyph_height() == font().glyph_height() && bold_font.glyph_width(' ') == font().glyph_width(' '))
|
||||||
m_bold_font = &bold_font;
|
m_bold_font = &bold_font;
|
||||||
|
|
|
@ -194,7 +194,7 @@ void StyleProperties::load_font() const
|
||||||
RefPtr<Gfx::Font> StyleProperties::font_fallback(bool monospace, bool bold) const
|
RefPtr<Gfx::Font> StyleProperties::font_fallback(bool monospace, bool bold) const
|
||||||
{
|
{
|
||||||
if (monospace && bold)
|
if (monospace && bold)
|
||||||
return Gfx::FontDatabase::default_bold_fixed_width_font();
|
return Gfx::FontDatabase::default_fixed_width_font().bold_variant();
|
||||||
|
|
||||||
if (monospace)
|
if (monospace)
|
||||||
return Gfx::FontDatabase::default_fixed_width_font();
|
return Gfx::FontDatabase::default_fixed_width_font();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue