summaryrefslogtreecommitdiffstats
path: root/src/display
diff options
context:
space:
mode:
authorsu_v <suv-sf@users.sourceforge.net>2012-11-14 16:07:45 +0000
committer~suv <suv-sf@users.sourceforge.net>2012-11-14 16:07:45 +0000
commit0d3cb2271366191c5cc414fc1bf8f41aaa046068 (patch)
tree56015cf8999ee17546cdc448b7f9fdae389e0fe5 /src/display
parentchanges_2012_11_13a.patch (diff)
parentemf import. modify sequence of operations to load file EMF_Illustrator_a4.emf... (diff)
downloadinkscape-0d3cb2271366191c5cc414fc1bf8f41aaa046068.tar.gz
inkscape-0d3cb2271366191c5cc414fc1bf8f41aaa046068.zip
merge from trunk (r11871)
(bzr r11668.1.41)
Diffstat (limited to 'src/display')
-rw-r--r--src/display/curve.cpp2
-rw-r--r--src/display/nr-svgfonts.cpp67
2 files changed, 33 insertions, 36 deletions
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index 1a788b59a..ae243853e 100644
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
@@ -150,7 +150,7 @@ SPCurve::concat(GSList const *list)
SPCurve *new_curve = new SPCurve();
for (GSList const *l = list; l != NULL; l = l->next) {
- SPCurve *c = (SPCurve *) l->data;
+ SPCurve *c = static_cast<SPCurve *>(l->data);
new_curve->_pathv.insert( new_curve->_pathv.end(), c->get_pathvector().begin(), c->get_pathvector().end() );
}
diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp
index e095fb9a9..d0c6d2d56 100644
--- a/src/display/nr-svgfonts.cpp
+++ b/src/display/nr-svgfonts.cpp
@@ -43,10 +43,9 @@
static cairo_user_data_key_t key;
static cairo_status_t font_init_cb (cairo_scaled_font_t *scaled_font,
- cairo_t */*cairo*/, cairo_font_extents_t *metrics){
- cairo_font_face_t* face;
- face = cairo_scaled_font_get_font_face(scaled_font);
- SvgFont* instance = (SvgFont*) cairo_font_face_get_user_data(face, &key);
+ cairo_t * /*cairo*/, cairo_font_extents_t *metrics){
+ cairo_font_face_t* face = cairo_scaled_font_get_font_face(scaled_font);
+ SvgFont* instance = static_cast<SvgFont*>(cairo_font_face_get_user_data(face, &key));
return instance->scaled_font_init(scaled_font, metrics);
}
@@ -58,9 +57,8 @@ static cairo_status_t font_text_to_glyphs_cb ( cairo_scaled_font_t *scaled_font
cairo_text_cluster_t **clusters,
int *num_clusters,
cairo_text_cluster_flags_t *flags){
- cairo_font_face_t* face;
- face = cairo_scaled_font_get_font_face(scaled_font);
- SvgFont* instance = (SvgFont*) cairo_font_face_get_user_data(face, &key);
+ cairo_font_face_t* face = cairo_scaled_font_get_font_face(scaled_font);
+ SvgFont* instance = static_cast<SvgFont*>(cairo_font_face_get_user_data(face, &key));
return instance->scaled_font_text_to_glyphs(scaled_font, utf8, utf8_len, glyphs, num_glyphs, clusters, num_clusters, flags);
}
@@ -68,9 +66,8 @@ static cairo_status_t font_render_glyph_cb (cairo_scaled_font_t *scaled_font,
unsigned long glyph,
cairo_t *cr,
cairo_text_extents_t *metrics){
- cairo_font_face_t* face;
- face = cairo_scaled_font_get_font_face(scaled_font);
- SvgFont* instance = (SvgFont*) cairo_font_face_get_user_data(face, &key);
+ cairo_font_face_t* face = cairo_scaled_font_get_font_face(scaled_font);
+ SvgFont* instance = static_cast<SvgFont*>(cairo_font_face_get_user_data(face, &key));
return instance->scaled_font_render_glyph(scaled_font, glyph, cr, metrics);
}
@@ -116,15 +113,15 @@ unsigned int size_of_substring(const char* substring, gchar* str){
}
//TODO: in these macros, verify what happens when using unicode strings.
-#define Match_VKerning_Rule (((SPVkern*)node)->u1->contains(previous_unicode[0])\
- || ((SPVkern*)node)->g1->contains(previous_glyph_name)) &&\
- (((SPVkern*)node)->u2->contains(this->glyphs[i]->unicode[0])\
- || ((SPVkern*)node)->g2->contains(this->glyphs[i]->glyph_name.c_str()))
+#define Match_VKerning_Rule ((SP_VKERN(node))->u1->contains(previous_unicode[0])\
+ || (SP_VKERN(node))->g1->contains(previous_glyph_name)) &&\
+ ((SP_VKERN(node))->u2->contains(this->glyphs[i]->unicode[0])\
+ || (SP_VKERN(node))->g2->contains(this->glyphs[i]->glyph_name.c_str()))
-#define Match_HKerning_Rule (((SPHkern*)node)->u1->contains(previous_unicode[0])\
- || ((SPHkern*)node)->g1->contains(previous_glyph_name)) &&\
- (((SPHkern*)node)->u2->contains(this->glyphs[i]->unicode[0])\
- || ((SPHkern*)node)->g2->contains(this->glyphs[i]->glyph_name.c_str()))
+#define Match_HKerning_Rule ((SP_HKERN(node))->u1->contains(previous_unicode[0])\
+ || (SP_HKERN(node))->g1->contains(previous_glyph_name)) &&\
+ ((SP_HKERN(node))->u2->contains(this->glyphs[i]->unicode[0])\
+ || (SP_HKERN(node))->g2->contains(this->glyphs[i]->glyph_name.c_str()))
cairo_status_t
SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t */*scaled_font*/,
@@ -187,14 +184,14 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t */*scaled_font*/,
for(SPObject* node = this->font->children;previous_unicode && node;node=node->next){
//apply glyph kerning if appropriate
if (SP_IS_HKERN(node) && is_horizontal_text && Match_HKerning_Rule ){
- x -= (((SPHkern*)node)->k / 1000.0);//TODO: use here the height of the font
+ x -= ((SP_HKERN(node))->k / 1000.0);//TODO: use here the height of the font
}
if (SP_IS_VKERN(node) && !is_horizontal_text && Match_VKerning_Rule ){
- y -= (((SPVkern*)node)->k / 1000.0);//TODO: use here the "height" of the font
+ y -= ((SP_VKERN(node))->k / 1000.0);//TODO: use here the "height" of the font
}
}
- previous_unicode = (char*) this->glyphs[i]->unicode.c_str();//used for kerning checking
- previous_glyph_name = (char*) this->glyphs[i]->glyph_name.c_str();//used for kerning checking
+ previous_unicode = const_cast<char*>(this->glyphs[i]->unicode.c_str());//used for kerning checking
+ previous_glyph_name = const_cast<char*>(this->glyphs[i]->glyph_name.c_str());//used for kerning checking
(*glyphs)[count].index = i;
(*glyphs)[count].x = x;
(*glyphs)[count++].y = y;
@@ -251,7 +248,7 @@ Geom::PathVector
SvgFont::flip_coordinate_system(SPFont* spfont, Geom::PathVector pathv){
double units_per_em = 1000;
SPObject* obj;
- for (obj = ((SPObject*) spfont)->children; obj; obj=obj->next){
+ for (obj = (SP_OBJECT(spfont))->children; obj; obj=obj->next){
if (SP_IS_FONTFACE(obj)){
//XML Tree being directly used here while it shouldn't be.
sp_repr_get_double(obj->getRepr(), "units_per_em", &units_per_em);
@@ -282,16 +279,16 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/,
SPObject* node;
if (glyph == this->glyphs.size()){
if (!this->missingglyph) return CAIRO_STATUS_SUCCESS;
- node = (SPObject*) this->missingglyph;
+ node = SP_OBJECT(this->missingglyph);
} else {
- node = (SPObject*) this->glyphs[glyph];
+ node = SP_OBJECT(this->glyphs[glyph]);
}
if (!SP_IS_GLYPH(node) && !SP_IS_MISSING_GLYPH(node)) {
return CAIRO_STATUS_SUCCESS; // FIXME: is this the right code to return?
}
- SPFont* spfont = (SPFont*) node->parent;
+ SPFont* spfont = SP_FONT(node->parent);
if (!spfont) {
return CAIRO_STATUS_SUCCESS; // FIXME: is this the right code to return?
}
@@ -300,12 +297,12 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/,
// or using the d attribute of a glyph node.
// pathv stores the path description from the d attribute:
Geom::PathVector pathv;
- if (SP_IS_GLYPH(node) && ((SPGlyph*)node)->d) {
- pathv = sp_svg_read_pathv(((SPGlyph*)node)->d);
+ if (SP_IS_GLYPH(node) && (SP_GLYPH(node))->d) {
+ pathv = sp_svg_read_pathv((SP_GLYPH(node))->d);
pathv = flip_coordinate_system(spfont, pathv);
this->render_glyph_path(cr, &pathv);
- } else if (SP_IS_MISSING_GLYPH(node) && ((SPMissingGlyph*)node)->d) {
- pathv = sp_svg_read_pathv(((SPMissingGlyph*)node)->d);
+ } else if (SP_IS_MISSING_GLYPH(node) && (SP_MISSING_GLYPH(node))->d) {
+ pathv = sp_svg_read_pathv((SP_MISSING_GLYPH(node))->d);
pathv = flip_coordinate_system(spfont, pathv);
this->render_glyph_path(cr, &pathv);
}
@@ -314,7 +311,7 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/,
//render the SVG described on this glyph's child nodes.
for(node = node->children; node; node=node->next){
if (SP_IS_PATH(node)){
- pathv = ((SPShape*)node)->_curve->get_pathvector();
+ pathv = (SP_SHAPE(node))->_curve->get_pathvector();
pathv = flip_coordinate_system(spfont, pathv);
this->render_glyph_path(cr, &pathv);
}
@@ -324,12 +321,12 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/,
if (SP_IS_USE(node)){
SPItem* item = SP_USE(node)->ref->getObject();
if (SP_IS_PATH(item)){
- pathv = ((SPShape*)item)->_curve->get_pathvector();
+ pathv = (SP_SHAPE(item))->_curve->get_pathvector();
pathv = flip_coordinate_system(spfont, pathv);
this->render_glyph_path(cr, &pathv);
}
- glyph_modified_connection = ((SPObject*) item)->connectModified(sigc::mem_fun(*this, &SvgFont::glyph_modified));
+ glyph_modified_connection = (SP_OBJECT(item))->connectModified(sigc::mem_fun(*this, &SvgFont::glyph_modified));
}
}
}
@@ -342,10 +339,10 @@ SvgFont::get_font_face(){
if (!this->userfont) {
for(SPObject* node = this->font->children;node;node=node->next){
if (SP_IS_GLYPH(node)){
- this->glyphs.push_back((SPGlyph*)node);
+ this->glyphs.push_back(SP_GLYPH(node));
}
if (SP_IS_MISSING_GLYPH(node)){
- this->missingglyph=(SPMissingGlyph*)node;
+ this->missingglyph=SP_MISSING_GLYPH(node);
}
}
this->userfont = new UserFont(this);