diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2014-09-29 13:57:21 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2014-09-29 13:57:21 +0000 |
| commit | 3c73700a91c6dc1561b3b70dcdc0c051d23405d3 (patch) | |
| tree | 1f1645104f52d5f4b95714a2611384346de70388 /src | |
| parent | Quick fix to unbreak build from last check in. (diff) | |
| download | inkscape-3c73700a91c6dc1561b3b70dcdc0c051d23405d3.tar.gz inkscape-3c73700a91c6dc1561b3b70dcdc0c051d23405d3.zip | |
Remove NRTypePosDef class and associated cruft. More direct CSS -> Pango translation.
(bzr r13569)
Diffstat (limited to 'src')
| -rw-r--r-- | src/desktop-style.cpp | 6 | ||||
| -rw-r--r-- | src/libnrtype/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/libnrtype/FontFactory.cpp | 196 | ||||
| -rw-r--r-- | src/libnrtype/FontFactory.h | 3 | ||||
| -rw-r--r-- | src/libnrtype/Makefile_insert | 4 | ||||
| -rw-r--r-- | src/libnrtype/font-style-to-pos.cpp | 120 | ||||
| -rw-r--r-- | src/libnrtype/font-style-to-pos.h | 21 | ||||
| -rw-r--r-- | src/libnrtype/nr-type-pos-def.cpp | 272 | ||||
| -rw-r--r-- | src/libnrtype/nr-type-pos-def.h | 103 | ||||
| -rw-r--r-- | src/sp-text.cpp | 1 | ||||
| -rw-r--r-- | src/ui/dialog/text-edit.cpp | 1 |
11 files changed, 130 insertions, 601 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index bfd662c9a..0b2e15d34 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -40,7 +40,6 @@ #include "sp-tspan.h" #include "xml/repr.h" #include "xml/sp-css-attr.h" -#include "libnrtype/font-style-to-pos.h" #include "sp-path.h" #include "ui/tools/tool-base.h" @@ -1098,7 +1097,10 @@ objects_query_fontstyle (GSList *objects, SPStyle *style_res) texts ++; if (set && - font_style_to_pos(*style_res).signature() != font_style_to_pos(*style).signature() ) { + ( ( style_res->font_weight.computed != style->font_weight.computed ) || + ( style_res->font_style.computed != style->font_style.computed ) || + ( style_res->font_stretch.computed != style->font_stretch.computed ) || + ( style_res->font_variant.computed != style->font_variant.computed ) ) ) { different = true; // different styles } diff --git a/src/libnrtype/CMakeLists.txt b/src/libnrtype/CMakeLists.txt index 84979d7ea..05fd01a03 100644 --- a/src/libnrtype/CMakeLists.txt +++ b/src/libnrtype/CMakeLists.txt @@ -3,14 +3,12 @@ set(nrtype_SRC FontFactory.cpp FontInstance.cpp font-lister.cpp - font-style-to-pos.cpp Layout-TNG.cpp Layout-TNG-Compute.cpp Layout-TNG-Input.cpp Layout-TNG-OutIter.cpp Layout-TNG-Output.cpp Layout-TNG-Scanline-Makers.cpp - nr-type-pos-def.cpp nr-type-primitives.cpp TextWrapper.cpp @@ -25,9 +23,7 @@ set(nrtype_SRC font-glyph.h font-instance.h font-lister.h - font-style-to-pos.h font-style.h - nr-type-pos-def.h nr-type-primitives.h one-box.h one-glyph.h diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 2b7e1fa0c..fa452dd77 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -636,9 +636,133 @@ font_instance* font_factory::FaceFromStyle(SPStyle const *style) // If that failed, try using the CSS information in the style if (!font) { - font = Face(style->font_family.value, font_style_to_pos(*style)); + PangoFontDescription *temp_descr = pango_font_description_new(); - // That was a hatchet job... so we need to check if this font exists!! + pango_font_description_set_family(temp_descr, style->font_family.value); + + // This duplicates Layout::EnumConversionItem... perhaps we can share code? + switch ( style->font_style.computed ) { + case SP_CSS_FONT_STYLE_ITALIC: + pango_font_description_set_style(temp_descr, PANGO_STYLE_ITALIC); + break; + + case SP_CSS_FONT_STYLE_OBLIQUE: + pango_font_description_set_style(temp_descr, PANGO_STYLE_OBLIQUE); + break; + + case SP_CSS_FONT_STYLE_NORMAL: + default: + pango_font_description_set_style(temp_descr, PANGO_STYLE_NORMAL); + break; + } + + switch( style->font_weight.computed ) { + case SP_CSS_FONT_WEIGHT_100: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_THIN); + break; + + case SP_CSS_FONT_WEIGHT_200: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_ULTRALIGHT); + break; + + case SP_CSS_FONT_WEIGHT_300: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_LIGHT); + break; + + case SP_CSS_FONT_WEIGHT_400: + case SP_CSS_FONT_WEIGHT_NORMAL: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_NORMAL); + break; + + case SP_CSS_FONT_WEIGHT_500: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_MEDIUM); + break; + + case SP_CSS_FONT_WEIGHT_600: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_SEMIBOLD); + break; + + case SP_CSS_FONT_WEIGHT_700: + case SP_CSS_FONT_WEIGHT_BOLD: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_BOLD); + break; + + case SP_CSS_FONT_WEIGHT_800: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_ULTRABOLD); + break; + + case SP_CSS_FONT_WEIGHT_900: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_HEAVY); + break; + + case SP_CSS_FONT_WEIGHT_LIGHTER: + case SP_CSS_FONT_WEIGHT_BOLDER: + default: + g_warning("FaceFromStyle: Unrecognized font_weight.computed value"); + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_NORMAL); + break; + } + // PANGO_WIEGHT_ULTRAHEAVY not used (not CSS2) + + switch (style->font_stretch.computed) { + case SP_CSS_FONT_STRETCH_ULTRA_CONDENSED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_ULTRA_CONDENSED); + break; + + case SP_CSS_FONT_STRETCH_EXTRA_CONDENSED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_EXTRA_CONDENSED); + break; + + case SP_CSS_FONT_STRETCH_CONDENSED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_CONDENSED); + break; + + case SP_CSS_FONT_STRETCH_SEMI_CONDENSED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_SEMI_CONDENSED); + break; + + case SP_CSS_FONT_STRETCH_NORMAL: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_NORMAL); + break; + + case SP_CSS_FONT_STRETCH_SEMI_EXPANDED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_SEMI_EXPANDED); + break; + + case SP_CSS_FONT_STRETCH_EXPANDED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_EXPANDED); + break; + + case SP_CSS_FONT_STRETCH_EXTRA_EXPANDED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_EXTRA_EXPANDED); + break; + + case SP_CSS_FONT_STRETCH_ULTRA_EXPANDED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_ULTRA_EXPANDED); + + case SP_CSS_FONT_STRETCH_WIDER: + case SP_CSS_FONT_STRETCH_NARROWER: + default: + g_warning("FaceFromStyle: Unrecognized font_stretch.computed value"); + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_NORMAL); + break; + } + + switch ( style->font_variant.computed ) { + case SP_CSS_FONT_VARIANT_SMALL_CAPS: + pango_font_description_set_variant(temp_descr, PANGO_VARIANT_SMALL_CAPS); + break; + + case SP_CSS_FONT_VARIANT_NORMAL: + default: + pango_font_description_set_variant(temp_descr, PANGO_VARIANT_NORMAL); + break; + } + + font = Face(temp_descr); + pango_font_description_free(temp_descr); + + // We now find closest match to this font: Glib::ustring fontSpec = font_factory::Default()->ConstructFontSpecification(font); Glib::ustring newFontSpec = FontSpecificationBestMatch( fontSpec ); if( fontSpec != newFontSpec ) { @@ -831,74 +955,6 @@ font_instance *font_factory::Face(char const *family, int variant, int style, in return res; } -font_instance *font_factory::Face(char const *family, NRTypePosDef apos) -{ - PangoFontDescription *temp_descr = pango_font_description_new(); - - pango_font_description_set_family(temp_descr, family); - - if ( apos.variant == NR_POS_VARIANT_SMALLCAPS ) { - pango_font_description_set_variant(temp_descr, PANGO_VARIANT_SMALL_CAPS); - } else { - pango_font_description_set_variant(temp_descr, PANGO_VARIANT_NORMAL); - } - - if ( apos.italic ) { - pango_font_description_set_style(temp_descr, PANGO_STYLE_ITALIC); - } else if ( apos.oblique ) { - pango_font_description_set_style(temp_descr, PANGO_STYLE_OBLIQUE); - } else { - pango_font_description_set_style(temp_descr, PANGO_STYLE_NORMAL); - } - - if ( apos.weight <= NR_POS_WEIGHT_THIN ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_THIN); - } else if ( apos.weight <= NR_POS_WEIGHT_ULTRA_LIGHT ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_ULTRALIGHT); - } else if ( apos.weight <= NR_POS_WEIGHT_LIGHT ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_LIGHT); -#if PANGO_VERSION_CHECK(1,36,6) - } else if ( apos.weight <= NR_POS_WEIGHT_SEMILIGHT ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_SEMILIGHT); -#endif - } else if ( apos.weight <= NR_POS_WEIGHT_BOOK ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_BOOK); - } else if ( apos.weight <= NR_POS_WEIGHT_NORMAL ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_NORMAL); - } else if ( apos.weight <= NR_POS_WEIGHT_MEDIUM ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_MEDIUM); - } else if ( apos.weight <= NR_POS_WEIGHT_SEMIBOLD ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_SEMIBOLD); - } else if ( apos.weight <= NR_POS_WEIGHT_BOLD ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_BOLD); - } else if ( apos.weight <= NR_POS_WEIGHT_ULTRA_BOLD ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_ULTRABOLD); - } else { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_HEAVY); - } - // PANGO_WIEGHT_ULTRAHEAVY not used (not CSS2) - - if ( apos.stretch <= NR_POS_STRETCH_ULTRA_CONDENSED ) { - pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_EXTRA_CONDENSED); - } else if ( apos.stretch <= NR_POS_STRETCH_CONDENSED ) { - pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_CONDENSED); - } else if ( apos.stretch <= NR_POS_STRETCH_SEMI_CONDENSED ) { - pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_SEMI_CONDENSED); - } else if ( apos.stretch <= NR_POS_STRETCH_NORMAL ) { - pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_NORMAL); - } else if ( apos.stretch <= NR_POS_STRETCH_SEMI_EXPANDED ) { - pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_SEMI_EXPANDED); - } else if ( apos.stretch <= NR_POS_STRETCH_EXPANDED ) { - pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_EXPANDED); - } else { - pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_EXTRA_EXPANDED); - } - - font_instance *res = Face(temp_descr); - pango_font_description_free(temp_descr); - return res; -} - void font_factory::UnrefFace(font_instance *who) { if ( who ) { diff --git a/src/libnrtype/FontFactory.h b/src/libnrtype/FontFactory.h index 513ee4bf7..bb3a8fa25 100644 --- a/src/libnrtype/FontFactory.h +++ b/src/libnrtype/FontFactory.h @@ -21,8 +21,6 @@ #include <pango/pango.h> #include "nr-type-primitives.h" -#include "nr-type-pos-def.h" -#include "font-style-to-pos.h" #include "../style.h" /* Freetype */ @@ -138,7 +136,6 @@ public: int variant=PANGO_VARIANT_NORMAL, int style=PANGO_STYLE_NORMAL, int weight=PANGO_WEIGHT_NORMAL, int stretch=PANGO_STRETCH_NORMAL, int size=10, int spacing=0); - font_instance* Face(char const *family, NRTypePosDef apos); /// Semi-private: tells the font_factory taht the font_instance 'who' has died and should be removed from loadedFaces void UnrefFace(font_instance* who); diff --git a/src/libnrtype/Makefile_insert b/src/libnrtype/Makefile_insert index 0ce8f1fd5..ab9465daa 100644 --- a/src/libnrtype/Makefile_insert +++ b/src/libnrtype/Makefile_insert @@ -2,13 +2,9 @@ ink_common_sources += \ libnrtype/boundary-type.h \ - libnrtype/font-style-to-pos.cpp \ - libnrtype/font-style-to-pos.h \ libnrtype/font-glyph.h \ libnrtype/font-instance.h \ libnrtype/font-style.h \ - libnrtype/nr-type-pos-def.cpp \ - libnrtype/nr-type-pos-def.h \ libnrtype/nr-type-primitives.cpp \ libnrtype/nr-type-primitives.h \ libnrtype/FontFactory.cpp \ diff --git a/src/libnrtype/font-style-to-pos.cpp b/src/libnrtype/font-style-to-pos.cpp deleted file mode 100644 index 02f5ef37c..000000000 --- a/src/libnrtype/font-style-to-pos.cpp +++ /dev/null @@ -1,120 +0,0 @@ -#include "font-style-to-pos.h" -#include <style.h> - -/* 'lighter' and 'darker' have to be resolved earlier */ -/** -Given a style struct (CSS representation), sets the corresponding fields in a NRTypePosDef. - */ -NRTypePosDef -font_style_to_pos (SPStyle const &style) -{ - NRTypePosDef ret; - - switch (style.font_weight.computed) { - case SP_CSS_FONT_WEIGHT_100: - ret.weight = NR_POS_WEIGHT_CSS100; - break; - - case SP_CSS_FONT_WEIGHT_200: - ret.weight = NR_POS_WEIGHT_CSS200; - break; - - case SP_CSS_FONT_WEIGHT_300: - ret.weight = NR_POS_WEIGHT_CSS300; - break; - - case SP_CSS_FONT_WEIGHT_400: - case SP_CSS_FONT_WEIGHT_NORMAL: - ret.weight = NR_POS_WEIGHT_CSS400; - break; - - case SP_CSS_FONT_WEIGHT_500: - ret.weight = NR_POS_WEIGHT_CSS500; - break; - - case SP_CSS_FONT_WEIGHT_600: - ret.weight = NR_POS_WEIGHT_CSS600; - break; - - case SP_CSS_FONT_WEIGHT_700: - case SP_CSS_FONT_WEIGHT_BOLD: - ret.weight = NR_POS_WEIGHT_CSS700; - break; - - case SP_CSS_FONT_WEIGHT_800: - ret.weight = NR_POS_WEIGHT_CSS800; - break; - - case SP_CSS_FONT_WEIGHT_900: - ret.weight = NR_POS_WEIGHT_CSS900; - break; - - case SP_CSS_FONT_WEIGHT_LIGHTER: - case SP_CSS_FONT_WEIGHT_BOLDER: - default: - g_warning("Unrecognized font_weight.computed value"); - ret.weight = NR_POS_WEIGHT_NORMAL; - break; - } - - switch (style.font_style.computed) { - case SP_CSS_FONT_STYLE_ITALIC: - ret.italic = 1; - break; - - case SP_CSS_FONT_STYLE_OBLIQUE: - ret.oblique = 1; - break; - - case SP_CSS_FONT_STYLE_NORMAL: - default: - ret.italic = 0; - ret.oblique = 0; - break; - } - - switch (style.font_stretch.computed) { - case SP_CSS_FONT_STRETCH_ULTRA_CONDENSED: - case SP_CSS_FONT_STRETCH_EXTRA_CONDENSED: - ret.stretch = NR_POS_STRETCH_EXTRA_CONDENSED; - break; - - case SP_CSS_FONT_STRETCH_CONDENSED: - case SP_CSS_FONT_STRETCH_NARROWER: - ret.stretch = NR_POS_STRETCH_CONDENSED; - break; - - case SP_CSS_FONT_STRETCH_SEMI_CONDENSED: - ret.stretch = NR_POS_STRETCH_SEMI_CONDENSED; - break; - - case SP_CSS_FONT_STRETCH_SEMI_EXPANDED: - ret.stretch = NR_POS_STRETCH_SEMI_EXPANDED; - break; - - case SP_CSS_FONT_STRETCH_EXPANDED: - case SP_CSS_FONT_STRETCH_WIDER: - ret.stretch = NR_POS_STRETCH_EXPANDED; - break; - - case SP_CSS_FONT_STRETCH_EXTRA_EXPANDED: - case SP_CSS_FONT_STRETCH_ULTRA_EXPANDED: - ret.stretch = NR_POS_STRETCH_EXTRA_EXPANDED; - break; - - default: - ret.stretch = NR_POS_STRETCH_NORMAL; - break; - } - - switch (style.font_variant.computed) { - case SP_CSS_FONT_VARIANT_SMALL_CAPS: - ret.variant = NR_POS_VARIANT_SMALLCAPS; - break; - default: - ret.variant = NR_POS_VARIANT_NORMAL; - break; - } - - return ret; -} diff --git a/src/libnrtype/font-style-to-pos.h b/src/libnrtype/font-style-to-pos.h deleted file mode 100644 index 41ba6cf72..000000000 --- a/src/libnrtype/font-style-to-pos.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef SEEN_FONT_STYLE_TO_POS_H -#define SEEN_FONT_STYLE_TO_POS_H - -#include <libnrtype/nr-type-pos-def.h> - -class SPStyle; - -NRTypePosDef font_style_to_pos(SPStyle const &style); - -#endif // SEEN_FONT_STYLE_TO_POS_H - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnrtype/nr-type-pos-def.cpp b/src/libnrtype/nr-type-pos-def.cpp deleted file mode 100644 index ff633d5f1..000000000 --- a/src/libnrtype/nr-type-pos-def.cpp +++ /dev/null @@ -1,272 +0,0 @@ -#include "nr-type-pos-def.h" -#include <glib.h> -#include <string.h> - -/** - * Given a font name or style name, returns a constant describing its - * apparent style (normal/italic/oblique). -*/ -int -parse_name_for_style (char const *cc) -{ - g_assert ( cc != NULL ); - gchar *c = g_ascii_strdown (cc, -1); - - gint style; - // first dab at i18n... french and german - if (strstr (c, "italic") || strstr (c, "italique") || strstr (c, "kursiv")) { - style = NR_POS_STYLE_ITALIC; - } else if (strstr (c, "oblique")) { - style = NR_POS_STYLE_OBLIQUE; - } else { - style = NR_POS_STYLE_NORMAL; - } - - g_free (c); - return style; -} - - -/** - * Given a font name or style name, returns a constant describing its - * apparent weight. -*/ -int -parse_name_for_weight (char const *cc) -{ - g_assert ( cc != NULL ); - gchar *c = g_ascii_strdown (cc, -1); - - gint weight; - if (strstr (c, "thin")) { - weight = NR_POS_WEIGHT_THIN; - } else if (strstr (c, "extra light")) { - weight = NR_POS_WEIGHT_EXTRA_LIGHT; - } else if (strstr (c, "ultra light")) { - weight = NR_POS_WEIGHT_ULTRA_LIGHT; - } else if (strstr (c, "light")) { - weight = NR_POS_WEIGHT_LIGHT; - } else if (strstr (c, "semi light")) { - weight = NR_POS_WEIGHT_SEMILIGHT; - } else if (strstr (c, "semilight")) { - weight = NR_POS_WEIGHT_SEMILIGHT; - } else if (strstr (c, "book")) { - weight = NR_POS_WEIGHT_BOOK; - } else if (strstr (c, "medium")) { - weight = NR_POS_WEIGHT_MEDIUM; - } else if (strstr (c, "semi bold")) { - weight = NR_POS_WEIGHT_SEMIBOLD; - } else if (strstr (c, "semibold")) { - weight = NR_POS_WEIGHT_SEMIBOLD; - } else if (strstr (c, "demi bold")) { - weight = NR_POS_WEIGHT_DEMIBOLD; - } else if (strstr (c, "demibold") || strstr (c, "demi")) { - weight = NR_POS_WEIGHT_DEMIBOLD; - } else if (strstr (c, "ultra bold")) { - weight = NR_POS_WEIGHT_ULTRA_BOLD; - } else if (strstr (c, "extra bold") || strstr (c, "xbold") || strstr (c, "xtrabold")) { - weight = NR_POS_WEIGHT_EXTRA_BOLD; - } else if (strstr (c, "black") || strstr (c, "heavy")) { - weight = NR_POS_WEIGHT_BLACK; - } else if (strstr (c, "bold")) { - /* Must come after the checks for `blah bold'. */ - weight = NR_POS_WEIGHT_BOLD; - } else { - weight = NR_POS_WEIGHT_NORMAL; - } - - g_free (c); - return weight; -} - -/** - * Given a font name or style name, returns a constant describing its - * apparent stretch. -*/ -int -parse_name_for_stretch (char const *cc) -{ - g_assert ( cc != NULL ); - gchar *c = g_ascii_strdown (cc, -1); - - gint stretch; - if (strstr (c, "ultra narrow") || strstr (c, "ultra condensed") || strstr (c, "extra condensed")) { - stretch = NR_POS_STRETCH_EXTRA_CONDENSED; - } else if (strstr (c, "ultra wide") || strstr (c, "ultra expanded") || strstr (c, "ultra extended") || strstr (c, "extra expanded")) { - stretch = NR_POS_STRETCH_EXTRA_EXPANDED; - } else if (strstr (c, "semi condensed") || strstr (c, "semicondensed")) { - stretch = NR_POS_STRETCH_SEMI_CONDENSED; - } else if (strstr (c, "semi extended") || strstr (c, "semiextended")) { - stretch = NR_POS_STRETCH_SEMI_EXPANDED; - } else if (strstr (c, "narrow") || strstr (c, "condensed")) { - stretch = NR_POS_STRETCH_CONDENSED; - } else if (strstr (c, "wide") || strstr (c, "expanded") || strstr (c, "extended")) { - stretch = NR_POS_STRETCH_EXPANDED; - } else { - stretch = NR_POS_STRETCH_NORMAL; - } - - g_free (c); - return stretch; -} - -/** - * Given a font name or style name, returns a constant describing its - * apparent variant (normal/smallcaps). -*/ -int -parse_name_for_variant (char const *cc) -{ - g_assert ( cc != NULL ); - gchar *c = g_ascii_strdown (cc, -1); - - gint variant; - if (strstr (c, "small caps") || strstr (c, "smallcaps") || strstr (c, "caps")) { - variant = NR_POS_VARIANT_SMALLCAPS; - } else { - variant = NR_POS_VARIANT_NORMAL; - } - - g_free (c); - return variant; -} - -/** - * Given a style constant, returns the CSS value for font-style. -*/ -const char * -style_to_css (int style) -{ - switch (style) { - case NR_POS_STYLE_NORMAL: - return "normal"; - break; - case NR_POS_STYLE_ITALIC: - return "italic"; - break; - case NR_POS_STYLE_OBLIQUE: - return "oblique"; - break; - default: - break; - } - return NULL; -} - - -/** - * Given a weight constant, returns the CSS value for font-weight. -*/ -const char * -weight_to_css (int weight) -{ - switch (weight) { - case NR_POS_WEIGHT_THIN: - return "100"; - break; - case NR_POS_WEIGHT_EXTRA_LIGHT: - return "200"; - break; - case NR_POS_WEIGHT_LIGHT: - return "300"; - break; - case NR_POS_WEIGHT_BOOK: - return "normal"; - break; - case NR_POS_WEIGHT_MEDIUM: - return "500"; - break; - case NR_POS_WEIGHT_SEMIBOLD: - return "600"; - break; - case NR_POS_WEIGHT_BOLD: - return "bold"; - break; - case NR_POS_WEIGHT_EXTRA_BOLD: - return "800"; - break; - case NR_POS_WEIGHT_BLACK: - return "900"; - break; - default: - break; - } - return NULL; -} - -/** - * Given a stretch constant, returns the CSS value for font-stretch. -*/ -const char * -stretch_to_css (int stretch) -{ - switch (stretch) { - case NR_POS_STRETCH_EXTRA_CONDENSED: - return "extra-condensed"; - break; - case NR_POS_STRETCH_CONDENSED: - return "condensed"; - break; - case NR_POS_STRETCH_SEMI_CONDENSED: - return "semi-condensed"; - break; - case NR_POS_STRETCH_NORMAL: - return "normal"; - break; - case NR_POS_STRETCH_SEMI_EXPANDED: - return "semi-expanded"; - break; - case NR_POS_STRETCH_EXPANDED: - return "expanded"; - break; - case NR_POS_STRETCH_EXTRA_EXPANDED: - return "extra-expanded"; - break; - default: - break; - } - return NULL; -} - -/** - * Given a variant constant, returns the CSS value for font-variant. -*/ -const char * -variant_to_css (int stretch) -{ - switch (stretch) { - case NR_POS_VARIANT_SMALLCAPS: - return "small-caps"; - break; - case NR_POS_VARIANT_NORMAL: - return "normal"; - break; - default: - break; - } - return NULL; -} - - -/** - * Constructor for NRTypePostDef. Sets the italic, oblique, weight, - * stretch, and variant. - */ -NRTypePosDef::NRTypePosDef(char const *description) { - // we cannot use strcasestr, it's linux only... so we must lowercase the string first - g_assert ( description != NULL ); - gchar *c = g_ascii_strdown (description, -1); - - /* copied from nr-type-directory.cpp:nr_type_calculate_position. */ - - italic = (strstr (c, "italic") != NULL); - oblique = (strstr (c, "oblique") != NULL); - - weight = parse_name_for_weight (c); - - stretch = parse_name_for_stretch (c); - - variant = parse_name_for_variant (c); - - g_free (c); -} diff --git a/src/libnrtype/nr-type-pos-def.h b/src/libnrtype/nr-type-pos-def.h deleted file mode 100644 index d4d412b21..000000000 --- a/src/libnrtype/nr-type-pos-def.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef __NR_TYPE_POS_DEF_H__ -#define __NR_TYPE_POS_DEF_H__ - -#define NR_POS_STYLE_NORMAL 0 -#define NR_POS_STYLE_ITALIC 1 -#define NR_POS_STYLE_OBLIQUE 2 - -#define NR_POS_WEIGHT_THIN 32 -#define NR_POS_WEIGHT_EXTRA_LIGHT 64 -#define NR_POS_WEIGHT_ULTRA_LIGHT 64 -#define NR_POS_WEIGHT_LIGHT 96 -#define NR_POS_WEIGHT_SEMILIGHT 96 -#define NR_POS_WEIGHT_BOOK 128 -#define NR_POS_WEIGHT_NORMAL 128 -#define NR_POS_WEIGHT_MEDIUM 144 -#define NR_POS_WEIGHT_SEMIBOLD 160 -#define NR_POS_WEIGHT_DEMIBOLD 160 -#define NR_POS_WEIGHT_BOLD 192 -#define NR_POS_WEIGHT_ULTRA_BOLD 224 -#define NR_POS_WEIGHT_EXTRA_BOLD 224 -#define NR_POS_WEIGHT_BLACK 255 - -#define NR_POS_STRETCH_ULTRA_CONDENSED 48 -#define NR_POS_STRETCH_EXTRA_CONDENSED 48 -#define NR_POS_STRETCH_CONDENSED 88 -#define NR_POS_STRETCH_SEMI_CONDENSED 108 -#define NR_POS_STRETCH_NORMAL 128 -#define NR_POS_STRETCH_SEMI_EXPANDED 148 -#define NR_POS_STRETCH_EXPANDED 168 -#define NR_POS_STRETCH_EXTRA_EXPANDED 228 -#define NR_POS_STRETCH_ULTRA_EXPANDED 228 - -// This is an enumerate, rather than on/off property, -// for I sincerely hope the vocabulary of this property will be -// extended by the W3C in the future to allow for more fancy fonts -#define NR_POS_VARIANT_NORMAL 0 -#define NR_POS_VARIANT_SMALLCAPS 1 - -/* Mapping from CSS weight numbers. - - for i in `seq 9`; do - if [ $i -le 4 ]; then w=$((32 * $i)); - elif [ $i = 5 ]; then w=144; - elif [ $i -lt 9 ]; then w=$((32 * $(($i - 1)))); - else w=255; - fi; - printf '#define NR_POS_WEIGHT_CSS%d00\t\t%3d\n' $i $w; - done - - This calculation approximately matches the old to-and-from-text code, - I don't claim it to be reasonable. ("approximately": some of the old - code wrote strings like "semi" and "heavy" that weren't being parsed - at the other end, and it had CSS100 darker than CSS200.) - */ -#define NR_POS_WEIGHT_CSS100 32 -#define NR_POS_WEIGHT_CSS200 64 -#define NR_POS_WEIGHT_CSS300 96 -#define NR_POS_WEIGHT_CSS400 128 -#define NR_POS_WEIGHT_CSS500 144 -#define NR_POS_WEIGHT_CSS600 160 -#define NR_POS_WEIGHT_CSS700 192 -#define NR_POS_WEIGHT_CSS800 224 -#define NR_POS_WEIGHT_CSS900 255 - - -class NRTypePosDef { -public: - unsigned int italic : 1; - unsigned int oblique : 1; - unsigned int weight : 8; - unsigned int stretch : 8; - unsigned int variant : 8; - /* These can probably be made sensible sizes rather than bitfields; for the moment we'll - keep the old definition. */ - -public: - NRTypePosDef() : - italic(0), - oblique(0), - weight(NR_POS_WEIGHT_NORMAL), - stretch(NR_POS_STRETCH_NORMAL), - variant(NR_POS_VARIANT_NORMAL) - { } - - NRTypePosDef(char const *description); - - bool signature() {return this->italic + - this->oblique * 255 + - this->weight * 255 * 255 + - this->stretch * 255 * 255 * 255 + - this->variant * 255 * 255 * 255 * 255;}; -}; - -int parse_name_for_style (char const *c); -int parse_name_for_weight (char const *c); -int parse_name_for_stretch (char const *c); -int parse_name_for_variant (char const *c); -const char *style_to_css (int style); -const char *weight_to_css (int weight); -const char *stretch_to_css (int stretch); -const char *variant_to_css (int variant); - -#endif /* __NR_TYPE_POS_DEF_H__ */ diff --git a/src/sp-text.cpp b/src/sp-text.cpp index ccc5adf59..23a3d26cd 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -30,7 +30,6 @@ #include <2geom/affine.h> #include <libnrtype/FontFactory.h> #include <libnrtype/font-instance.h> -#include <libnrtype/font-style-to-pos.h> #include <glibmm/i18n.h> #include "svg/svg.h" diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index c1ebb32e0..a00db1715 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -32,7 +32,6 @@ extern "C" { #include <gtkmm/stock.h> #include <libnrtype/font-instance.h> -#include <libnrtype/font-style-to-pos.h> #include <libnrtype/font-lister.h> #include <xml/repr.h> |
