mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:17:44 +00:00
FontEditor: Update editor to handle new font format
The editor now unmasks fonts on load, mapping their glyphs to the complete unicode character set, and masks them upon saving to reduce disk space. This is a naive approach in terms of memory usage and can be improved but whose immediate goal is to allow editing any glyph without concern for range allocation.
This commit is contained in:
parent
9bcfdfc03b
commit
a486415f03
10 changed files with 26 additions and 91 deletions
|
@ -39,7 +39,7 @@ void GlyphEditorWidget::delete_glyph()
|
|||
{
|
||||
if (on_undo_event)
|
||||
on_undo_event();
|
||||
auto bitmap = font().glyph(m_glyph).glyph_bitmap();
|
||||
auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap();
|
||||
for (int x = 0; x < bitmap.width(); x++)
|
||||
for (int y = 0; y < bitmap.height(); y++)
|
||||
bitmap.set_bit_at(x, y, false);
|
||||
|
@ -56,7 +56,7 @@ void GlyphEditorWidget::cut_glyph()
|
|||
|
||||
void GlyphEditorWidget::copy_glyph()
|
||||
{
|
||||
auto bitmap = font().glyph(m_glyph).glyph_bitmap();
|
||||
auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap();
|
||||
u8 bits[bitmap.width()][bitmap.height()];
|
||||
for (int x = 0; x < bitmap.width(); x++) {
|
||||
for (int y = 0; y < bitmap.height(); y++) {
|
||||
|
@ -105,7 +105,7 @@ void GlyphEditorWidget::paste_glyph()
|
|||
}
|
||||
}
|
||||
|
||||
auto bitmap = font().glyph(m_glyph).glyph_bitmap();
|
||||
auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap();
|
||||
for (int x = 0; x < min(bitmap.width(), buffer_width.value()); x++) {
|
||||
for (int y = 0; y < min(bitmap.height(), buffer_height.value()); y++) {
|
||||
if (bits[x][y])
|
||||
|
@ -138,7 +138,7 @@ void GlyphEditorWidget::paint_event(GUI::PaintEvent& event)
|
|||
for (int x = 1; x < font().max_glyph_width(); ++x)
|
||||
painter.draw_line({ x * m_scale, 0 }, { x * m_scale, font().glyph_height() * m_scale }, palette().threed_shadow2());
|
||||
|
||||
auto bitmap = font().glyph(m_glyph).glyph_bitmap();
|
||||
auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap();
|
||||
|
||||
for (int y = 0; y < font().glyph_height(); ++y) {
|
||||
for (int x = 0; x < font().max_glyph_width(); ++x) {
|
||||
|
@ -155,7 +155,7 @@ void GlyphEditorWidget::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
bool GlyphEditorWidget::is_glyph_empty()
|
||||
{
|
||||
auto bitmap = font().glyph(m_glyph).glyph_bitmap();
|
||||
auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap();
|
||||
for (int x = 0; x < bitmap.width(); x++)
|
||||
for (int y = 0; y < bitmap.height(); y++)
|
||||
if (bitmap.bit_at(x, y))
|
||||
|
@ -176,7 +176,7 @@ void GlyphEditorWidget::mousedown_event(GUI::MouseEvent& event)
|
|||
draw_at_mouse(event);
|
||||
} else {
|
||||
memset(m_movable_bits, 0, sizeof(m_movable_bits));
|
||||
auto bitmap = font().glyph(m_glyph).glyph_bitmap();
|
||||
auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap();
|
||||
for (int x = s_max_width; x < s_max_width + bitmap.width(); x++)
|
||||
for (int y = s_max_height; y < s_max_height + bitmap.height(); y++)
|
||||
m_movable_bits[x][y] = bitmap.bit_at(x - s_max_width, y - s_max_height);
|
||||
|
@ -221,7 +221,7 @@ void GlyphEditorWidget::draw_at_mouse(const GUI::MouseEvent& event)
|
|||
return;
|
||||
int x = (event.x() - 1) / m_scale;
|
||||
int y = (event.y() - 1) / m_scale;
|
||||
auto bitmap = font().glyph(m_glyph).glyph_bitmap();
|
||||
auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap();
|
||||
if (x < 0 || x >= bitmap.width())
|
||||
return;
|
||||
if (y < 0 || y >= bitmap.height())
|
||||
|
@ -238,7 +238,7 @@ void GlyphEditorWidget::move_at_mouse(const GUI::MouseEvent& event)
|
|||
{
|
||||
int x_delta = ((event.x() - 1) / m_scale) - x_offset;
|
||||
int y_delta = ((event.y() - 1) / m_scale) - y_offset;
|
||||
auto bitmap = font().glyph(m_glyph).glyph_bitmap();
|
||||
auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap();
|
||||
if (abs(x_delta) > bitmap.width() || abs(y_delta) > bitmap.height())
|
||||
return;
|
||||
for (int x = 0; x < bitmap.width(); x++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue