mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 10:22:05 -05:00
LibGfx+FontEditor: Add helper to determine raw glyph presence
GlyphBitmaps are considered present if they have a width greater than zero. This adds a counterpart method for raw (unmasked) glyphs and makes intent more explicit throughout FontEditor.
This commit is contained in:
parent
cdaa179eeb
commit
edf86af4f4
3 changed files with 8 additions and 7 deletions
|
@ -204,7 +204,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&&
|
|||
});
|
||||
m_paste_action->set_enabled(GUI::Clipboard::the().fetch_mime_type() == "glyph/x-fonteditor");
|
||||
m_delete_action = GUI::CommonActions::make_delete_action([this](auto&) {
|
||||
if (m_glyph_editor_widget->is_glyph_empty() && m_edited_font->raw_glyph_width(m_glyph_map_widget->selected_glyph()) == 0)
|
||||
if (m_glyph_editor_widget->is_glyph_empty() && !m_edited_font->contains_raw_glyph(m_glyph_map_widget->selected_glyph()))
|
||||
return;
|
||||
m_glyph_editor_widget->delete_glyph();
|
||||
if (m_edited_font->is_fixed_width())
|
||||
|
@ -252,7 +252,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&&
|
|||
} else if (i < 0 && search_wrapped) {
|
||||
break;
|
||||
}
|
||||
if (m_edited_font->raw_glyph_width(i) > 0) {
|
||||
if (m_edited_font->contains_raw_glyph(i)) {
|
||||
m_glyph_map_widget->set_focus(true);
|
||||
m_glyph_map_widget->set_selected_glyph(i);
|
||||
m_glyph_map_widget->scroll_to_glyph(i);
|
||||
|
@ -270,7 +270,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&&
|
|||
} else if (i > 0x10FFFF && search_wrapped) {
|
||||
break;
|
||||
}
|
||||
if (m_edited_font->raw_glyph_width(i) > 0) {
|
||||
if (m_edited_font->contains_raw_glyph(i)) {
|
||||
m_glyph_map_widget->set_focus(true);
|
||||
m_glyph_map_widget->set_selected_glyph(i);
|
||||
m_glyph_map_widget->scroll_to_glyph(i);
|
||||
|
@ -501,7 +501,7 @@ void FontEditorWidget::initialize(const String& path, RefPtr<Gfx::BitmapFont>&&
|
|||
m_glyph_editor_width_spinbox->set_value(m_edited_font->raw_glyph_width(m_glyph_map_widget->selected_glyph()), GUI::AllowCallback::No);
|
||||
|
||||
m_glyph_editor_present_checkbox->set_visible(m_edited_font->is_fixed_width());
|
||||
m_glyph_editor_present_checkbox->set_checked(m_edited_font->raw_glyph_width(m_glyph_map_widget->selected_glyph()) > 0, GUI::AllowCallback::No);
|
||||
m_glyph_editor_present_checkbox->set_checked(m_edited_font->contains_raw_glyph(m_glyph_map_widget->selected_glyph()), GUI::AllowCallback::No);
|
||||
m_fixed_width_checkbox->set_checked(m_edited_font->is_fixed_width(), GUI::AllowCallback::No);
|
||||
|
||||
m_name_textbox->set_text(m_edited_font->name(), GUI::AllowCallback::No);
|
||||
|
@ -736,7 +736,7 @@ void FontEditorWidget::update_statusbar()
|
|||
builder.appendff(" {}", glyph_name.value());
|
||||
}
|
||||
|
||||
if (m_edited_font->raw_glyph_width(glyph) > 0)
|
||||
if (m_edited_font->contains_raw_glyph(glyph))
|
||||
builder.appendff(" [{}x{}]", m_edited_font->raw_glyph_width(glyph), m_edited_font->glyph_height());
|
||||
m_statusbar->set_text(builder.to_string());
|
||||
}
|
||||
|
|
|
@ -97,9 +97,9 @@ void GlyphMapWidget::paint_event(GUI::PaintEvent& event)
|
|||
font().glyph_height());
|
||||
if (glyph == m_selected_glyph) {
|
||||
painter.fill_rect(outer_rect, is_focused() ? palette().selection() : palette().inactive_selection());
|
||||
if (m_font->raw_glyph_width(glyph))
|
||||
if (m_font->contains_raw_glyph(glyph))
|
||||
painter.draw_glyph(inner_rect.location(), glyph, is_focused() ? palette().selection_text() : palette().inactive_selection_text());
|
||||
} else if (m_font->raw_glyph_width(glyph)) {
|
||||
} else if (m_font->contains_raw_glyph(glyph)) {
|
||||
painter.fill_rect(outer_rect, palette().base());
|
||||
painter.draw_glyph(inner_rect.location(), glyph, palette().base_text());
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
Glyph glyph(u32 code_point) const override;
|
||||
Glyph raw_glyph(u32 code_point) const;
|
||||
bool contains_glyph(u32 code_point) const override;
|
||||
bool contains_raw_glyph(u32 code_point) const { return m_glyph_widths[code_point] > 0; }
|
||||
|
||||
ALWAYS_INLINE int glyph_or_emoji_width(u32 code_point) const override
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue