mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
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:
parent
cc7744f6ca
commit
f0f487babd
3 changed files with 18 additions and 12 deletions
|
@ -23,6 +23,9 @@
|
||||||
#include <LibGfx/Font.h>
|
#include <LibGfx/Font.h>
|
||||||
#include <LibGfx/Palette.h>
|
#include <LibGfx/Palette.h>
|
||||||
|
|
||||||
|
static constexpr int s_max_width = 32;
|
||||||
|
static constexpr int s_max_height = 36;
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
class GlyphPreviewWidget final : public Frame {
|
class GlyphPreviewWidget final : public Frame {
|
||||||
|
@ -33,10 +36,13 @@ public:
|
||||||
m_width = width;
|
m_width = width;
|
||||||
m_height = height;
|
m_height = height;
|
||||||
m_glyph_width = width;
|
m_glyph_width = width;
|
||||||
if (m_width > 25 || m_height > 20)
|
for (int i = 10; i > 0; i--) {
|
||||||
set_scale(6);
|
if ((frame_thickness() * 2 + (m_width * i) - 1) <= 250
|
||||||
if (m_width <= 25 && m_height <= 20)
|
&& (frame_thickness() * 2 + (m_height * i) - 1) <= 205) {
|
||||||
set_scale(10);
|
set_scale(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
set_fixed_width(frame_thickness() * 2 + (m_width * m_scale) - 1);
|
set_fixed_width(frame_thickness() * 2 + (m_width * m_scale) - 1);
|
||||||
set_fixed_height(frame_thickness() * 2 + (m_height * 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_glyph_width { 20 };
|
||||||
int m_mean_line { 2 };
|
int m_mean_line { 2 };
|
||||||
int m_baseline { 16 };
|
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_height_spinbox->set_value(20);
|
||||||
m_glyph_width_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_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_spacing_spinbox->set_value(1);
|
||||||
m_fixed_width_checkbox->set_checked(false);
|
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) {
|
m_glyph_height_spinbox->on_change = [&](int value) {
|
||||||
preview_editor.set_preview_size(m_glyph_width_spinbox->value(), 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([&] {
|
deferred_invoke([&] {
|
||||||
m_glyph_editor_container->set_fixed_height(1 + preview_editor.height() + preview_editor.frame_thickness() * 2);
|
m_glyph_editor_container->set_fixed_height(1 + preview_editor.height() + preview_editor.frame_thickness() * 2);
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,8 +26,6 @@ private:
|
||||||
|
|
||||||
void save_metadata();
|
void save_metadata();
|
||||||
|
|
||||||
RefPtr<Gfx::BitmapFont> m_font_clone;
|
|
||||||
|
|
||||||
struct NewFontMetadata {
|
struct NewFontMetadata {
|
||||||
u8 glyph_width;
|
u8 glyph_width;
|
||||||
u8 glyph_height;
|
u8 glyph_height;
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
@GUI::SpinBox {
|
@GUI::SpinBox {
|
||||||
name: "height_spinbox"
|
name: "height_spinbox"
|
||||||
min: 0
|
min: 0
|
||||||
max: 34
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +43,6 @@
|
||||||
@GUI::SpinBox {
|
@GUI::SpinBox {
|
||||||
name: "width_spinbox"
|
name: "width_spinbox"
|
||||||
min: 0
|
min: 0
|
||||||
max: 34
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +59,6 @@
|
||||||
@GUI::SpinBox {
|
@GUI::SpinBox {
|
||||||
name: "mean_line_spinbox"
|
name: "mean_line_spinbox"
|
||||||
min: 0
|
min: 0
|
||||||
max: 32
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +75,6 @@
|
||||||
@GUI::SpinBox {
|
@GUI::SpinBox {
|
||||||
name: "baseline_spinbox"
|
name: "baseline_spinbox"
|
||||||
min: 0
|
min: 0
|
||||||
max: 32
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue