summaryrefslogtreecommitdiffstats
path: root/src/libnrtype
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2018-03-14 19:29:37 +0000
committerTavmjong Bah <tavmjong@free.fr>2018-03-14 19:29:37 +0000
commit3e7d770728fdd3d3fae52c5c9cf1345a87bd9fe4 (patch)
tree467400e1a9ebad439ec7735a56aaa66388e34a96 /src/libnrtype
parentFix bug in operator= for SPIFontVariableSettings. (diff)
downloadinkscape-3e7d770728fdd3d3fae52c5c9cf1345a87bd9fe4.tar.gz
inkscape-3e7d770728fdd3d3fae52c5c9cf1345a87bd9fe4.zip
Remove duplicate code.
Diffstat (limited to 'src/libnrtype')
-rw-r--r--src/libnrtype/font-lister.cpp141
1 files changed, 6 insertions, 135 deletions
diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp
index ca15baa81..c3882fad2 100644
--- a/src/libnrtype/font-lister.cpp
+++ b/src/libnrtype/font-lister.cpp
@@ -735,146 +735,17 @@ void FontLister::fill_css(SPCSSAttr *css, Glib::ustring fontspec)
}
}
-// We do this ourselves as we can't rely on FontFactory.
+
Glib::ustring FontLister::fontspec_from_style(SPStyle *style)
{
- //std::cout << "FontLister:fontspec_from_style: " << std::endl;
-
- Glib::ustring fontspec;
- if (style) {
-
- // First try to use the font specification if it is set
- if (style->font_specification.set && style->font_specification.value && *style->font_specification.value) {
-
- fontspec = style->font_specification.value;
-
- } else {
-
- fontspec = style->font_family.value;
- fontspec += ",";
-
- // Use weight names as defined by Pango
- switch (style->font_weight.computed) {
-
- case SP_CSS_FONT_WEIGHT_100:
- fontspec += " Thin";
- break;
-
- case SP_CSS_FONT_WEIGHT_200:
- fontspec += " Ultra-Light";
- break;
-
- case SP_CSS_FONT_WEIGHT_300:
- fontspec += " Light";
- break;
-
- case SP_CSS_FONT_WEIGHT_400:
- case SP_CSS_FONT_WEIGHT_NORMAL:
- //fontspec += " normal";
- break;
-
- case SP_CSS_FONT_WEIGHT_500:
- fontspec += " Medium";
- break;
-
- case SP_CSS_FONT_WEIGHT_600:
- fontspec += " Semi-Bold";
- break;
-
- case SP_CSS_FONT_WEIGHT_700:
- case SP_CSS_FONT_WEIGHT_BOLD:
- fontspec += " Bold";
- break;
-
- case SP_CSS_FONT_WEIGHT_800:
- fontspec += " Ultra-Bold";
- break;
-
- case SP_CSS_FONT_WEIGHT_900:
- fontspec += " Heavy";
- break;
-
- case SP_CSS_FONT_WEIGHT_LIGHTER:
- case SP_CSS_FONT_WEIGHT_BOLDER:
- default:
- g_warning("Unrecognized font_weight.computed value");
- break;
- }
-
- switch (style->font_style.computed) {
- case SP_CSS_FONT_STYLE_ITALIC:
- fontspec += " italic";
- break;
-
- case SP_CSS_FONT_STYLE_OBLIQUE:
- fontspec += " oblique";
- break;
-
- case SP_CSS_FONT_STYLE_NORMAL:
- default:
- //fontspec += " normal";
- break;
- }
-
- switch (style->font_stretch.computed) {
-
- case SP_CSS_FONT_STRETCH_ULTRA_CONDENSED:
- fontspec += " ultra-condensed";
- break;
-
- case SP_CSS_FONT_STRETCH_EXTRA_CONDENSED:
- fontspec += " extra-condensed";
- break;
-
- case SP_CSS_FONT_STRETCH_CONDENSED:
- case SP_CSS_FONT_STRETCH_NARROWER:
- fontspec += " condensed";
- break;
-
- case SP_CSS_FONT_STRETCH_SEMI_CONDENSED:
- fontspec += " semi-condensed";
- break;
-
- case SP_CSS_FONT_STRETCH_NORMAL:
- //fontspec += " normal";
- break;
-
- case SP_CSS_FONT_STRETCH_SEMI_EXPANDED:
- fontspec += " semi-expanded";
- break;
-
- case SP_CSS_FONT_STRETCH_EXPANDED:
- case SP_CSS_FONT_STRETCH_WIDER:
- fontspec += " expanded";
- break;
-
- case SP_CSS_FONT_STRETCH_EXTRA_EXPANDED:
- fontspec += " extra-expanded";
- break;
-
- case SP_CSS_FONT_STRETCH_ULTRA_EXPANDED:
- fontspec += " ultra-expanded";
- break;
-
- default:
- //fontspec += " normal";
- break;
- }
-
- switch (style->font_variant.computed) {
+ PangoFontDescription* descr = ink_font_description_from_style( style );
+ Glib::ustring fontspec = pango_font_description_to_string( descr );
+ pango_font_description_free(descr);
- case SP_CSS_FONT_VARIANT_SMALL_CAPS:
- fontspec += "small-caps";
- break;
+ //std::cout << "FontLister:fontspec_from_style: " << fontspec << std::endl;
- default:
- //fontspec += "normal";
- break;
- }
- }
- }
- return canonize_fontspec(fontspec);
+ return fontspec;
}