mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
LizaBold8x10: Import a bold variant of Liza8x10 and make it the default bold.
Start using it right away for window titles.
This commit is contained in:
parent
ac11c90dee
commit
cacba45f1c
Notes:
sideshowbarker
2024-07-19 15:52:27 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/cacba45f1c6
5 changed files with 37 additions and 2 deletions
BIN
Base/res/fonts/LizaBold8x10.font
Normal file
BIN
Base/res/fonts/LizaBold8x10.font
Normal file
Binary file not shown.
|
@ -32,10 +32,12 @@ static constexpr const char* error_glyph {
|
|||
};
|
||||
|
||||
static Font* s_default_font;
|
||||
static Font* s_default_bold_font;
|
||||
|
||||
void Font::initialize()
|
||||
{
|
||||
s_default_font = nullptr;
|
||||
s_default_bold_font = nullptr;
|
||||
}
|
||||
|
||||
Font& Font::default_font()
|
||||
|
@ -44,7 +46,6 @@ Font& Font::default_font()
|
|||
if (!s_default_font) {
|
||||
#ifdef USERLAND
|
||||
s_default_font = Font::load_from_file(default_font_path).leak_ref();
|
||||
ASSERT(s_default_font);
|
||||
#else
|
||||
int error;
|
||||
auto descriptor = VFS::the().open(default_font_path, error, 0, 0, *VFS::the().root_inode());
|
||||
|
@ -56,10 +57,33 @@ Font& Font::default_font()
|
|||
ASSERT(buffer);
|
||||
s_default_font = Font::load_from_memory(buffer.pointer()).leak_ref();
|
||||
#endif
|
||||
ASSERT(s_default_font);
|
||||
}
|
||||
return *s_default_font;
|
||||
}
|
||||
|
||||
Font& Font::default_bold_font()
|
||||
{
|
||||
static const char* default_bold_font_path = "/res/fonts/LizaBold8x10.font";
|
||||
if (!s_default_bold_font) {
|
||||
#ifdef USERLAND
|
||||
s_default_bold_font = Font::load_from_file(default_bold_font_path).leak_ref();
|
||||
#else
|
||||
int error;
|
||||
auto descriptor = VFS::the().open(default_bold_font_path, error, 0, 0, *VFS::the().root_inode());
|
||||
if (!descriptor) {
|
||||
kprintf("Failed to open default font (%s)\n", default_bold_font_path);
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
auto buffer = descriptor->read_entire_file(*current);
|
||||
ASSERT(buffer);
|
||||
s_default_bold_font = Font::load_from_memory(buffer.pointer()).leak_ref();
|
||||
#endif
|
||||
ASSERT(s_default_bold_font);
|
||||
}
|
||||
return *s_default_bold_font;
|
||||
}
|
||||
|
||||
RetainPtr<Font> Font::clone() const
|
||||
{
|
||||
size_t bytes_per_glyph = glyph_width() * glyph_height();
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
class Font : public Retainable<Font> {
|
||||
public:
|
||||
static Font& default_font();
|
||||
static Font& default_bold_font();
|
||||
|
||||
RetainPtr<Font> clone() const;
|
||||
|
||||
|
|
|
@ -123,6 +123,11 @@ WSWindowManager::WSWindowManager()
|
|||
m_front_painter = make<Painter>(*m_front_bitmap);
|
||||
m_back_painter = make<Painter>(*m_back_bitmap);
|
||||
|
||||
m_font = Font::default_bold_font();
|
||||
|
||||
m_front_painter->set_font(font());
|
||||
m_back_painter->set_font(font());
|
||||
|
||||
m_background_color = Color(50, 50, 50);
|
||||
m_active_window_border_color = Color(110, 34, 9);
|
||||
m_active_window_border_color2 = Color(244, 202, 158);
|
||||
|
@ -159,7 +164,7 @@ void WSWindowManager::paint_window_frame(WSWindow& window)
|
|||
|
||||
|
||||
auto titlebar_title_rect = titlebar_inner_rect;
|
||||
titlebar_title_rect.set_width(Font::default_font().glyph_width() * window.title().length());
|
||||
titlebar_title_rect.set_width(font().glyph_width() * window.title().length());
|
||||
|
||||
Rect inner_border_rect {
|
||||
window.x() - 1,
|
||||
|
|
|
@ -39,6 +39,9 @@ public:
|
|||
void invalidate();
|
||||
void flush(const Rect&);
|
||||
|
||||
Font& font() { return *m_font; }
|
||||
const Font& font() const { return *m_font; }
|
||||
|
||||
private:
|
||||
WSWindowManager();
|
||||
virtual ~WSWindowManager() override;
|
||||
|
@ -98,6 +101,8 @@ private:
|
|||
OwnPtr<Painter> m_back_painter;
|
||||
OwnPtr<Painter> m_front_painter;
|
||||
|
||||
RetainPtr<Font> m_font;
|
||||
|
||||
mutable Lock m_lock;
|
||||
|
||||
bool m_flash_flush { false };
|
||||
|
|
Loading…
Add table
Reference in a new issue