From 8d80d1346dc4d8dca9d8045071c8bacaafe78f06 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sat, 20 Nov 2021 03:00:58 +0100 Subject: FontEditor: Add ability to copy the selected code point This makes it easier to preview the current glyph, if it is not easily typable. --- Userland/Applications/FontEditor/FontEditor.cpp | 8 ++++++++ Userland/Applications/FontEditor/FontEditorWindow.gml | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'Userland') diff --git a/Userland/Applications/FontEditor/FontEditor.cpp b/Userland/Applications/FontEditor/FontEditor.cpp index 5aa52c189f..0b0bceb810 100644 --- a/Userland/Applications/FontEditor/FontEditor.cpp +++ b/Userland/Applications/FontEditor/FontEditor.cpp @@ -116,6 +116,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr&& auto& rotate_90_button = *find_descendant_of_type_named("rotate_90"); auto& flip_vertical_button = *find_descendant_of_type_named("flip_vertical"); auto& flip_horizontal_button = *find_descendant_of_type_named("flip_horizontal"); + auto& copy_code_point_button = *find_descendant_of_type_named("copy_code_point"); m_statusbar = *find_descendant_of_type_named("statusbar"); m_glyph_editor_container = *find_descendant_of_type_named("glyph_editor_container"); m_left_column_container = *find_descendant_of_type_named("left_column_container"); @@ -347,6 +348,13 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr&& }; flip_horizontal_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-horizontal.png").release_value_but_fixme_should_propagate_errors()); + copy_code_point_button.on_click = [&](auto) { + StringBuilder glyph_builder; + glyph_builder.append_code_point(m_glyph_editor_widget->glyph()); + GUI::Clipboard::the().set_plain_text(glyph_builder.build()); + }; + copy_code_point_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png").release_value_but_fixme_should_propagate_errors()); + GUI::Clipboard::the().on_change = [&](const String& data_type) { m_paste_action->set_enabled(data_type == "glyph/x-fonteditor"); }; diff --git a/Userland/Applications/FontEditor/FontEditorWindow.gml b/Userland/Applications/FontEditor/FontEditorWindow.gml index 3a5c24b17a..a3cf68b1ae 100644 --- a/Userland/Applications/FontEditor/FontEditorWindow.gml +++ b/Userland/Applications/FontEditor/FontEditorWindow.gml @@ -80,6 +80,13 @@ button_style: "Coolbar" focus_policy: "TabFocus" } + } + + @GUI::Widget { + shrink_to_fit: true + + layout: @GUI::HorizontalBoxLayout { + } @GUI::Button { name: "rotate_90" @@ -88,6 +95,17 @@ button_style: "Coolbar" focus_policy: "TabFocus" } + + @GUI::Widget { + } + + @GUI::Button { + name: "copy_code_point" + fixed_width: 22 + tooltip: "Copy this codepoint (not glyph)" + button_style: "Coolbar" + focus_policy: "TabFocus" + } } } } -- cgit v1.2.3