22#include <glibmm/markup.h>
23#include <glibmm/regex.h>
24#include <gtkmm/cellrenderertext.h>
25#include <gtkmm/settings.h>
56 return (a.casefold().compare(b.casefold()) == 0);
78 if (
auto settings = Gtk::Settings::get_default()) {
79 settings->property_gtk_fontconfig_timestamp().signal_changed().connect([
this]() {
97 static bool first_call =
true;
105 if (group_offset <= 0) {
107 if (group_offset == 0)
115 if (!key_val.first.empty()) {
147 bool all_fonts =
false;
152 if (
size >= total_families) {
153 label += _(
"All Fonts");
156 label += _(
"Fonts ");
159 label += std::to_string(total_families);
162 return std::make_pair(all_fonts,
label);
174 auto it = std::search(
175 text.begin(), text.end(),
176 pat.begin(), pat.end(),
177 [] (
unsigned char ch1,
unsigned char ch2) { return std::toupper(ch1) == std::toupper(ch2); }
180 return it != text.end();
188 if (search_text ==
"") {
217 add_document_fonts_at_top(SP_ACTIVE_DOCUMENT);
218 font_list_store->thaw_notify();
219 init_default_styles();
225void FontLister::apply_collections(std::set <Glib::ustring>& selected_collections)
228 std::set <Glib::ustring> fonts;
232 for (
auto const &col : selected_collections) {
235 for (
auto const &font : document_fonts->
get_fonts()) {
240 for (
auto const &font : recently_used->
get_fonts()) {
244 for (
auto const &font : font_collections->
get_fonts(col)) {
245 fonts.insert(std::move(font));
251 font_list_store->freeze_notify();
252 font_list_store->clear();
257 init_font_families();
258 init_default_styles();
259 add_document_fonts_at_top(SP_ACTIVE_DOCUMENT);
263 for (
auto const &f : fonts) {
264 auto row = *font_list_store->append();
265 row[font_list.family] = f;
269 row[font_list.styles] =
nullptr;
272 row[font_list.pango_family] = pango_family_map[f];
273 row[font_list.onSystem] =
true;
276 add_document_fonts_at_top(SP_ACTIVE_DOCUMENT);
277 font_list_store->thaw_notify();
278 init_default_styles();
281 update_signal.emit();
285void FontLister::ensureRowStyles(Gtk::TreeModel::iterator iter)
288 if (row.get_value(font_list.styles)) {
292 if (row[font_list.pango_family]) {
293 row[font_list.styles] = std::make_shared<Styles>(
FontFactory::get().GetUIStyles(row[font_list.pango_family]));
295 row[font_list.styles] = default_styles;
299Glib::ustring FontLister::get_font_family_markup(Gtk::TreeModel::const_iterator
const &iter)
const
301 auto const &row = *iter;
304 Glib::ustring family = row[font_list.family];
305 bool onSystem = row[font_list.onSystem];
307 Glib::ustring family_escaped = Glib::Markup::escape_text( family );
308 Glib::ustring markup;
311 markup =
"<span font-weight='bold'>";
314 std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(
"\\s*,\\s*", family);
316 for (
auto const &token: tokens) {
317 if (font_installed_on_system(token)) {
318 markup += Glib::Markup::escape_text (token);
321 markup +=
"<span strikethrough=\"true\" strikethrough_color=\"red\">";
322 markup += Glib::Markup::escape_text (token);
329 if (markup.size() >= 2) {
330 markup.resize(markup.size() - 2);
335 markup = family_escaped;
338 int show_sample = prefs->
getInt(
"/tools/text/show_sample_in_list", 1);
340 Glib::ustring sample = prefs->
getString(
"/tools/text/font_sample");
342#if PANGO_VERSION_CHECK(1,50,0)
343 markup +=
" <span foreground='gray' line-height='0.6' font-size='100%' font_family='";
345 markup +=
" <span foreground='gray' font_family='";
347 markup += family_escaped;
371void FontLister::insert_font_family(Glib::ustring
const &new_family)
373 auto styles = default_styles;
376 std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(
",", new_family);
377 if (!tokens.empty() && !tokens[0].empty()) {
378 for (
auto &row : font_list_store->children()) {
379 auto row_styles = row.get_value(font_list.styles);
383 row_styles = std::make_shared<Styles>(
FontFactory::get().GetUIStyles(row[font_list.pango_family]));
391 auto row = *font_list_store->prepend();
392 row[font_list.family] = new_family;
393 row[font_list.styles] = styles;
394 row[font_list.onSystem] =
false;
395 row[font_list.pango_family] =
nullptr;
397 current_family = new_family;
398 current_family_row = 0;
399 current_style =
"Normal";
404int FontLister::add_document_fonts_at_top(
SPDocument *document)
417 auto children = font_list_store->
children();
418 for (
auto iter = children.begin(),
end = children.end(); iter !=
end;) {
419 if (!iter->get_value(font_list.onSystem)) {
421 iter = font_list_store->erase(iter);
430 std::map<Glib::ustring, std::set<Glib::ustring>> font_data;
431 update_font_data_recursive(*
root, font_data);
434 if (!font_data.empty()) {
435 auto row = *font_list_store->prepend();
436 row[font_list.family] =
"#";
440 for (
auto const &[data_family, data_styleset] : font_data) {
442 auto const i = data_family.find_first_of(
',');
446 auto const fam = data_family.substr(0, i);
449 auto find_matching_system_font = [
this] (Glib::ustring
const &fam) -> Gtk::TreeIter<Gtk::TreeRow> {
450 for (
auto &row : font_list_store->children()) {
452 return row.get_iter();
462 if (
auto const iter = find_matching_system_font(fam)) {
463 auto const row = *iter;
464 ensureRowStyles(iter);
465 data_styles = *row.get_value(font_list.styles);
469 for (
auto const &data_style : data_styleset) {
473 for (
auto const &style : data_styles) {
474 if (style.css_name.compare(data_style) == 0) {
481 data_styles.emplace_back(data_style, data_style);
485 auto row = *font_list_store->prepend();
486 row[font_list.family] = data_family;
487 row[font_list.styles] = std::make_shared<Styles>(std::move(data_styles));
496 document_fonts->update_document_fonts(font_data);
498 return font_data.size();
508 font_list_store->freeze_notify();
511 bool row_is_system =
false;
512 if (current_family_row > -1) {
514 path.push_back(current_family_row);
515 Gtk::TreeModel::iterator iter = font_list_store->get_iter(path);
517 row_is_system = (*iter)[font_list.onSystem];
522 int font_data_size = add_document_fonts_at_top(document);
524 font_family_row_update(row_is_system ? font_data_size : 0);
527 font_list_store->thaw_notify();
531void FontLister::update_font_data_recursive(
SPObject &r, std::map<Glib::ustring, std::set<Glib::ustring>> &font_data)
539 auto font_family_char = pango_font_description_get_family(descr);
540 if (font_family_char) {
541 Glib::ustring font_family(font_family_char);
542 pango_font_description_unset_fields(descr, PANGO_FONT_MASK_FAMILY);
544 auto font_style_char = pango_font_description_to_string(descr);
545 Glib::ustring font_style(font_style_char);
546 g_free(font_style_char);
548 if (!font_family.empty() && !font_style.empty()) {
549 font_data[font_family].insert(font_style);
553 std::cerr <<
"FontLister::update_font_data_recursive: descr without font family! " << (r.
getId()?r.
getId():
"null") << std::endl;
555 pango_font_description_free(descr);
557 if (is<SPGroup>(&r) ||
562 is<SPTextPath>(&r) ||
564 is<SPFlowtext>(&r) ||
566 is<SPFlowpara>(&r) ||
570 update_font_data_recursive(
child, font_data);
575void FontLister::emit_update()
580 update_signal.emit();
584Glib::ustring FontLister::canonize_fontspec(Glib::ustring
const &fontspec)
const
591 gchar *canonized = pango_font_description_to_string(descr);
592 Glib::ustring Canonized = canonized;
594 pango_font_description_free(descr);
599 while ((i = Canonized.find_first_of(
",@", i)) != std::string::npos ) {
600 if (Canonized[i] ==
'@')
602 Canonized.replace(i, 1,
", ");
609Glib::ustring FontLister::system_fontspec(Glib::ustring
const &fontspec)
612 Glib::ustring out = fontspec;
617 auto nFaceDesc = pango_font_describe(res->get_font());
620 pango_font_description_free(descr);
625std::pair<Glib::ustring, Glib::ustring> FontLister::ui_from_fontspec(Glib::ustring
const &fontspec)
const
628 const gchar *family = pango_font_description_get_family(descr);
630 family =
"sans-serif";
631 Glib::ustring Family = family;
638 Glib::RefPtr<Glib::Regex>
weight = Glib::Regex::create(
",[1-9]00$");
639 Family =
weight->replace(Family, 0,
"", Glib::Regex::MatchFlags::PARTIAL);
643 while ((i = Family.find(
",", i)) != std::string::npos) {
644 Family.replace(i, 1,
", ");
648 pango_font_description_unset_fields(descr, PANGO_FONT_MASK_FAMILY);
649 gchar *style = pango_font_description_to_string(descr);
650 Glib::ustring Style = style;
651 pango_font_description_free(descr);
654 return std::make_pair(Family, Style);
663void FontLister::font_family_row_update(
int start)
665 if (this->current_family_row > -1 &&
start > -1) {
666 int length = this->font_list_store->children().size();
667 for (
int i = 0; i < length; ++i) {
673 if (
auto iter = font_list_store->get_iter(path)) {
675 current_family_row = row;
683std::pair<Glib::ustring, Glib::ustring> FontLister::selection_update()
686 std::cout <<
"\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
687 std::cout <<
"FontLister::selection_update: entrance" << std::endl;
690 Glib::ustring fontspec;
691 SPStyle query(SP_ACTIVE_DOCUMENT);
704 if (fontspec.empty()) {
711 fontspec = fontspec_from_style(&query);
717 if (fontspec.empty()) {
719 if (prefs->
getBool(
"/tools/text/usecurrent")) {
724 fontspec = fontspec_from_style(&query);
728 if (fontspec.empty()) {
730 fontspec = current_family +
", " + current_style;
736 int font_data_size = add_document_fonts_at_top(SP_ACTIVE_DOCUMENT);
737 font_family_row_update(font_data_size);
739 std::pair<Glib::ustring, Glib::ustring> ui = ui_from_fontspec(fontspec);
740 set_font_family(ui.first);
741 set_font_style(ui.second);
744 std::cout <<
" family_row: :" << current_family_row <<
":" << std::endl;
745 std::cout <<
" family: :" << current_family <<
":" << std::endl;
746 std::cout <<
" style: :" << current_style <<
":" << std::endl;
747 std::cout <<
"FontLister::selection_update: exit" << std::endl;
748 std::cout <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl;
753 return std::make_pair(current_family, current_style);
758void FontLister::set_fontspec(Glib::ustring
const &new_fontspec,
bool )
760 auto const &[new_family, new_style] = ui_from_fontspec(new_fontspec);
763 std::cout <<
"FontLister::set_fontspec: family: " << new_family
764 <<
" style:" << new_style << std::endl;
767 set_font_family(new_family,
false,
false);
768 set_font_style(new_style,
false);
776std::pair<Glib::ustring, Glib::ustring> FontLister::new_font_family(Glib::ustring
const &new_family,
bool )
779 std::cout <<
"\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
780 std::cout <<
"FontLister::new_font_family: " << new_family << std::endl;
786 std::cout <<
"FontLister::new_font_family: exit: no change in family." << std::endl;
787 std::cout <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl;
789 return std::make_pair(current_family, current_style);
797 std::shared_ptr<Styles> styles;
798 for (
auto row : font_list_store->children()) {
800 auto row_styles = row.get_value(font_list.styles);
802 row_styles = std::make_shared<Styles>(
FontFactory::get().GetUIStyles(row[font_list.pango_family]));
804 styles = std::move(row_styles);
813 styles = default_styles;
817 style_list_store->freeze_notify();
818 style_list_store->clear();
820 for (
auto const &style : *styles) {
821 auto row = *style_list_store->append();
822 row[font_style_list.cssStyle] = style.css_name;
823 row[font_style_list.displayStyle] = style.display_name;
826 style_list_store->thaw_notify();
831 Glib::ustring best_style = get_best_style_match(new_family, current_style);
834 std::cout <<
"FontLister::new_font_family: exit: " << new_family <<
" " << best_style << std::endl;
835 std::cout <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl;
837 return std::make_pair(new_family, best_style);
840void FontLister::set_dragging_family(
const Glib::ustring &new_family)
842 dragging_family = new_family;
845std::pair<Glib::ustring, Glib::ustring> FontLister::set_font_family(Glib::ustring
const &new_family,
bool const check_style,
850 std::cout <<
"\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
851 std::cout <<
"FontLister::set_font_family: " << new_family << std::endl;
854 std::pair<Glib::ustring, Glib::ustring> ui = new_font_family(new_family, check_style);
855 current_family = ui.first;
856 current_style = ui.second;
859 std::cout <<
" family_row: :" << current_family_row <<
":" << std::endl;
860 std::cout <<
" family: :" << current_family <<
":" << std::endl;
861 std::cout <<
" style: :" << current_style <<
":" << std::endl;
862 std::cout <<
"FontLister::set_font_family: end" << std::endl;
863 std::cout <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl;
872std::pair<Glib::ustring, Glib::ustring> FontLister::set_font_family(
int row,
bool check_style,
bool emit)
876 std::cout <<
"\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
877 std::cout <<
"FontLister::set_font_family( row ): " << row << std::endl;
880 current_family_row = row;
883 Glib::ustring new_family = current_family;
884 if (
auto iter = font_list_store->get_iter(path)) {
885 new_family = (*iter)[font_list.family];
888 std::pair<Glib::ustring, Glib::ustring> ui = set_font_family(new_family, check_style, emit);
891 std::cout <<
"FontLister::set_font_family( row ): end" << std::endl;
892 std::cout <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl;
898void FontLister::set_font_style(Glib::ustring new_style,
bool emit)
904 std::cout <<
"\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
905 std::cout <<
"FontLister:set_font_style: " << new_style << std::endl;
908 current_style = std::move(new_style);
911 std::cout <<
" family: " << current_family << std::endl;
912 std::cout <<
" style: " << current_style << std::endl;
913 std::cout <<
"FontLister::set_font_style: end" << std::endl;
914 std::cout <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl;
925 if (fontspec.empty()) {
929 std::pair<Glib::ustring, Glib::ustring> ui = ui_from_fontspec(fontspec);
931 Glib::ustring family = ui.first;
935 Glib::ustring fontspec_quoted(fontspec);
944 PangoWeight
weight = pango_font_description_get_weight(desc);
946 case PANGO_WEIGHT_THIN:
949 case PANGO_WEIGHT_ULTRALIGHT:
952 case PANGO_WEIGHT_LIGHT:
955 case PANGO_WEIGHT_SEMILIGHT:
958 case PANGO_WEIGHT_BOOK:
961 case PANGO_WEIGHT_NORMAL:
964 case PANGO_WEIGHT_MEDIUM:
967 case PANGO_WEIGHT_SEMIBOLD:
970 case PANGO_WEIGHT_BOLD:
973 case PANGO_WEIGHT_ULTRABOLD:
976 case PANGO_WEIGHT_HEAVY:
979 case PANGO_WEIGHT_ULTRAHEAVY:
989 g_message(
"Pango reported font weight of %d ignored (font: '%s').",
weight, fontspec.c_str());
994 PangoStyle style = pango_font_description_get_style(desc);
996 case PANGO_STYLE_NORMAL:
999 case PANGO_STYLE_OBLIQUE:
1002 case PANGO_STYLE_ITALIC:
1007 PangoStretch stretch = pango_font_description_get_stretch(desc);
1009 case PANGO_STRETCH_ULTRA_CONDENSED:
1012 case PANGO_STRETCH_EXTRA_CONDENSED:
1015 case PANGO_STRETCH_CONDENSED:
1018 case PANGO_STRETCH_SEMI_CONDENSED:
1021 case PANGO_STRETCH_NORMAL:
1024 case PANGO_STRETCH_SEMI_EXPANDED:
1027 case PANGO_STRETCH_EXPANDED:
1030 case PANGO_STRETCH_EXTRA_EXPANDED:
1033 case PANGO_STRETCH_ULTRA_EXPANDED:
1038 PangoVariant variant = pango_font_description_get_variant(desc);
1040 case PANGO_VARIANT_NORMAL:
1043 case PANGO_VARIANT_SMALL_CAPS:
1049 const char* str = pango_font_description_get_variations(desc);
1051 std::string variations;
1055 std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(
",", str);
1057 Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create(
"(\\w{4})=([-+]?\\d*\\.?\\d+([eE][-+]?\\d+)?)");
1058 Glib::MatchInfo matchInfo;
1059 for (
auto const &token: tokens) {
1060 regex->match(token, matchInfo);
1061 if (matchInfo.matches()) {
1063 variations += matchInfo.fetch(1).raw();
1065 variations += matchInfo.fetch(2).raw();
1069 if (variations.length() >= 2) {
1070 variations.pop_back();
1071 variations.pop_back();
1075 if (!variations.empty()) {
1080 pango_font_description_free(desc);
1083Glib::ustring FontLister::fontspec_from_style(
SPStyle *style)
const
1086 Glib::ustring fontspec = pango_font_description_to_string( descr );
1087 pango_font_description_free(descr);
1094Gtk::TreeModel::Row FontLister::get_row_for_font(Glib::ustring
const &family)
1096 for (
auto const &row : font_list_store->children()) {
1102 throw Exception::FAMILY_NOT_FOUND;
1105Gtk::TreePath FontLister::get_path_for_font(Glib::ustring
const &family)
1107 return font_list_store->get_path(get_row_for_font(family).get_iter());
1110bool FontLister::is_path_for_font(Gtk::TreePath path, Glib::ustring family)
1112 if (
auto iter = font_list_store->get_iter(path)) {
1119Gtk::TreeModel::Row FontLister::get_row_for_style(Glib::ustring
const &style)
1121 for (
auto const &row : font_list_store->children()) {
1127 throw Exception::STYLE_NOT_FOUND;
1133 gint
distance = abs(pango_font_description_get_weight(a) -
1134 pango_font_description_get_weight(b));
1136 distance += 10000 * abs(pango_font_description_get_stretch(a) -
1137 pango_font_description_get_stretch(b));
1139 PangoStyle style_a = pango_font_description_get_style(a);
1140 PangoStyle style_b = pango_font_description_get_style(b);
1141 if (style_a != style_b) {
1142 if ((style_a == PANGO_STYLE_OBLIQUE && style_b == PANGO_STYLE_ITALIC) ||
1143 (style_b == PANGO_STYLE_OBLIQUE && style_a == PANGO_STYLE_ITALIC)) {
1151 distance += 1000000 * abs(pango_font_description_get_variant(a) -
1152 pango_font_description_get_variant(b));
1162 if (old_desc ==
nullptr)
1164 if (new_desc ==
nullptr)
1172 return (new_distance < old_distance);
1187Glib::ustring FontLister::get_best_style_match(Glib::ustring
const &family, Glib::ustring
const &target_style)
1191 std::cout <<
"\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
1192 std::cout <<
"FontLister::get_best_style_match: " << family <<
" : " << target_style << std::endl;
1195 Glib::ustring fontspec = family +
", " + target_style;
1197 Gtk::TreeModel::Row row;
1199 row = get_row_for_font(family);
1201 std::cerr <<
"FontLister::get_best_style_match(): can't find family: " << family.raw() << std::endl;
1202 return target_style;
1210 auto styles = default_styles;
1211 if (row[font_list.onSystem] && !row.get_value(font_list.styles)) {
1212 row[font_list.styles] = std::make_shared<Styles>(
FontFactory::get().GetUIStyles(row[font_list.pango_family]));
1213 styles = row[font_list.styles];
1216 for (
auto const &style : *styles) {
1217 Glib::ustring fontspec = family +
", " + style.css_name;
1222 pango_font_description_free(best);
1226 pango_font_description_free(candidate);
1231 Glib::ustring best_style = target_style;
1233 pango_font_description_unset_fields(best, PANGO_FONT_MASK_FAMILY);
1234 best_style = pango_font_description_to_string(best);
1238 pango_font_description_free(target);
1240 pango_font_description_free(best);
1244 std::cout <<
" Returning: " << best_style << std::endl;
1245 std::cout <<
"FontLister::get_best_style_match: exit" << std::endl;
1246 std::cout <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl;
1257 Gtk::TreeModel::const_iterator
const &iter)
1264 return entry ==
"#";
1269 Gtk::TreeModel::const_iterator
const & )
1276 Gtk::TreeModel::const_iterator
const &iter)
1280 renderer->set_property(
"markup", markup);
1285 Gtk::TreeModel::const_iterator
const &iter,
1289 Glib::ustring family = (*iter)[font_lister->font_list.family];
1290 bool onSystem = (*iter)[font_lister->font_list.onSystem];
1291 auto family_escaped = g_markup_escape_text(family.c_str(), -1);
1293 bool dark = prefs->getBool(
"/theme/darkTheme",
false);
1294 Glib::ustring markup;
1297 markup =
"<span font-weight='bold'>";
1300 std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(
"\\s*,\\s*", family);
1301 for (
auto const &token : tokens) {
1305 markup += g_markup_escape_text(token.c_str(), -1);
1309 markup +=
"<span strikethrough='true' strikethrough_color='salmon'>";
1311 markup +=
"<span strikethrough='true' strikethrough_color='red'>";
1313 markup += g_markup_escape_text(token.c_str(), -1);
1314 markup +=
"</span>";
1319 if (markup.size() >= 2) {
1320 markup.resize(markup.size() - 2);
1322 markup +=
"</span>";
1325 markup = family_escaped;
1328 int show_sample = prefs->getInt(
"/tools/text/show_sample_in_list", 1);
1330 Glib::ustring sample = prefs->getString(
"/tools/text/font_sample");
1331 gchar* sample_escaped = g_markup_escape_text(sample.data(), -1);
1333 markup +=
" <span alpha='55%";
1334#if PANGO_VERSION_CHECK(1,50,0)
1335 markup +=
"' font-size='100%' line-height='0.6' font_family='";
1337 markup +=
"' font_family='";
1339 markup += family_escaped;
1341 markup +=
" <span alpha='1";
1344 markup += sample_escaped;
1345 markup +=
"</span>";
1346 g_free(sample_escaped);
1349 cell.set_property(
"markup", markup);
1350 g_free(family_escaped);
1355 Gtk::TreeModel::const_iterator
const &iter)
1358 auto const &row = *iter;
1363 Glib::ustring style_escaped = Glib::Markup::escape_text( style );
1364 Glib::ustring font_desc = family +
", " + style;
1365 Glib::ustring markup;
1367 markup =
"<span font='" + font_desc +
"'>" + style_escaped +
"</span>";
1370 renderer->set_property(
"markup", markup);
_PangoFontDescription PangoFontDescription
double distance(Shape const *s, Geom::Point const &p)
std::shared_ptr< FontInstance > Face(PangoFontDescription *descr, bool canFail=true)
void refreshConfig()
The fontsize used as workaround for hinting.
std::map< std::string, PangoFontFamily * > GetUIFamilies()
std::set< Glib::ustring > const & get_fonts() const
static DocumentFonts * get()
static FontCollections * get()
void clear_selected_collections()
std::set< Glib::ustring > const & get_fonts(Glib::ustring const &name, bool is_system=false) const
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.
std::pair< bool, std::string > get_font_count_label() const
void insert_font_family(Glib::ustring const &new_family)
Inserts a font family or font-fallback list (for use when not already in document or on system).
bool find_string_case_insensitive(std::string const &text, std::string const &pat)
Takes a hand written font spec and returns a Pango generated one in standard form.
int get_font_families_size() const
void init_default_styles()
Glib::RefPtr< Gtk::ListStore > style_list_store
Glib::RefPtr< Gtk::ListStore > font_list_store
std::shared_ptr< Styles > default_styles
If a font-family is not on system, this list of styles is used.
std::vector< StyleNames > Styles
sigc::signal< void()> new_fonts_signal
std::map< std::string, PangoFontFamily * > pango_family_map
The list of fonts, sorted by the order they will appear in the UI.
void init_font_families(int group_offset=-1, int group_size=-1)
int add_document_fonts_at_top(SPDocument *document)
bool font_installed_on_system(Glib::ustring const &font) const
void show_results(Glib::ustring const &search_text)
static Inkscape::FontLister * get_instance()
FontStyleListClass font_style_list
Glib::ustring const & get_font_family() const
sigc::signal< void()> update_signal
Preference storage class.
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
Glib::ustring getString(Glib::ustring const &pref_path, Glib::ustring const &def="")
Retrieve an UTF-8 string.
static Preferences * get()
Access the singleton Preferences object.
int getInt(Glib::ustring const &pref_path, int def=0)
Retrieve an integer.
static RecentlyUsedFonts * get()
std::list< Glib::ustring > const & get_fonts() const
static FontFactory & get(Args &&... args)
virtual NodeType type() const =0
Get the type of the node.
Typed SVG document implementation.
SPRoot * getRoot()
Returns our SPRoot.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
char const * getId() const
Returns the objects current ID string.
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
void mergeCSS(SPCSSAttr *css)
T< SPAttr::INKSCAPE_FONT_SPEC, SPIString > font_specification
Full font name, as FontFactory::ConstructFontSpecification would give, for internal use.
void readFromPrefs(Glib::ustring const &path)
Read style properties from preferences.
std::shared_ptr< Css const > css
SPCSSAttr * sp_desktop_get_style(SPDesktop *desktop, bool with_text)
Return the desktop's current style.
int sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property)
Query the subselection (if any) or selection on the given desktop for the given property,...
@ QUERY_STYLE_PROPERTY_FONT_SPECIFICATION
@ QUERY_STYLE_PROPERTY_FONTSTYLE
@ QUERY_STYLE_PROPERTY_FONTFAMILY
Editable view implementation.
PangoFontDescription * ink_font_description_from_style(SPStyle const *style)
char const * sp_font_description_get_family(PangoFontDescription const *fontDescr)
TODO: insert short description here.
The data describing a single loaded font.
bool font_lister_separator_func(Glib::RefPtr< Gtk::TreeModel > const &, Gtk::TreeModel::const_iterator const &iter)
bool familyNamesAreEqual(const Glib::ustring &a, const Glib::ustring &b)
void font_lister_cell_data_func_markup(Gtk::CellRenderer *const renderer, Gtk::TreeModel::const_iterator const &iter)
void font_lister_cell_data_func(Gtk::CellRenderer *, Gtk::TreeModel::const_iterator const &)
void font_lister_style_cell_data_func(Gtk::CellRenderer *const renderer, Gtk::TreeModel::const_iterator const &iter)
void font_lister_cell_data_func2(Gtk::CellRenderer &cell, Gtk::TreeModel::const_iterator const &iter, bool with_markup)
@ TEXT_NODE
Text node, e.g. "Some text" in <group>Some text</group> is represented by a text node.
Helper class to stream background task notifications as a series of messages.
static int compute_distance(PangoFontDescription const *a, PangoFontDescription const *b)
Glib::ustring get_fontspec(const Glib::ustring &family, const Glib::ustring &face, const Glib::ustring &variations)
gboolean font_description_better_match(PangoFontDescription *target, PangoFontDescription *old_desc, PangoFontDescription *new_desc)
const std::string DOCUMENT_FONTS
const std::string RECENTLY_USED_FONTS
Singleton class to access the preferences file in a convenient way.
void sp_repr_css_unset_property(SPCSSAttr *css, gchar const *name)
Set a style property to "inkscape:unset".
void sp_repr_css_set_property(SPCSSAttr *css, gchar const *name, gchar const *value)
Set a style property to a new value (e.g.
C facade to Inkscape::XML::Node.
TODO: insert short description here.
TODO: insert short description here.
SPRoot: SVG <svg> implementation.
TODO: insert short description here.
SVG <tref> implementation, see sp-tref.cpp.
TODO: insert short description here.
Gtk::TreeModelColumn< std::shared_ptr< Styles > > styles
Styles for each family name.
Gtk::TreeModelColumn< Glib::ustring > family
Family name.
Gtk::TreeModelColumn< PangoFontFamily * > pango_family
Not actually a column.
Gtk::TreeModelColumn< bool > onSystem
Whether font is on system.
Gtk::TreeModelColumn< Glib::ustring > cssStyle
Column containing the styles in CSS/Pango format.
Gtk::TreeModelColumn< Glib::ustring > displayStyle
Column containing the styles as Font designer used.
void css_quote(Glib::ustring &val)
Quote and/or escape string for writing to CSS, changing strings in place.
void css_font_family_quote(Glib::ustring &val)
Quote font names in font-family lists, changing string in place.