main.cpp 976 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "FontEditor.h"
  2. #include <LibDraw/PNGLoader.h>
  3. #include <LibGUI/GApplication.h>
  4. #include <LibGUI/GWindow.h>
  5. #include <stdio.h>
  6. int main(int argc, char** argv)
  7. {
  8. GApplication app(argc, argv);
  9. RefPtr<Font> edited_font;
  10. String path;
  11. if (argc == 2) {
  12. path = argv[1];
  13. edited_font = Font::load_from_file(path);
  14. if (!edited_font) {
  15. fprintf(stderr, "Couldn't load font: %s\n", path.characters());
  16. return 1;
  17. }
  18. }
  19. if (edited_font)
  20. edited_font = edited_font->clone();
  21. else
  22. edited_font = Font::default_font().clone();
  23. auto window = GWindow::construct();
  24. window->set_title("Font Editor");
  25. window->set_rect({ 50, 50, 390, 342 });
  26. auto font_editor = FontEditorWidget::construct(path, move(edited_font));
  27. window->set_main_widget(font_editor);
  28. window->show();
  29. window->set_icon(load_png("/res/icons/16x16/app-font-editor.png"));
  30. return app.exec();
  31. }