summaryrefslogtreecommitdiff
path: root/Applications/FontEditor/main.cpp
blob: 109e4a1151bff9133d56b83194664db5c50d2014 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "FontEditor.h"
#include <LibDraw/PNGLoader.h>
#include <LibGUI/GApplication.h>
#include <LibGUI/GWindow.h>
#include <stdio.h>

int main(int argc, char** argv)
{
    GApplication app(argc, argv);

    RefPtr<Font> edited_font;
    String path;

    if (argc == 2) {
        path = argv[1];
        edited_font = Font::load_from_file(path);
        if (!edited_font) {
            fprintf(stderr, "Couldn't load font: %s\n", path.characters());
            return 1;
        }
    }

    if (edited_font)
        edited_font = edited_font->clone();
    else
        edited_font = Font::default_font().clone();

    auto window = GWindow::construct();
    window->set_title("Font Editor");
    window->set_rect({ 50, 50, 390, 342 });
    auto font_editor = FontEditorWidget::construct(path, move(edited_font));
    window->set_main_widget(font_editor);
    window->show();
    window->set_icon(load_png("/res/icons/16x16/app-font-editor.png"));
    return app.exec();
}