FontEditor: Display something for emoji glyphs

This commit makes FontEditor displaying emojis in GlyphMapWidget. They
are not editable, what is marked by red background of a glyph.

Additionally, a proper information is displayed in statusbar.

Fixes #10900.
This commit is contained in:
Maciej 2021-11-14 13:27:17 +01:00 committed by Andreas Kling
parent 923bec28b7
commit 4d4764e0fb
2 changed files with 9 additions and 0 deletions

View file

@ -34,6 +34,7 @@
#include <LibGUI/ToolbarContainer.h>
#include <LibGUI/Window.h>
#include <LibGfx/BitmapFont.h>
#include <LibGfx/Emoji.h>
#include <LibGfx/FontStyleMapping.h>
#include <LibGfx/Palette.h>
#include <LibGfx/TextDirection.h>
@ -742,6 +743,8 @@ void FontEditorWidget::update_statusbar()
if (m_edited_font->contains_raw_glyph(glyph))
builder.appendff(" [{}x{}]", m_edited_font->raw_glyph_width(glyph), m_edited_font->glyph_height());
else if (Gfx::Emoji::emoji_for_code_point(glyph))
builder.appendff(" [emoji]");
m_statusbar->set_text(builder.to_string());
}

View file

@ -8,6 +8,7 @@
#include "GlyphMapWidget.h"
#include <LibGUI/Painter.h>
#include <LibGfx/BitmapFont.h>
#include <LibGfx/Emoji.h>
#include <LibGfx/Palette.h>
GlyphMapWidget::GlyphMapWidget()
@ -102,9 +103,14 @@ void GlyphMapWidget::paint_event(GUI::PaintEvent& event)
painter.fill_rect(outer_rect, is_focused() ? palette().selection() : palette().inactive_selection());
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 (auto* emoji = Gfx::Emoji::emoji_for_code_point(glyph))
painter.draw_emoji(inner_rect.location(), *emoji, *m_font);
} 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());
} else if (auto* emoji = Gfx::Emoji::emoji_for_code_point(glyph)) {
painter.fill_rect(outer_rect, Gfx::Color { 255, 150, 150 });
painter.draw_emoji(inner_rect.location(), *emoji, *m_font);
}
}
}