From f0f487babdd4545ed312fad266890f55cd2e6b2d Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Thu, 22 Apr 2021 14:40:24 -0400 Subject: [PATCH] FontEditor: Set proper defaults in NewFontDialog GlyphBitmap width is currently limited to twiddling 32 bits so abide by a 32x36 standard for now. Fixes incorrect line values and ranges and removes unused RefPtr. --- .../Applications/FontEditor/NewFontDialog.cpp | 24 ++++++++++++++----- .../Applications/FontEditor/NewFontDialog.h | 2 -- .../FontEditor/NewFontDialogPage2.gml | 4 ---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Userland/Applications/FontEditor/NewFontDialog.cpp b/Userland/Applications/FontEditor/NewFontDialog.cpp index aa9443beb8..71e826c22e 100644 --- a/Userland/Applications/FontEditor/NewFontDialog.cpp +++ b/Userland/Applications/FontEditor/NewFontDialog.cpp @@ -23,6 +23,9 @@ #include #include +static constexpr int s_max_width = 32; +static constexpr int s_max_height = 36; + namespace GUI { class GlyphPreviewWidget final : public Frame { @@ -33,10 +36,13 @@ public: m_width = width; m_height = height; m_glyph_width = width; - if (m_width > 25 || m_height > 20) - set_scale(6); - if (m_width <= 25 && m_height <= 20) - set_scale(10); + for (int i = 10; i > 0; i--) { + if ((frame_thickness() * 2 + (m_width * i) - 1) <= 250 + && (frame_thickness() * 2 + (m_height * i) - 1) <= 205) { + set_scale(i); + break; + } + } set_fixed_width(frame_thickness() * 2 + (m_width * m_scale) - 1); set_fixed_height(frame_thickness() * 2 + (m_height * m_scale) - 1); } @@ -114,7 +120,7 @@ private: int m_glyph_width { 20 }; int m_mean_line { 2 }; int m_baseline { 16 }; - u8 m_bits[34][34] {}; + u8 m_bits[s_max_width][s_max_height] {}; }; } @@ -176,8 +182,12 @@ NewFontDialog::NewFontDialog(GUI::Window* parent_window) m_glyph_height_spinbox->set_value(20); m_glyph_width_spinbox->set_value(20); - m_mean_line_spinbox->set_value(3); + m_glyph_height_spinbox->set_max(s_max_height); + m_glyph_width_spinbox->set_max(s_max_width); + m_mean_line_spinbox->set_value(2); m_baseline_spinbox->set_value(16); + m_mean_line_spinbox->set_max(max(m_glyph_height_spinbox->value() - 2, 0)); + m_baseline_spinbox->set_max(max(m_glyph_height_spinbox->value() - 2, 0)); m_spacing_spinbox->set_value(1); m_fixed_width_checkbox->set_checked(false); @@ -193,6 +203,8 @@ NewFontDialog::NewFontDialog(GUI::Window* parent_window) }; m_glyph_height_spinbox->on_change = [&](int value) { preview_editor.set_preview_size(m_glyph_width_spinbox->value(), value); + m_mean_line_spinbox->set_max(max(value - 2, 0)); + m_baseline_spinbox->set_max(max(value - 2, 0)); deferred_invoke([&] { m_glyph_editor_container->set_fixed_height(1 + preview_editor.height() + preview_editor.frame_thickness() * 2); }); diff --git a/Userland/Applications/FontEditor/NewFontDialog.h b/Userland/Applications/FontEditor/NewFontDialog.h index 339d3bf0ed..7cda592f88 100644 --- a/Userland/Applications/FontEditor/NewFontDialog.h +++ b/Userland/Applications/FontEditor/NewFontDialog.h @@ -26,8 +26,6 @@ private: void save_metadata(); - RefPtr m_font_clone; - struct NewFontMetadata { u8 glyph_width; u8 glyph_height; diff --git a/Userland/Applications/FontEditor/NewFontDialogPage2.gml b/Userland/Applications/FontEditor/NewFontDialogPage2.gml index 9576615287..e4dec5fcc3 100644 --- a/Userland/Applications/FontEditor/NewFontDialogPage2.gml +++ b/Userland/Applications/FontEditor/NewFontDialogPage2.gml @@ -27,7 +27,6 @@ @GUI::SpinBox { name: "height_spinbox" min: 0 - max: 34 } } @@ -44,7 +43,6 @@ @GUI::SpinBox { name: "width_spinbox" min: 0 - max: 34 } } @@ -61,7 +59,6 @@ @GUI::SpinBox { name: "mean_line_spinbox" min: 0 - max: 32 } } @@ -78,7 +75,6 @@ @GUI::SpinBox { name: "baseline_spinbox" min: 0 - max: 32 } }