Add a bold variant of Katica and make that the system's default bold font.

..and do some minor tweaks to the font rendering code.
This commit is contained in:
Andreas Kling 2019-03-06 14:50:27 +01:00
parent 66a5ddd94a
commit 31d6b640eb
Notes: sideshowbarker 2024-07-19 15:09:58 +09:00
5 changed files with 10 additions and 5 deletions

Binary file not shown.

Binary file not shown.

View file

@ -76,7 +76,7 @@ void GTextBox::paint_event(GPaintEvent& event)
Painter painter(*this); Painter painter(*this);
painter.set_clip_rect(event.rect()); painter.set_clip_rect(event.rect());
painter.fill_rect({ rect().x() + 1, rect().y() + 1, rect().width() - 2, rect().height() - 2 }, background_color()); painter.fill_rect(rect().shrunken(2, 2), background_color());
painter.draw_rect(rect(), foreground_color()); painter.draw_rect(rect(), foreground_color());
if (is_focused()) if (is_focused())
@ -88,9 +88,9 @@ void GTextBox::paint_event(GPaintEvent& event)
painter.set_clip_rect(inner_rect); painter.set_clip_rect(inner_rect);
painter.translate(-m_scroll_offset, 0); painter.translate(-m_scroll_offset, 0);
int y = inner_rect.center().y() - font().glyph_height() / 2;
int space_width = font().glyph_width(' ') + font().glyph_spacing(); int space_width = font().glyph_width(' ') + font().glyph_spacing();
int x = inner_rect.x(); int x = inner_rect.x();
int y = inner_rect.center().y() - font().glyph_height() / 2;
for (int i = 0; i < m_text.length(); ++i) { for (int i = 0; i < m_text.length(); ++i) {
char ch = m_text[i]; char ch = m_text[i];
@ -103,7 +103,12 @@ void GTextBox::paint_event(GPaintEvent& event)
} }
if (is_focused() && m_cursor_blink_state) { if (is_focused() && m_cursor_blink_state) {
Rect cursor_rect(inner_rect.x() + cursor_content_position().x(), inner_rect.y(), 1, inner_rect.height()); Rect cursor_rect {
inner_rect.x() + cursor_content_position().x(),
inner_rect.y(),
1,
inner_rect.height()
};
painter.fill_rect(cursor_rect, foreground_color()); painter.fill_rect(cursor_rect, foreground_color());
} }
} }

View file

@ -44,7 +44,7 @@ Font& Font::default_fixed_width_font()
Font& Font::default_bold_font() Font& Font::default_bold_font()
{ {
static Font* s_default_bold_font; static Font* s_default_bold_font;
static const char* default_bold_font_path = "/res/fonts/CsillaBold7x10.font"; static const char* default_bold_font_path = "/res/fonts/KaticaBold10.font";
if (!s_default_bold_font) { if (!s_default_bold_font) {
s_default_bold_font = Font::load_from_file(default_bold_font_path).leak_ref(); s_default_bold_font = Font::load_from_file(default_bold_font_path).leak_ref();
ASSERT(s_default_bold_font); ASSERT(s_default_bold_font);

View file

@ -54,7 +54,7 @@ public:
~Font(); ~Font();
GlyphBitmap glyph_bitmap(char ch) const { return GlyphBitmap(&m_rows[(byte)ch * m_glyph_height], { m_glyph_width, m_glyph_height }); } GlyphBitmap glyph_bitmap(char ch) const { return GlyphBitmap(&m_rows[(byte)ch * m_glyph_height], { glyph_width(ch), m_glyph_height }); }
byte glyph_width(char ch) const { return m_fixed_width ? m_glyph_width : m_glyph_widths[(byte)ch]; } byte glyph_width(char ch) const { return m_fixed_width ? m_glyph_width : m_glyph_widths[(byte)ch]; }
byte glyph_height() const { return m_glyph_height; } byte glyph_height() const { return m_glyph_height; }