LibGUI+Applications: Let GlyphMapWidget initialize a null Font

FontEditor will need to clear references to its mutable font in
the future while CharacterMap has no use for the highlights clone,
so let's convert GlyphMapWidget's set_font wrapper into a separate
initialize function for the editor and stop hiding the base function
for others. Setting font null in either ultimately points the map to
the system's default font.
This commit is contained in:
thankyouverycool 2023-05-10 17:01:08 -04:00 committed by Andreas Kling
parent cf4ddd1dcf
commit 0ad5e85163
Notes: sideshowbarker 2024-07-17 02:29:45 +09:00
4 changed files with 8 additions and 6 deletions

View file

@ -167,8 +167,7 @@ ErrorOr<void> CharacterMapWidget::initialize_menubar(GUI::Window& window)
void CharacterMapWidget::did_change_font()
{
// No need to track glyph modifications by cloning
m_glyph_map->GUI::AbstractScrollableWidget::set_font(font());
m_glyph_map->set_font(font());
m_font_name_label->set_text(String::from_deprecated_string(font().human_readable_name()).release_value_but_fixme_should_propagate_errors());
m_output_box->set_font(font());
}

View file

@ -637,7 +637,7 @@ ErrorOr<void> MainWidget::initialize(StringView path, RefPtr<Gfx::BitmapFont>&&
if (m_font == mutable_font)
return {};
TRY(m_glyph_map_widget->set_font(*mutable_font));
TRY(m_glyph_map_widget->initialize(mutable_font));
auto active_glyph = m_glyph_map_widget->active_glyph();
m_glyph_map_widget->set_focus(true);

View file

@ -573,9 +573,12 @@ bool GlyphMapWidget::glyph_is_modified(u32 glyph)
return m_modified_glyphs.contains(glyph);
}
ErrorOr<void> GlyphMapWidget::set_font(Gfx::Font const& font)
ErrorOr<void> GlyphMapWidget::initialize(Gfx::Font const* font)
{
m_original_font = TRY(font.try_clone());
if (font)
m_original_font = TRY(font->try_clone());
else
m_original_font = nullptr;
m_modified_glyphs.clear();
AbstractScrollableWidget::set_font(font);
return {};

View file

@ -20,7 +20,7 @@ class GlyphMapWidget final : public AbstractScrollableWidget {
public:
virtual ~GlyphMapWidget() override = default;
ErrorOr<void> set_font(Gfx::Font const&);
ErrorOr<void> initialize(Gfx::Font const*);
class Selection {
public: