mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:27:35 +00:00
More work on the variable-width font support.
Katica is now the default system font, and it looks quite nice. :^) I'm gonna need to refine the GTextBox movement stuff eventually, but it works well-enough for basic editing now.
This commit is contained in:
parent
e53cef02d5
commit
66a5ddd94a
12 changed files with 125 additions and 30 deletions
|
@ -19,9 +19,9 @@
|
|||
|
||||
Terminal::Terminal(int ptm_fd)
|
||||
: m_ptm_fd(ptm_fd)
|
||||
, m_font(Font::default_font())
|
||||
, m_notifier(ptm_fd, GNotifier::Read)
|
||||
{
|
||||
set_font(Font::default_fixed_width_font());
|
||||
m_notifier.on_ready_to_read = [this] (GNotifier& notifier) {
|
||||
byte buffer[BUFSIZ];
|
||||
ssize_t nread = read(notifier.fd(), buffer, sizeof(buffer));
|
||||
|
@ -798,7 +798,7 @@ void Terminal::force_repaint()
|
|||
|
||||
void Terminal::resize_event(GResizeEvent& event)
|
||||
{
|
||||
int new_columns = event.size().width() / m_font->glyph_width('x');
|
||||
int new_columns = event.size().width() / font().glyph_width('x');
|
||||
int new_rows = event.size().height() / m_line_height;
|
||||
set_size(new_columns, new_rows);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ private:
|
|||
virtual void keydown_event(GKeyEvent&) override;
|
||||
virtual const char* class_name() const override { return "Terminal"; }
|
||||
|
||||
Font& font() { return *m_font; }
|
||||
void scroll_up();
|
||||
void newline();
|
||||
void set_cursor(unsigned row, unsigned column);
|
||||
|
@ -145,8 +144,6 @@ private:
|
|||
bool m_in_active_window { false };
|
||||
bool m_need_full_flush { false };
|
||||
|
||||
RetainPtr<Font> m_font;
|
||||
|
||||
GNotifier m_notifier;
|
||||
|
||||
float m_opacity { 0.8f };
|
||||
|
|
|
@ -108,7 +108,7 @@ int main(int argc, char** argv)
|
|||
menubar->add_menu(move(app_menu));
|
||||
|
||||
auto font_menu = make<GMenu>("Font");
|
||||
GFontDatabase::the().for_each_font([&] (const String& font_name) {
|
||||
GFontDatabase::the().for_each_fixed_width_font([&] (const String& font_name) {
|
||||
font_menu->add_action(GAction::create(font_name, [&terminal] (const GAction& action) {
|
||||
terminal.set_font(GFontDatabase::the().get_by_name(action.text()));
|
||||
terminal.force_repaint();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue