diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-02-02 23:13:12 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-02-02 23:13:12 +0100 |
commit | 7f91aec25cd2b517e8a4bacc2b35e08a0556e9d4 (patch) | |
tree | 32318f1559c8e26257205af82c39a621cba1863e /FontEditor | |
parent | 655753c557afb221302aaa1935fee82021afff3f (diff) | |
download | serenity-7f91aec25cd2b517e8a4bacc2b35e08a0556e9d4.zip |
Support font files.
This only works with the userspace build of SharedGraphics so far.
It's also very slow at loading fonts, but that's easy to fix.
Let's put fonts in /res/fonts/.
Diffstat (limited to 'FontEditor')
-rw-r--r-- | FontEditor/FontEditor.cpp | 16 | ||||
-rw-r--r-- | FontEditor/FontEditor.h | 2 |
2 files changed, 15 insertions, 3 deletions
diff --git a/FontEditor/FontEditor.cpp b/FontEditor/FontEditor.cpp index 011368d6db..57dc476678 100644 --- a/FontEditor/FontEditor.cpp +++ b/FontEditor/FontEditor.cpp @@ -1,18 +1,28 @@ #include "FontEditor.h" #include <SharedGraphics/Painter.h> +#include <LibGUI/GButton.h> #include <LibGUI/GLabel.h> FontEditorWidget::FontEditorWidget(GWidget* parent) : GWidget(parent) { - auto mutable_font = Font::default_font().clone(); + m_edited_font = Font::load_from_file("/saved.font"); + if (!m_edited_font) + m_edited_font = Font::default_font().clone(); - m_glyph_map_widget = new GlyphMapWidget(*mutable_font, this); + m_glyph_map_widget = new GlyphMapWidget(*m_edited_font, this); m_glyph_map_widget->move_to({ 90, 5 }); - m_glyph_editor_widget = new GlyphEditorWidget(*mutable_font, this); + m_glyph_editor_widget = new GlyphEditorWidget(*m_edited_font, this); m_glyph_editor_widget->move_to({ 5, 5 }); + auto* save_button = new GButton(this); + save_button->set_caption("Save"); + save_button->set_relative_rect({ 5, 135, 140, 20 }); + save_button->on_click = [this] (GButton&) { + m_edited_font->write_to_file("/saved.font"); + }; + auto* label = new GLabel(this); label->set_relative_rect({ 5, 110, 140, 20 }); diff --git a/FontEditor/FontEditor.h b/FontEditor/FontEditor.h index b4a1f547ee..7786edceb2 100644 --- a/FontEditor/FontEditor.h +++ b/FontEditor/FontEditor.h @@ -12,6 +12,8 @@ public: virtual ~FontEditorWidget() override; private: + RetainPtr<Font> m_edited_font; + GlyphMapWidget* m_glyph_map_widget { nullptr }; GlyphEditorWidget* m_glyph_editor_widget { nullptr }; }; |