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.
This commit is contained in:
thankyouverycool 2021-04-22 14:40:24 -04:00 committed by Andreas Kling
parent cc7744f6ca
commit f0f487babd
Notes: sideshowbarker 2024-07-18 19:12:25 +09:00
3 changed files with 18 additions and 12 deletions

View File

@ -23,6 +23,9 @@
#include <LibGfx/Font.h>
#include <LibGfx/Palette.h>
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);
});

View File

@ -26,8 +26,6 @@ private:
void save_metadata();
RefPtr<Gfx::BitmapFont> m_font_clone;
struct NewFontMetadata {
u8 glyph_width;
u8 glyph_height;

View File

@ -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
}
}