1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:28:12 +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:
thankyouverycool 2021-09-09 07:41:08 -04:00 committed by Andreas Kling
parent 9bcfdfc03b
commit a486415f03
10 changed files with 26 additions and 91 deletions

View file

@ -52,7 +52,8 @@ int main(int argc, char** argv)
RefPtr<Gfx::BitmapFont> edited_font;
if (path == nullptr) {
edited_font = static_ptr_cast<Gfx::BitmapFont>(Gfx::FontDatabase::default_font().clone());
auto bitmap_font = static_ptr_cast<Gfx::BitmapFont>(Gfx::FontDatabase::default_font().clone());
edited_font = static_ptr_cast<Gfx::BitmapFont>(bitmap_font->unmasked_character_set());
} else {
auto bitmap_font = Gfx::BitmapFont::load_from_file(path);
if (!bitmap_font) {
@ -60,7 +61,7 @@ int main(int argc, char** argv)
GUI::MessageBox::show(nullptr, message, "Font Editor", GUI::MessageBox::Type::Error);
return 1;
}
edited_font = static_ptr_cast<Gfx::BitmapFont>(bitmap_font->clone());
edited_font = static_ptr_cast<Gfx::BitmapFont>(bitmap_font->unmasked_character_set());
if (!edited_font) {
String message = String::formatted("Couldn't load font: {}\n", path);
GUI::MessageBox::show(nullptr, message, "Font Editor", GUI::MessageBox::Type::Error);