diff --git a/Userland/Applications/FontEditor/FontEditor.cpp b/Userland/Applications/FontEditor/FontEditor.cpp index 4ba367987ae..5f6864571d9 100644 --- a/Userland/Applications/FontEditor/FontEditor.cpp +++ b/Userland/Applications/FontEditor/FontEditor.cpp @@ -241,13 +241,15 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr&& m_glyph_map_widget->update_glyph(m_glyph_map_widget->selected_glyph()); }); m_paste_action->set_enabled(GUI::Clipboard::the().mime_type() == "glyph/x-fonteditor"); - m_delete_action = GUI::CommonActions::make_delete_action([&](auto&) { - m_edited_font->set_glyph_width(m_glyph_map_widget->selected_glyph(), m_edited_font->max_glyph_width()); + m_delete_action = GUI::CommonActions::make_delete_action([this, update_statusbar](auto&) { + if (m_glyph_editor_widget->is_glyph_empty() && m_edited_font->raw_glyph_width(m_glyph_map_widget->selected_glyph()) == 0) + return; m_glyph_editor_widget->delete_glyph(); - m_glyph_map_widget->update_glyph(m_glyph_map_widget->selected_glyph()); - auto glyph_width = m_edited_font->raw_glyph_width(m_glyph_map_widget->selected_glyph()); - m_glyph_editor_width_spinbox->set_value(glyph_width); - m_glyph_editor_present_checkbox->set_checked(glyph_width > 0); + if (m_edited_font->is_fixed_width()) + m_glyph_editor_present_checkbox->set_checked(false, GUI::AllowCallback::No); + else + m_glyph_editor_width_spinbox->set_value(0, GUI::AllowCallback::No); + update_statusbar(); }); m_undo_action = GUI::CommonActions::make_undo_action([&](auto&) { undo(); diff --git a/Userland/Applications/FontEditor/GlyphEditorWidget.cpp b/Userland/Applications/FontEditor/GlyphEditorWidget.cpp index b5bd55a42b8..9274cf6f8b0 100644 --- a/Userland/Applications/FontEditor/GlyphEditorWidget.cpp +++ b/Userland/Applications/FontEditor/GlyphEditorWidget.cpp @@ -39,9 +39,10 @@ void GlyphEditorWidget::delete_glyph() if (on_undo_event) on_undo_event(); auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap(); - for (int x = 0; x < bitmap.width(); x++) - for (int y = 0; y < bitmap.height(); y++) + for (int x = 0; x < font().max_glyph_width(); x++) + for (int y = 0; y < font().glyph_height(); y++) bitmap.set_bit_at(x, y, false); + font().set_glyph_width(m_glyph, 0); if (on_glyph_altered) on_glyph_altered(m_glyph); update(); @@ -155,8 +156,8 @@ void GlyphEditorWidget::paint_event(GUI::PaintEvent& event) bool GlyphEditorWidget::is_glyph_empty() { auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap(); - for (int x = 0; x < bitmap.width(); x++) - for (int y = 0; y < bitmap.height(); y++) + for (int x = 0; x < font().max_glyph_width(); x++) + for (int y = 0; y < font().glyph_height(); y++) if (bitmap.bit_at(x, y)) return false; return true;