FontEditor: Improve error handling opening, saving and editing fonts

Adds fallible functions for opening and saving fonts and cutting
and copying selections. FontEditor now falls back on a guaranteed
default BitmapFont on startup. Fixes crashing on start when the
default system font is set to TrueType.
This commit is contained in:
thankyouverycool 2022-07-30 07:30:30 -04:00 committed by Andreas Kling
commit 807bd6da6c
Notes: sideshowbarker 2024-07-17 10:54:57 +09:00
3 changed files with 35 additions and 40 deletions

View file

@ -46,11 +46,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(font_editor->initialize_menubar(*window));
if (path) {
auto success = font_editor->open_file(path);
if (!success)
return 1;
TRY(font_editor->open_file(path));
} else {
auto mutable_font = static_ptr_cast<Gfx::BitmapFont>(Gfx::FontDatabase::default_font().clone())->unmasked_character_set();
auto mutable_font = TRY(TRY(Gfx::BitmapFont::try_load_from_file("/res/fonts/KaticaRegular10.font"))->unmasked_character_set());
TRY(font_editor->initialize({}, move(mutable_font)));
}