From 60f82e06260417d6c808db8199913567276078c7 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sun, 18 Apr 2021 14:31:39 +0300 Subject: [PATCH] FontEditor: Update GlyphMap on font type change Since font type changes also change the amount of glyphs in a font, the glyph map has to be re-rendered to properly showcase the change. --- Userland/Applications/FontEditor/FontEditor.cpp | 1 + Userland/Applications/FontEditor/GlyphMapWidget.cpp | 8 ++++++++ Userland/Applications/FontEditor/GlyphMapWidget.h | 1 + 3 files changed, 10 insertions(+) diff --git a/Userland/Applications/FontEditor/FontEditor.cpp b/Userland/Applications/FontEditor/FontEditor.cpp index cb1f712dfb..5887d93199 100644 --- a/Userland/Applications/FontEditor/FontEditor.cpp +++ b/Userland/Applications/FontEditor/FontEditor.cpp @@ -288,6 +288,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr&& m_type_combobox->on_change = [this](auto&, const auto& index) { m_edited_font->set_type(static_cast(index.row())); + m_glyph_map_widget->reprobe_font(); }; m_presentation_spinbox->on_change = [this, update_demo](int value) { diff --git a/Userland/Applications/FontEditor/GlyphMapWidget.cpp b/Userland/Applications/FontEditor/GlyphMapWidget.cpp index b115472718..c03302f93e 100644 --- a/Userland/Applications/FontEditor/GlyphMapWidget.cpp +++ b/Userland/Applications/FontEditor/GlyphMapWidget.cpp @@ -90,6 +90,14 @@ void GlyphMapWidget::update_glyph(int glyph) update(get_outer_rect(glyph)); } +void GlyphMapWidget::reprobe_font() +{ + VERIFY(m_font); + m_glyph_count = m_font->glyph_count(); + m_selected_glyph = 0; + update(); +} + void GlyphMapWidget::paint_event(GUI::PaintEvent& event) { GUI::Frame::paint_event(event); diff --git a/Userland/Applications/FontEditor/GlyphMapWidget.h b/Userland/Applications/FontEditor/GlyphMapWidget.h index 3c6a683c32..1fb2ccc5d3 100644 --- a/Userland/Applications/FontEditor/GlyphMapWidget.h +++ b/Userland/Applications/FontEditor/GlyphMapWidget.h @@ -47,6 +47,7 @@ public: const Gfx::BitmapFont& font() const { return *m_font; } void update_glyph(int); + void reprobe_font(); Function on_glyph_selected;