summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2014-04-24 12:04:31 +0000
committertavmjong-free <tavmjong@free.fr>2014-04-24 12:04:31 +0000
commit67c3fc5586ae05506f75bb30fe46a071e20613d2 (patch)
tree8469b6ad6668ba9852930950833db245eb70da00 /src
parentAdd missing style-internal.cpp (diff)
downloadinkscape-67c3fc5586ae05506f75bb30fe46a071e20613d2.tar.gz
inkscape-67c3fc5586ae05506f75bb30fe46a071e20613d2.zip
Clean up of style code, removal of SPFontStyle. Step 2.
(bzr r13300)
Diffstat (limited to 'src')
-rw-r--r--src/desktop-style.cpp50
-rw-r--r--src/extension/internal/emf-print.cpp4
-rw-r--r--src/extension/internal/wmf-print.cpp4
-rw-r--r--src/libnrtype/FontFactory.cpp10
-rw-r--r--src/libnrtype/Layout-TNG-Input.cpp5
-rw-r--r--src/libnrtype/font-lister.cpp14
-rw-r--r--src/style-internal.cpp4
-rw-r--r--src/style-internal.h13
-rw-r--r--src/style.cpp28
-rw-r--r--src/style.h8
-rw-r--r--src/ui/dialog/font-substitution.cpp18
-rw-r--r--src/widgets/text-toolbar.cpp23
12 files changed, 80 insertions, 101 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index bab9635a9..a7097b4c9 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -1227,11 +1227,11 @@ objects_query_fontfamily (GSList *objects, SPStyle *style_res)
bool different = false;
int texts = 0;
- if (style_res->text->font_family.value) {
- g_free(style_res->text->font_family.value);
- style_res->text->font_family.value = NULL;
+ if (style_res->font_family.value) {
+ g_free(style_res->font_family.value);
+ style_res->font_family.value = NULL;
}
- style_res->text->font_family.set = FALSE;
+ style_res->font_family.set = FALSE;
for (GSList const *i = objects; i != NULL; i = i->next) {
SPObject *obj = SP_OBJECT (i->data);
@@ -1250,21 +1250,21 @@ objects_query_fontfamily (GSList *objects, SPStyle *style_res)
texts ++;
- if (style_res->text->font_family.value && style->text->font_family.value &&
- strcmp (style_res->text->font_family.value, style->text->font_family.value)) {
+ if (style_res->font_family.value && style->font_family.value &&
+ strcmp (style_res->font_family.value, style->font_family.value)) {
different = true; // different fonts
}
- if (style_res->text->font_family.value) {
- g_free(style_res->text->font_family.value);
- style_res->text->font_family.value = NULL;
+ if (style_res->font_family.value) {
+ g_free(style_res->font_family.value);
+ style_res->font_family.value = NULL;
}
- style_res->text->font_family.set = TRUE;
- style_res->text->font_family.value = g_strdup(style->text->font_family.value);
+ style_res->font_family.set = TRUE;
+ style_res->font_family.value = g_strdup(style->font_family.value);
}
- if (texts == 0 || !style_res->text->font_family.set) {
+ if (texts == 0 || !style_res->font_family.set) {
return QUERY_STYLE_NOTHING;
}
@@ -1285,11 +1285,11 @@ objects_query_fontspecification (GSList *objects, SPStyle *style_res)
bool different = false;
int texts = 0;
- if (style_res->text->font_specification.value) {
- g_free(style_res->text->font_specification.value);
- style_res->text->font_specification.value = NULL;
+ if (style_res->font_specification.value) {
+ g_free(style_res->font_specification.value);
+ style_res->font_specification.value = NULL;
}
- style_res->text->font_specification.set = FALSE;
+ style_res->font_specification.set = FALSE;
for (GSList const *i = objects; i != NULL; i = i->next) {
SPObject *obj = SP_OBJECT (i->data);
@@ -1308,21 +1308,21 @@ objects_query_fontspecification (GSList *objects, SPStyle *style_res)
texts ++;
- if (style_res->text->font_specification.value && style_res->text->font_specification.set &&
- style->text->font_specification.value && style->text->font_specification.set &&
- strcmp (style_res->text->font_specification.value, style->text->font_specification.value)) {
+ if (style_res->font_specification.value && style_res->font_specification.set &&
+ style->font_specification.value && style->font_specification.set &&
+ strcmp (style_res->font_specification.value, style->font_specification.value)) {
different = true; // different fonts
}
- if (style->text->font_specification.set) {
+ if (style->font_specification.set) {
- if (style_res->text->font_specification.value) {
- g_free(style_res->text->font_specification.value);
- style_res->text->font_specification.value = NULL;
+ if (style_res->font_specification.value) {
+ g_free(style_res->font_specification.value);
+ style_res->font_specification.value = NULL;
}
- style_res->text->font_specification.set = TRUE;
- style_res->text->font_specification.value = g_strdup(style->text->font_specification.value);
+ style_res->font_specification.set = TRUE;
+ style_res->font_specification.value = g_strdup(style->font_specification.value);
}
}
diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp
index f4f7f08cb..8b80fec1c 100644
--- a/src/extension/internal/emf-print.cpp
+++ b/src/extension/internal/emf-print.cpp
@@ -1869,7 +1869,7 @@ unsigned int PrintEmf::text(Inkscape::Extension::Print * /*mod*/, char const *te
_lookup_ppt_fontfix("Convert To Wingdings", params);
break;
default: //also CVTNON
- _lookup_ppt_fontfix(style->text->font_family.value, params);
+ _lookup_ppt_fontfix(style->font_family.value, params);
break;
}
if (params.f2 != 0 || params.f3 != 0) {
@@ -1897,7 +1897,7 @@ unsigned int PrintEmf::text(Inkscape::Extension::Print * /*mod*/, char const *te
// of the special fonts.
uint16_t *wfacename;
if (!newfont) {
- wfacename = U_Utf8ToUtf16le(style->text->font_family.value, 0, NULL);
+ wfacename = U_Utf8ToUtf16le(style->font_family.value, 0, NULL);
} else {
wfacename = U_Utf8ToUtf16le(FontName(newfont), 0, NULL);
}
diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp
index 5a552ad83..55ad5da5f 100644
--- a/src/extension/internal/wmf-print.cpp
+++ b/src/extension/internal/wmf-print.cpp
@@ -1387,7 +1387,7 @@ unsigned int PrintWmf::text(Inkscape::Extension::Print * /*mod*/, char const *te
_lookup_ppt_fontfix("Convert To Wingdings", params);
break;
default: //also CVTNON
- _lookup_ppt_fontfix(style->text->font_family.value, params);
+ _lookup_ppt_fontfix(style->font_family.value, params);
break;
}
if (params.f2 != 0 || params.f3 != 0) {
@@ -1416,7 +1416,7 @@ unsigned int PrintWmf::text(Inkscape::Extension::Print * /*mod*/, char const *te
// of the special fonts.
char *facename;
if (!newfont) {
- facename = U_Utf8ToLatin1(style->text->font_family.value, 0, NULL);
+ facename = U_Utf8ToLatin1(style->font_family.value, 0, NULL);
} else {
facename = U_Utf8ToLatin1(FontName(newfont), 0, NULL);
}
diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp
index 7c0b4ffba..4ae408397 100644
--- a/src/libnrtype/FontFactory.cpp
+++ b/src/libnrtype/FontFactory.cpp
@@ -825,17 +825,17 @@ font_instance* font_factory::FaceFromStyle(SPStyle const *style)
if (style) {
// First try to use the font specification if it is set
- if (style->text->font_specification.set
- && style->text->font_specification.value
- && *style->text->font_specification.value) {
+ if (style->font_specification.set
+ && style->font_specification.value
+ && *style->font_specification.value) {
- font = FaceFromFontSpecification(style->text->font_specification.value);
+ font = FaceFromFontSpecification(style->font_specification.value);
}
// If that failed, try using the CSS information in the style
if (!font) {
- font = Face(style->text->font_family.value, font_style_to_pos(*style));
+ font = Face(style->font_family.value, font_style_to_pos(*style));
// That was a hatchet job... so we need to check if this font exists!!
Glib::ustring fontSpec = font_factory::Default()->ConstructFontSpecification(font);
diff --git a/src/libnrtype/Layout-TNG-Input.cpp b/src/libnrtype/Layout-TNG-Input.cpp
index cb3e6f620..fa1e8c11b 100644
--- a/src/libnrtype/Layout-TNG-Input.cpp
+++ b/src/libnrtype/Layout-TNG-Input.cpp
@@ -286,16 +286,15 @@ font_instance *Layout::InputStreamTextSource::styleGetFontInstance() const
PangoFontDescription *Layout::InputStreamTextSource::styleGetFontDescription() const
{
- if (style->text == NULL) return NULL;
PangoFontDescription *descr = pango_font_description_new();
// Pango can't cope with spaces before or after the commas - let's remove them.
// this code is not exactly unicode-safe, but it's similar to what's done in
// pango, so it's not the limiting factor
Glib::ustring family;
- if (style->text->font_family.value == NULL) {
+ if (style->font_family.value == NULL) {
family = "sans-serif";
} else {
- gchar **families = g_strsplit(style->text->font_family.value, ",", -1);
+ gchar **families = g_strsplit(style->font_family.value, ",", -1);
if (families) {
for (gchar **f = families ; *f ; ++f) {
g_strstrip(*f);
diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp
index dde0ee4a9..98589d9d7 100644
--- a/src/libnrtype/font-lister.cpp
+++ b/src/libnrtype/font-lister.cpp
@@ -358,8 +358,8 @@ namespace Inkscape
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
//std::cout << " Attempting selected style" << std::endl;
- if( result != QUERY_STYLE_NOTHING && query->text->font_specification.set ) {
- fontspec = query->text->font_specification.value;
+ if( result != QUERY_STYLE_NOTHING && query->font_specification.set ) {
+ fontspec = query->font_specification.value;
//std::cout << " fontspec from query :" << fontspec << ":" << std::endl;
}
@@ -693,15 +693,15 @@ std::pair<Glib::ustring, Glib::ustring> FontLister::new_font_family (Glib::ustri
if (style) {
// First try to use the font specification if it is set
- if (style->text->font_specification.set
- && style->text->font_specification.value
- && *style->text->font_specification.value) {
+ if (style->font_specification.set
+ && style->font_specification.value
+ && *style->font_specification.value) {
- fontspec = style->text->font_specification.value;
+ fontspec = style->font_specification.value;
} else {
- fontspec = style->text->font_family.value;
+ fontspec = style->font_family.value;
fontspec += ",";
switch (style->font_weight.computed) {
diff --git a/src/style-internal.cpp b/src/style-internal.cpp
index ede543078..b03e848ba 100644
--- a/src/style-internal.cpp
+++ b/src/style-internal.cpp
@@ -1887,7 +1887,7 @@ SPIFont::read( gchar const *str ) {
std::string str_s = str; // Why this extra step?
std::string family = str_s.substr( str_s.find( param ) );
- style->text->font_family.readIfUnset( family.c_str() );
+ style->font_family.readIfUnset( family.c_str() );
// Everything in shorthand is set per CSS rules, this works since
// properties are read backwards from end to start.
@@ -1897,7 +1897,7 @@ SPIFont::read( gchar const *str ) {
style->font_stretch.set = true;
style->font_size.set = true;
style->line_height.set = true;
- style->text->font_family.set = true;
+ style->font_family.set = true;
// style->font_size_adjust.set = true;
// style->font_kerning.set = true;
// style->font_language_override.set = true;;
diff --git a/src/style-internal.h b/src/style-internal.h
index e5ef72c76..665c7abd4 100644
--- a/src/style-internal.h
+++ b/src/style-internal.h
@@ -867,19 +867,6 @@ struct SPITextDecorationData {
float line_through_position;
};
-
-/// An SPFontStyle has a 'font', 'font-family', and font_specification (ala Pango).
-struct SPFontStyle {
- /* CSS font properties */
- SPIString font_family;
-
- /* Full font name, as font_factory::ConstructFontSpecification would give */
- SPIString font_specification;
-
- /** \todo fixme: The 'font' property is ugly, and not working (lauris) */
-// SPIString font;
-};
-
#endif // SEEN_SP_STYLE_INTERNAL_H
diff --git a/src/style.cpp b/src/style.cpp
index 97d9c811c..fa99d278c 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -112,7 +112,9 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
font_stretch( "font-stretch", enum_font_stretch, SP_CSS_FONT_STRETCH_NORMAL ),
font_size(),
line_height( "line-height", 1.0 ), // SPILengthOrNormal
+ font_family( "font-family" ), // SPIString
font(), // SPIFont
+ font_specification( "-inkscape-font-specification" ), // SPIString
// Text related properties
text_indent( "text-indent", 0.0 ), // SPILength
@@ -225,11 +227,6 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
new (&fill_ps_modified_connection) sigc::connection();
new (&stroke_ps_modified_connection) sigc::connection();
-
- // FIX-ME Remove SPFontStyle
- text = new SPFontStyle();
- text->font_family = SPIString( "font-family" );
- text->font_specification = SPIString( "-inkscape-font-specification" );
// 'font' shorthand requires access to included properties.
font.setStylePointer( this );
@@ -274,7 +271,9 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
_properties.push_back( &font_stretch );
_properties.push_back( &font_size );
_properties.push_back( &line_height );
+ _properties.push_back( &font_family );
_properties.push_back( &font );
+ _properties.push_back( &font_specification );
_properties.push_back( &text_indent );
_properties.push_back( &text_align );
@@ -337,9 +336,6 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
_properties.push_back( &enable_background );
- _properties.push_back( &text->font_family ); // Must be first as other values depend on it ('ex')
- _properties.push_back( &text->font_specification );
-
// MAP -------------------------------------------
// if( _propmap.size() == 0 ) {
@@ -348,13 +344,15 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
// _propmap.insert( std::make_pair( color.name, reinterpret_cast<SPIBasePtr>(&SPStyle::color ) ) );
// // 'font-size' must be before properties that need to know em, ex size (SPILength, SPILenghtOrNormal)
- // _propmap.insert( std::make_pair( font.name, reinterpret_cast<SPIBasePtr>(&SPStyle::font ) ) );
// _propmap.insert( std::make_pair( font_style.name, reinterpret_cast<SPIBasePtr>(&SPStyle::font_style ) ) );
// _propmap.insert( std::make_pair( font_variant.name, reinterpret_cast<SPIBasePtr>(&SPStyle::font_variant ) ) );
// _propmap.insert( std::make_pair( font_weight.name, reinterpret_cast<SPIBasePtr>(&SPStyle::font_weight ) ) );
// _propmap.insert( std::make_pair( font_stretch.name, reinterpret_cast<SPIBasePtr>(&SPStyle::font_stretch ) ) );
// _propmap.insert( std::make_pair( font_size.name, reinterpret_cast<SPIBasePtr>(&SPStyle::font_size ) ) );
// _propmap.insert( std::make_pair( line_height.name, reinterpret_cast<SPIBasePtr>(&SPStyle::line_height ) ) );
+ // _propmap.insert( std::make_pair( font_family.name, reinterpret_cast<SPIBasePtr>(&SPStyle::font_family ) ) );
+ // _propmap.insert( std::make_pair( font.name, reinterpret_cast<SPIBasePtr>(&SPStyle::font ) ) );
+ // _propmap.insert( std::make_pair( font_specification.name, reinterpret_cast<SPIBasePtr>(&SPStyle::font_specification ) ) );
// _propmap.insert( std::make_pair( text_indent.name, reinterpret_cast<SPIBasePtr>(&SPStyle::text_indent ) ) );
// _propmap.insert( std::make_pair( text_align.name, reinterpret_cast<SPIBasePtr>(&SPStyle::text_align ) ) );
@@ -448,7 +446,6 @@ SPStyle::~SPStyle() {
_properties.clear();
//_propmap.clear();
- delete text;
// std::cout << "SPStyle::~SPstyle(): Exit\n" << std::endl;
}
@@ -594,10 +591,10 @@ SPStyle::readIfUnset( gint id, gchar const *val ) {
switch (id) {
case SP_PROP_INKSCAPE_FONT_SPEC:
- text->font_specification.readIfUnset( val );
+ font_specification.readIfUnset( val );
break;
case SP_PROP_FONT_FAMILY:
- text->font_family.readIfUnset( val );
+ font_family.readIfUnset( val );
break;
case SP_PROP_FONT_SIZE:
font_size.readIfUnset( val );
@@ -1599,10 +1596,10 @@ sp_style_unset_property_attrs(SPObject *o)
if (style->paint_order.set) {
repr->setAttribute("paint-order", NULL);
}
- if (style->text->font_specification.set) {
+ if (style->font_specification.set) {
repr->setAttribute("-inkscape-font-specification", NULL);
}
- if (style->text->font_family.set) {
+ if (style->font_family.set) {
repr->setAttribute("font-family", NULL);
}
if (style->text_anchor.set) {
@@ -1856,9 +1853,6 @@ attribute_unquote(gchar const *val)
*/
Glib::ustring css2_escape_quote(gchar const *val) {
- std::cout << "css2_escape_quote: " << (val?val:"null") << std::endl;
- //return val;
-
Glib::ustring t;
bool quote = false;
bool last_was_space = false;
diff --git a/src/style.h b/src/style.h
index 76a0929cd..9784ee48d 100644
--- a/src/style.h
+++ b/src/style.h
@@ -93,10 +93,6 @@ public:
/* ----------------------- THE PROPERTIES ------------------------- */
- /** Our font style component */
- SPFontStyle *text; // FIXME: Break into font, font-family, ...
-
- /* CSS2 */
/* Font */
/** Font style */
SPIEnum font_style;
@@ -110,8 +106,12 @@ public:
SPIFontSize font_size;
/** Line height (css2 10.8.1) */
SPILengthOrNormal line_height;
+ /** Font family */
+ SPIString font_family;
/** Font shorthand */
SPIFont font;
+ /** Full font name, as font_factory::ConstructFontSpecification would give, for internal use. */
+ SPIString font_specification;
/** First line indent of paragraphs (css2 16.1) */
SPILength text_indent;
diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp
index bf9133086..6e9ecc3c8 100644
--- a/src/ui/dialog/font-substitution.cpp
+++ b/src/ui/dialog/font-substitution.cpp
@@ -200,16 +200,16 @@ GSList * FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustring *
}
}
- if (style && style->text) {
+ if (style) {
gchar const *style_font = NULL;
- if (style->text->font_family.set)
- style_font = style->text->font_family.value;
- else if (style->text->font_specification.set)
- style_font = style->text->font_specification.value;
- else if (style->text->font_family.value)
- style_font = style->text->font_family.value;
- else if (style->text->font_specification.value)
- style_font = style->text->font_specification.value;
+ if (style->font_family.set)
+ style_font = style->font_family.value;
+ else if (style->font_specification.set)
+ style_font = style->font_specification.value;
+ else if (style->font_family.value)
+ style_font = style->font_family.value;
+ else if (style->font_specification.value)
+ style_font = style->font_specification.value;
if (style_font) {
if (has_visible_text(item)) {
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index 7b59fa633..3a4f315da 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -72,20 +72,20 @@ using Inkscape::UI::PrefPusher;
static void sp_print_font( SPStyle *query ) {
- bool family_set = query->text->font_family.set;
+ bool family_set = query->font_family.set;
bool style_set = query->font_style.set;
- bool fontspec_set = query->text->font_specification.set;
+ bool fontspec_set = query->font_specification.set;
std::cout << " Family set? " << family_set
<< " Style set? " << style_set
<< " FontSpec set? " << fontspec_set
<< std::endl;
std::cout << " Family: "
- << (query->text->font_family.value ? query->text->font_family.value : "No value")
+ << (query->font_family.value ? query->font_family.value : "No value")
<< " Style: " << query->font_style.computed
<< " Weight: " << query->font_weight.computed
<< " FontSpec: "
- << (query->text->font_specification.value ? query->text->font_specification.value : "No value")
+ << (query->font_specification.value ? query->font_specification.value : "No value")
<< std::endl;
std::cout << " LineHeight: " << query->line_height.computed
<< " WordSpacing: " << query->word_spacing.computed
@@ -930,7 +930,6 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
}
// If we have valid query data for text (font-family, font-specification) set toolbar accordingly.
- if (query->text)
{
// Size (average of text selected)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -1058,11 +1057,11 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
ege_select_one_action_set_active( textOrientationAction, activeButton2 );
- } // if( query->text )
+ }
#ifdef DEBUG_TEXT
std::cout << " GUI: fontfamily.value: "
- << (query->text->font_family.value ? query->text->font_family.value : "No value")
+ << (query->font_family.value ? query->font_family.value : "No value")
<< std::endl;
std::cout << " GUI: font_size.computed: " << query->font_size.computed << std::endl;
std::cout << " GUI: font_weight.computed: " << query->font_weight.computed << std::endl;
@@ -1174,15 +1173,15 @@ static void sp_text_toolbox_select_cb( GtkEntry* entry, GtkEntryIconPosition /*p
SPItem *item = SP_ITEM(i->data);
SPStyle *style = item->style;
- if (style && style->text) {
+ if (style) {
Glib::ustring family_style;
- if (style->text->font_family.set) {
- family_style = style->text->font_family.value;
+ if (style->font_family.set) {
+ family_style = style->font_family.value;
//std::cout << " family style from font_family: " << family_style << std::endl;
}
- else if (style->text->font_specification.set) {
- family_style = style->text->font_specification.value;
+ else if (style->font_specification.set) {
+ family_style = style->font_specification.value;
//std::cout << " family style from font_spec: " << family_style << std::endl;
}