From c1744822a17601afcd19702d46cf901ec407da05 Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Mon, 29 Nov 2021 09:59:25 -0500 Subject: [PATCH] FontEditor: Account for glyph width when pasting Fixes glyphs not expanding up to their maximum width if necessary when pasting larger glyphs into smaller ones. --- Userland/Applications/FontEditor/FontEditor.cpp | 6 +++++- Userland/Applications/FontEditor/GlyphEditorWidget.cpp | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Userland/Applications/FontEditor/FontEditor.cpp b/Userland/Applications/FontEditor/FontEditor.cpp index 9e1def20ad..72535babb9 100644 --- a/Userland/Applications/FontEditor/FontEditor.cpp +++ b/Userland/Applications/FontEditor/FontEditor.cpp @@ -193,7 +193,11 @@ FontEditorWidget::FontEditorWidget() }); m_paste_action = GUI::CommonActions::make_paste_action([&](auto&) { m_glyph_editor_widget->paste_glyph(); - m_glyph_map_widget->update_glyph(m_glyph_map_widget->selected_glyph()); + if (m_edited_font->is_fixed_width()) + m_glyph_editor_present_checkbox->set_checked(true, GUI::AllowCallback::No); + else + m_glyph_editor_width_spinbox->set_value(m_edited_font->raw_glyph_width(m_glyph_map_widget->selected_glyph()), GUI::AllowCallback::No); + update_statusbar(); }); m_paste_action->set_enabled(GUI::Clipboard::the().fetch_mime_type() == "glyph/x-fonteditor"); m_delete_action = GUI::CommonActions::make_delete_action([this](auto&) { diff --git a/Userland/Applications/FontEditor/GlyphEditorWidget.cpp b/Userland/Applications/FontEditor/GlyphEditorWidget.cpp index a59298bdef..8c8c935f69 100644 --- a/Userland/Applications/FontEditor/GlyphEditorWidget.cpp +++ b/Userland/Applications/FontEditor/GlyphEditorWidget.cpp @@ -115,8 +115,10 @@ void GlyphEditorWidget::paste_glyph() } auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap(); - for (int x = 0; x < min(bitmap.width(), buffer_width); x++) { - for (int y = 0; y < min(bitmap.height(), buffer_height); y++) { + if (bitmap.width() < buffer_width) + font().set_glyph_width(m_glyph, min(buffer_width, font().max_glyph_width())); + for (int x = 0; x < min(buffer_width, font().max_glyph_width()); x++) { + for (int y = 0; y < min(buffer_height, font().glyph_height()); y++) { bitmap.set_bit_at(x, y, bits[x][y]); } }