Skip to content

Commit

Permalink
FontEditor: Update GlyphMap on font type change
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
IdanHo authored and linusg committed Apr 18, 2021
1 parent f461ee7 commit 60f82e0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions Userland/Applications/FontEditor/FontEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&&

m_type_combobox->on_change = [this](auto&, const auto& index) {
m_edited_font->set_type(static_cast<Gfx::FontTypes>(index.row()));
m_glyph_map_widget->reprobe_font();
};

m_presentation_spinbox->on_change = [this, update_demo](int value) {
Expand Down
8 changes: 8 additions & 0 deletions Userland/Applications/FontEditor/GlyphMapWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Userland/Applications/FontEditor/GlyphMapWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class GlyphMapWidget final : public GUI::ScrollableWidget {
const Gfx::BitmapFont& font() const { return *m_font; }

void update_glyph(int);
void reprobe_font();

Function<void(int)> on_glyph_selected;

Expand Down

0 comments on commit 60f82e0

Please sign in to comment.