29#include <sigc++/functors/mem_fun.h>
30#include <glibmm/i18n.h>
31#include <glibmm/regex.h>
32#include <gdkmm/display.h>
52 Gtk::CellRendererText*
const cell)
56 cell->set_property (
"markup", markup);
65 , signal_block (false)
82 Controller::add_key<&FontSelectorToolbar::on_key_pressed>(*entry, *
this);
86 completion->set_text_column (0);
87 completion->set_popup_completion ();
88 completion->set_inline_completion (
false);
89 completion->set_inline_selection ();
90 entry->set_completion (completion);
94 style_combo.set_name (
"FontSelectorToolbar: Style");
97 set_name (
"FontSelectorToolbar: Grid");
121 Gtk::TreeModel::Row row;
128 std::cerr <<
"FontSelectorToolbar::update_font: Couldn't find row for family: "
137 std::cerr <<
"FontSelectorToolbar::update_font: Couldn't find row for style: "
146 if (missing_fonts.empty()) {
148 entry->set_icon_from_icon_name(INKSCAPE_ICON(
"edit-select-all"), Gtk::Entry::IconPosition::SECONDARY);
149 entry->set_icon_tooltip_text(_(
"Select all text with this text family"), Gtk::Entry::IconPosition::SECONDARY);
152 Glib::ustring warning = _(
"Font not found on system: ") + missing_fonts;
153 entry->set_icon_from_icon_name(INKSCAPE_ICON(
"dialog-warning"), Gtk::Entry::IconPosition::SECONDARY);
154 entry->set_icon_tooltip_text(warning, Gtk::Entry::IconPosition::SECONDARY);
166 Glib::ustring font_list =
family_combo.get_entry_text();
167 Glib::ustring missing_font_list;
170 std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(
"\\s*,\\s*", font_list);
172 for (
auto token: tokens) {
174 Gtk::TreeModel::Children children = font_lister->
get_font_list()->children();
175 for (
auto row2 : children) {
180 if (onSystem2 && token.casefold().compare(family2.casefold()) == 0) {
187 missing_font_list += token;
188 missing_font_list +=
", ";
193 if (missing_font_list.size() >= 2) {
194 missing_font_list.resize(missing_font_list.size() - 2);
197 return missing_font_list;
226 Glib::ustring style =
style_combo.get_entry_text();
239 std::cerr <<
"FontSelectorToolbar::on_entry_icon_pressed" << std::endl;
240 std::cerr <<
" .... Should select all items with same font-family. FIXME" << std::endl;
249 unsigned ,
unsigned const keycode,
250 GdkModifierType
const state)
252 unsigned int key = 0;
253 gdk_display_translate_key(gdk_display_get_default(),
264 case GDK_KEY_KP_Enter:
266 std::cerr <<
"FontSelectorToolbar::on_key_pressed: Defocus: FIXME" << std::endl;
This class enumerates fonts using libnrtype into reusable data stores and allows for random access to...
Glib::ustring get_font_family_markup(Gtk::TreeModel::const_iterator const &iter) const
Get markup for font-family.
Gtk::TreeModel::Row get_row_for_style()
void set_font_style(Glib::ustring style, bool emit=true)
Sets style.
Glib::RefPtr< Gtk::ListStore > const & get_style_list() const
void update_font_list(SPDocument *document)
Updates font list to include fonts in document.
Gtk::TreeModel::Row get_row_for_font()
Glib::ustring const & get_font_style() const
static Inkscape::FontLister * get_instance()
Glib::RefPtr< Gtk::ListStore > const & get_font_list() const
std::pair< Glib::ustring, Glib::ustring > set_font_family(Glib::ustring const &family, bool check_style=true, bool emit=true)
Sets font-family, updating style list and attempting to find closest style to old current_style.
sigc::connection connectUpdate(sigc::slot< void()> slot)
Let users of FontLister know to update GUI.
Glib::ustring const & get_font_family() const
Utilities to more easily use Gtk::EventController & subclasses like Gesture.
Editable view implementation.
The data describing a single loaded font.
bool font_lister_separator_func(Glib::RefPtr< Gtk::TreeModel > const &, Gtk::TreeModel::const_iterator const &iter)
Macro for icon names used in Inkscape.
static cairo_user_data_key_t key
Gtk::TreeModelColumn< Glib::ustring > family
Family name.
Gtk::TreeModelColumn< bool > onSystem
Whether font is on system.