summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f30962b)
raw | patch | inline | side by side (parent: f30962b)
author | joncruz <joncruz@users.sourceforge.net> | |
Tue, 6 Jan 2009 07:11:11 +0000 (07:11 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Tue, 6 Jan 2009 07:11:11 +0000 (07:11 +0000) |
index 86da5b7a1daa2a5a0d0728cf737485fd0922bfef..2d71504d215db4ee013c9015e5b19711636fd9ae 100644 (file)
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);
- return instance->scaled_font_init(scaled_font, metrics);
+ 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);
+ return instance->scaled_font_init(scaled_font, metrics);
}
-static cairo_status_t font_text_to_glyphs_cb (
- cairo_scaled_font_t *scaled_font,
- const char *utf8,
- int utf8_len,
- cairo_glyph_t **glyphs,
- int *num_glyphs,
- 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);
- return instance->scaled_font_text_to_glyphs(scaled_font, utf8, utf8_len, glyphs, num_glyphs, clusters, num_clusters, flags);
+static cairo_status_t font_text_to_glyphs_cb ( cairo_scaled_font_t *scaled_font,
+ const char *utf8,
+ int utf8_len,
+ cairo_glyph_t **glyphs,
+ int *num_glyphs,
+ 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);
+ return instance->scaled_font_text_to_glyphs(scaled_font, utf8, utf8_len, glyphs, num_glyphs, clusters, num_clusters, flags);
}
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);
- return instance->scaled_font_render_glyph(scaled_font, glyph, cr, metrics);
+ 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);
+ return instance->scaled_font_render_glyph(scaled_font, glyph, cr, metrics);
}
UserFont::UserFont(SvgFont* instance){
- this->face = cairo_user_font_face_create ();
- cairo_user_font_face_set_init_func (this->face, font_init_cb);
- cairo_user_font_face_set_render_glyph_func (this->face, font_render_glyph_cb);
- cairo_user_font_face_set_text_to_glyphs_func (this->face, font_text_to_glyphs_cb);
+ this->face = cairo_user_font_face_create ();
+ cairo_user_font_face_set_init_func (this->face, font_init_cb);
+ cairo_user_font_face_set_render_glyph_func (this->face, font_render_glyph_cb);
+ cairo_user_font_face_set_text_to_glyphs_func(this->face, font_text_to_glyphs_cb);
- cairo_font_face_set_user_data (this->face, &key, (void*)instance, (cairo_destroy_func_t) NULL);
+ cairo_font_face_set_user_data (this->face, &key, (void*)instance, (cairo_destroy_func_t) NULL);
}
//******************************//
// SvgFont class Implementation //
//******************************//
SvgFont::SvgFont(SPFont* spfont){
- this->font = spfont;
- this->missingglyph = NULL;
- this->userfont = NULL;
+ this->font = spfont;
+ this->missingglyph = NULL;
+ this->userfont = NULL;
}
cairo_status_t
-SvgFont::scaled_font_init (cairo_scaled_font_t *scaled_font,
- cairo_font_extents_t *metrics)
+SvgFont::scaled_font_init (cairo_scaled_font_t */*scaled_font*/,
+ cairo_font_extents_t */*metrics*/)
{
//TODO
// metrics->ascent = .75;
}
unsigned int size_of_substring(const char* substring, gchar* str){
- const gchar* original_substring = substring;
-
- while((g_utf8_get_char(substring)==g_utf8_get_char(str)) && g_utf8_get_char(substring) != 0 && g_utf8_get_char(str) != 0){
- substring = g_utf8_next_char(substring);
- str = g_utf8_next_char(str);
- }
- if (g_utf8_get_char(substring)==0)
- return substring - original_substring;
- else
- return 0;
+ const gchar* original_substring = substring;
+
+ while((g_utf8_get_char(substring)==g_utf8_get_char(str)) && g_utf8_get_char(substring) != 0 && g_utf8_get_char(str) != 0){
+ substring = g_utf8_next_char(substring);
+ str = g_utf8_next_char(str);
+ }
+ if (g_utf8_get_char(substring)==0)
+ return substring - original_substring;
+ else
+ return 0;
}
//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()))
+ || ((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_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()))
+ || ((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()))
cairo_status_t
-SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font,
- const char *utf8,
- int utf8_len,
- cairo_glyph_t **glyphs,
- int *num_glyphs,
- cairo_text_cluster_t **clusters,
- int *num_clusters,
- cairo_text_cluster_flags_t *flags)
+SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t */*scaled_font*/,
+ const char *utf8,
+ int /*utf8_len*/,
+ cairo_glyph_t **glyphs,
+ int *num_glyphs,
+ cairo_text_cluster_t **/*clusters*/,
+ int */*num_clusters*/,
+ cairo_text_cluster_flags_t */*flags*/)
{
- //This function receives a text string to be rendered. It then defines what is the sequence of glyphs that
- // is used to properly render this string. It also defines the respective coordinates of each glyph. Thus, it
- // has to read the attributes of the SVGFont hkern and vkern nodes in order to adjust the glyph kerning.
- //It also determines the usage of the missing-glyph in portions of the string that does not match any of the declared glyphs.
+ //This function receives a text string to be rendered. It then defines what is the sequence of glyphs that
+ // is used to properly render this string. It also defines the respective coordinates of each glyph. Thus, it
+ // has to read the attributes of the SVGFont hkern and vkern nodes in order to adjust the glyph kerning.
+ //It also determines the usage of the missing-glyph in portions of the string that does not match any of the declared glyphs.
unsigned long i;
int count = 0;
bool missing;
//First we findout whats the number of glyphs needed.
while(g_utf8_get_char(_utf8)){
- missing = true;
- for (i=0; i < (unsigned long) this->glyphs.size(); i++){
- if ( (len = size_of_substring(this->glyphs[i]->unicode.c_str(), _utf8)) ){
- //TODO: store this cluster
- _utf8+=len;
- count++;
- missing=false;
- break;
- }
- }
- if (missing){
- //TODO: store this cluster
- _utf8++;
- count++;
- }
+ missing = true;
+ for (i=0; i < (unsigned long) this->glyphs.size(); i++){
+ if ( (len = size_of_substring(this->glyphs[i]->unicode.c_str(), _utf8)) ){
+ //TODO: store this cluster
+ _utf8+=len;
+ count++;
+ missing=false;
+ break;
+ }
+ }
+ if (missing){
+ //TODO: store this cluster
+ _utf8++;
+ count++;
+ }
}
_utf8 = (char*) utf8;
while(g_utf8_get_char(_utf8)){
- len = 0;
+ len = 0;
for (i=0; i < (unsigned long) this->glyphs.size(); i++){
- //check whether is there a glyph declared on the SVG document
- // that matches with the text string in its current position
- if ( (len = size_of_substring(this->glyphs[i]->unicode.c_str(), _utf8)) ){
- 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
- }
- 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
- }
- }
- 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
- (*glyphs)[count].index = i;
- (*glyphs)[count].x = x;
- (*glyphs)[count++].y = y;
-
- //advance glyph coordinates:
- if (is_horizontal_text) x+=(this->font->horiz_adv_x/1000.0);//TODO: use here the height of the font
- else y+=(this->font->vert_adv_y/1000.0);//TODO: use here the "height" of the font
- _utf8+=len; //advance 'len' bytes in our string pointer
- //continue;
- goto raptorz;
+ //check whether is there a glyph declared on the SVG document
+ // that matches with the text string in its current position
+ if ( (len = size_of_substring(this->glyphs[i]->unicode.c_str(), _utf8)) ){
+ 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
+ }
+ 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
+ }
+ }
+ 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
+ (*glyphs)[count].index = i;
+ (*glyphs)[count].x = x;
+ (*glyphs)[count++].y = y;
+
+ //advance glyph coordinates:
+ if (is_horizontal_text) x+=(this->font->horiz_adv_x/1000.0);//TODO: use here the height of the font
+ else y+=(this->font->vert_adv_y/1000.0);//TODO: use here the "height" of the font
+ _utf8+=len; //advance 'len' bytes in our string pointer
+ //continue;
+ goto raptorz;
}
}
-raptorz:
- if (len==0){
- (*glyphs)[count].index = i;
- (*glyphs)[count].x = x;
- (*glyphs)[count++].y = y;
-
- //advance glyph coordinates:
- if (is_horizontal_text) x+=(this->font->horiz_adv_x/1000.0);//TODO: use here the height of the font
- else y+=(this->font->vert_adv_y/1000.0);//TODO: use here the "height" of the font
-
- _utf8 = g_utf8_next_char(_utf8); //advance 1 char in our string pointer
- }
+ raptorz:
+ if (len==0){
+ (*glyphs)[count].index = i;
+ (*glyphs)[count].x = x;
+ (*glyphs)[count++].y = y;
+
+ //advance glyph coordinates:
+ if (is_horizontal_text) x+=(this->font->horiz_adv_x/1000.0);//TODO: use here the height of the font
+ else y+=(this->font->vert_adv_y/1000.0);//TODO: use here the "height" of the font
+
+ _utf8 = g_utf8_next_char(_utf8); //advance 1 char in our string pointer
+ }
}
*num_glyphs = count;
return CAIRO_STATUS_SUCCESS;
}
cairo_status_t
-SvgFont::scaled_font_render_glyph (cairo_scaled_font_t *scaled_font,
- unsigned long glyph,
- cairo_t *cr,
- cairo_text_extents_t *metrics)
+SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/,
+ unsigned long glyph,
+ cairo_t *cr,
+ cairo_text_extents_t */*metrics*/)
{
// This method does the actual rendering of glyphs.
- // We have glyphs.size() glyphs and possibly one missing-glyph declared on this SVG document
+ // We have glyphs.size() glyphs and possibly one missing-glyph declared on this SVG document
// The id of the missing-glyph is always equal to glyphs.size()
// All the other glyphs have ids ranging from 0 to glyphs.size()-1
if (!pathv.empty()){
//This glyph has a path description on its d attribute, so we render it:
cairo_new_path(cr);
- //adjust scale of the glyph
+ //adjust scale of the glyph
// Geom::Scale s(1.0/((SPFont*) node->parent)->horiz_adv_x);
Geom::Scale s(1.0/1000);//TODO: use here the units-per-em attribute?
- //This matrix flips the glyph vertically
+ //This matrix flips the glyph vertically
Geom::Matrix m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(0));
- //then we offset it
-// pathv += Geom::Point(Geom::Coord(0),Geom::Coord(-((SPFont*) node->parent)->horiz_adv_x));
- pathv += Geom::Point(Geom::Coord(0),Geom::Coord(-1000));//TODO: use here the units-per-em attribute?
+ //then we offset it
+// pathv += Geom::Point(Geom::Coord(0),Geom::Coord(-((SPFont*) node->parent)->horiz_adv_x));
+ pathv += Geom::Point(Geom::Coord(0),Geom::Coord(-1000));//TODO: use here the units-per-em attribute?
Geom::Rect area( Geom::Point(0,0), Geom::Point(1,1) ); //I need help here! (reaction: note that the 'area' parameter is an *optional* rect, so you can pass an empty Geom::OptRect() )
this->missingglyph=(SPMissingGlyph*)node;
}
}
- this->userfont = new UserFont(this);
+ this->userfont = new UserFont(this);
}
return this->userfont->face;
}
void SvgFont::refresh(){
- this->glyphs.clear();
- delete this->userfont;
- this->userfont = NULL;
+ this->glyphs.clear();
+ delete this->userfont;
+ this->userfont = NULL;
}
#endif //#ifdef ENABLE_SVG_FONTS
+
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp
index 811d9a14f0af50f5852da274e1d047fec82756a7..1ec6f4601b90e3a389e7c09c215af002eea7aa6d 100644 (file)
--- a/src/sp-font-face.cpp
+++ b/src/sp-font-face.cpp
* SVG <font-face> element implementation
*
* Section 20.8.3 of the W3C SVG 1.1 spec
- * available at:
+ * available at:
* http://www.w3.org/TR/SVG/fonts.html#FontFaceElement
*
* Author:
v.push_back(SP_FONTFACE_STYLE_ALL);
return v;
}
-
+
if (strncmp(value, "all", 3) == 0){
value += 3;
while(value[0]==',' || value[0]==' ')
@@ -137,7 +137,7 @@ static std::vector<FontFaceWeightType> sp_read_fontFaceWeightType(gchar const *v
v.push_back(SP_FONTFACE_WEIGHT_ALL);
return v;
}
-
+
if (strncmp(value, "all", 3) == 0){
value += 3;
while(value[0]==',' || value[0]==' ')
v.push_back(SP_FONTFACE_STRETCH_NORMAL);
return v;
}
-
+
if (strncmp(value, "all", 3) == 0){
value += 3;
while(value[0]==',' || value[0]==' ')
if (!type) {
GTypeInfo info = {
sizeof(SPFontFaceClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
+ NULL, /* base_init */
+ NULL, /* base_finalize */
(GClassInitFunc) sp_fontface_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
sizeof(SPFontFace),
- 16, /* n_preallocs */
+ 16, /* n_preallocs */
(GInstanceInitFunc) sp_fontface_init,
- NULL, /* value_table */
+ NULL, /* value_table */
};
type = g_type_register_static(SP_TYPE_OBJECT, "SPFontFace", &info, (GTypeFlags) 0);
}
@@ -439,7 +439,7 @@ static void sp_fontface_build(SPObject *object, SPDocument *document, Inkscape::
sp_object_read_attr(object, "overline-thickness");
}
-static void sp_fontface_children_modified(SPFontFace *sp_fontface)
+static void sp_fontface_children_modified(SPFontFace */*sp_fontface*/)
{
}
@@ -493,12 +493,12 @@ static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *val
std::vector<FontFaceStretchType> stretch;
switch (key) {
- case SP_PROP_FONT_FAMILY:
+ case SP_PROP_FONT_FAMILY:
if (face->font_family) g_free(face->font_family);
face->font_family = g_strdup(value);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
- break;
- case SP_PROP_FONT_STYLE:
+ break;
+ case SP_PROP_FONT_STYLE:
style = sp_read_fontFaceStyleType(value);
if (face->font_style.size() != style.size()){
face->font_style = style;
@@ -513,7 +513,7 @@ static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *val
}
}
break;
- case SP_PROP_FONT_VARIANT:
+ case SP_PROP_FONT_VARIANT:
variant = sp_read_fontFaceVariantType(value);
if (face->font_variant.size() != variant.size()){
face->font_variant = variant;
@@ -528,7 +528,7 @@ static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *val
}
}
break;
- case SP_PROP_FONT_WEIGHT:
+ case SP_PROP_FONT_WEIGHT:
weight = sp_read_fontFaceWeightType(value);
if (face->font_weight.size() != weight.size()){
face->font_weight = weight;
@@ -543,7 +543,7 @@ static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *val
}
}
break;
- case SP_PROP_FONT_STRETCH:
+ case SP_PROP_FONT_STRETCH:
stretch = sp_read_fontFaceStretchType(value);
if (face->font_stretch.size() != stretch.size()){
face->font_stretch = stretch;
@@ -558,168 +558,168 @@ static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *val
}
}
break;
- case SP_ATTR_UNITS_PER_EM:
+ case SP_ATTR_UNITS_PER_EM:
number = helperfns_read_number(value);
if (number != face->units_per_em){
face->units_per_em = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_STEMV:
+ case SP_ATTR_STEMV:
number = helperfns_read_number(value);
if (number != face->stemv){
face->stemv = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_STEMH:
+ case SP_ATTR_STEMH:
number = helperfns_read_number(value);
if (number != face->stemh){
face->stemh = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_SLOPE:
+ case SP_ATTR_SLOPE:
number = helperfns_read_number(value);
if (number != face->slope){
face->slope = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_CAP_HEIGHT:
+ case SP_ATTR_CAP_HEIGHT:
number = helperfns_read_number(value);
if (number != face->cap_height){
face->cap_height = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_X_HEIGHT:
+ case SP_ATTR_X_HEIGHT:
number = helperfns_read_number(value);
if (number != face->x_height){
face->x_height = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_ACCENT_HEIGHT:
+ case SP_ATTR_ACCENT_HEIGHT:
number = helperfns_read_number(value);
if (number != face->accent_height){
face->accent_height = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_ASCENT:
+ case SP_ATTR_ASCENT:
number = helperfns_read_number(value);
if (number != face->ascent){
face->ascent = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_DESCENT:
+ case SP_ATTR_DESCENT:
number = helperfns_read_number(value);
if (number != face->descent){
face->descent = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_IDEOGRAPHIC:
+ case SP_ATTR_IDEOGRAPHIC:
number = helperfns_read_number(value);
if (number != face->ideographic){
face->ideographic = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_ALPHABETIC:
+ case SP_ATTR_ALPHABETIC:
number = helperfns_read_number(value);
if (number != face->alphabetic){
face->alphabetic = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_MATHEMATICAL:
+ case SP_ATTR_MATHEMATICAL:
number = helperfns_read_number(value);
if (number != face->mathematical){
face->mathematical = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_HANGING:
+ case SP_ATTR_HANGING:
number = helperfns_read_number(value);
if (number != face->hanging){
face->hanging = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_V_IDEOGRAPHIC:
+ case SP_ATTR_V_IDEOGRAPHIC:
number = helperfns_read_number(value);
if (number != face->v_ideographic){
face->v_ideographic = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_V_ALPHABETIC:
+ case SP_ATTR_V_ALPHABETIC:
number = helperfns_read_number(value);
if (number != face->v_alphabetic){
face->v_alphabetic = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_V_MATHEMATICAL:
+ case SP_ATTR_V_MATHEMATICAL:
number = helperfns_read_number(value);
if (number != face->v_mathematical){
face->v_mathematical = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_V_HANGING:
+ case SP_ATTR_V_HANGING:
number = helperfns_read_number(value);
if (number != face->v_hanging){
face->v_hanging = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_UNDERLINE_POSITION:
+ case SP_ATTR_UNDERLINE_POSITION:
number = helperfns_read_number(value);
if (number != face->underline_position){
face->underline_position = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_UNDERLINE_THICKNESS:
+ case SP_ATTR_UNDERLINE_THICKNESS:
number = helperfns_read_number(value);
if (number != face->underline_thickness){
face->underline_thickness = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_STRIKETHROUGH_POSITION:
+ case SP_ATTR_STRIKETHROUGH_POSITION:
number = helperfns_read_number(value);
if (number != face->strikethrough_position){
face->strikethrough_position = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_STRIKETHROUGH_THICKNESS:
+ case SP_ATTR_STRIKETHROUGH_THICKNESS:
number = helperfns_read_number(value);
if (number != face->strikethrough_thickness){
face->strikethrough_thickness = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_OVERLINE_POSITION:
+ case SP_ATTR_OVERLINE_POSITION:
number = helperfns_read_number(value);
if (number != face->overline_position){
face->overline_position = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_OVERLINE_THICKNESS:
+ case SP_ATTR_OVERLINE_THICKNESS:
number = helperfns_read_number(value);
if (number != face->overline_thickness){
face->overline_thickness = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- default:
+ default:
if (((SPObjectClass *) (parent_class))->set) {
((SPObjectClass *) (parent_class))->set(object, key, value);
}
diff --git a/src/sp-font.cpp b/src/sp-font.cpp
index 07aeaabf41ffb76a801763a3587992fe0aae729c..75fb186383a56bb64449f01852d9e6c409329762 100644 (file)
--- a/src/sp-font.cpp
+++ b/src/sp-font.cpp
if (!type) {
GTypeInfo info = {
sizeof(SPFontClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
+ NULL, /* base_init */
+ NULL, /* base_finalize */
(GClassInitFunc) sp_font_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
sizeof(SPFont),
- 16, /* n_preallocs */
+ 16, /* n_preallocs */
(GInstanceInitFunc) sp_font_init,
- NULL, /* value_table */
+ NULL, /* value_table */
};
type = g_type_register_static(SP_TYPE_OBJECT, "SPFont", &info, (GTypeFlags) 0);
}
@@ -107,7 +107,7 @@ static void sp_font_build(SPObject *object, SPDocument *document, Inkscape::XML:
}
-static void sp_font_children_modified(SPFont *sp_font)
+static void sp_font_children_modified(SPFont */*sp_font*/)
{
}
@@ -158,49 +158,49 @@ static void sp_font_set(SPObject *object, unsigned int key, const gchar *value)
double number;
switch (key) {
- case SP_ATTR_HORIZ_ORIGIN_X:
+ case SP_ATTR_HORIZ_ORIGIN_X:
number = helperfns_read_number(value);
if (number != font->horiz_origin_x){
font->horiz_origin_x = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_HORIZ_ORIGIN_Y:
+ case SP_ATTR_HORIZ_ORIGIN_Y:
number = helperfns_read_number(value);
if (number != font->horiz_origin_y){
font->horiz_origin_y = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_HORIZ_ADV_X:
+ case SP_ATTR_HORIZ_ADV_X:
number = helperfns_read_number(value);
if (number != font->horiz_adv_x){
font->horiz_adv_x = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_VERT_ORIGIN_X:
+ case SP_ATTR_VERT_ORIGIN_X:
number = helperfns_read_number(value);
if (number != font->vert_origin_x){
font->vert_origin_x = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_VERT_ORIGIN_Y:
+ case SP_ATTR_VERT_ORIGIN_Y:
number = helperfns_read_number(value);
if (number != font->vert_origin_y){
font->vert_origin_y = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case SP_ATTR_VERT_ADV_Y:
+ case SP_ATTR_VERT_ADV_Y:
number = helperfns_read_number(value);
if (number != font->vert_adv_y){
font->vert_adv_y = number;
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- default:
+ default:
if (((SPObjectClass *) (parent_class))->set) {
((SPObjectClass *) (parent_class))->set(object, key, value);
}
index abdf4c3aeb64009648266891d93f1211f275130e..930d5a0a360bd28a475682fdd1afb6d0a515e121 100644 (file)
#include <2geom/pathvector.h>
SvgFontDrawingArea::SvgFontDrawingArea(){
- this->text = "";
- this->svgfont = NULL;
+ this->text = "";
+ this->svgfont = NULL;
}
void SvgFontDrawingArea::set_svgfont(SvgFont* svgfont){
- this->svgfont = svgfont;
+ this->svgfont = svgfont;
}
void SvgFontDrawingArea::set_text(Glib::ustring text){
- this->text = text;
- redraw();
+ this->text = text;
+ redraw();
}
void SvgFontDrawingArea::set_size(int x, int y){
}
void SvgFontDrawingArea::redraw(){
- ((Gtk::Widget*) this)->queue_draw();
+ ((Gtk::Widget*) this)->queue_draw();
}
-bool SvgFontDrawingArea::on_expose_event (GdkEventExpose *event){
+bool SvgFontDrawingArea::on_expose_event (GdkEventExpose */*event*/){
if (this->svgfont){
Glib::RefPtr<Gdk::Window> window = get_window();
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
@@ -89,40 +89,40 @@ SvgFontsDialog::AttrEntry::AttrEntry(SvgFontsDialog* d, gchar* lbl, const SPAttr
}
void SvgFontsDialog::AttrEntry::set_text(char* t){
- if (!t) return;
- entry.set_text(t);
+ if (!t) return;
+ entry.set_text(t);
}
void SvgFontsDialog::AttrEntry::on_attr_changed(){
- SPObject* o = NULL;
- for(SPObject* node = this->dialog->get_selected_spfont()->children; node; node=node->next){
- switch(this->attr){
- case SP_PROP_FONT_FAMILY:
- if (SP_IS_FONTFACE(node)){
- o = node;
- continue;
- }
- break;
- default:
- o = NULL;
- }
+ SPObject* o = NULL;
+ for(SPObject* node = this->dialog->get_selected_spfont()->children; node; node=node->next){
+ switch(this->attr){
+ case SP_PROP_FONT_FAMILY:
+ if (SP_IS_FONTFACE(node)){
+ o = node;
+ continue;
+ }
+ break;
+ default:
+ o = NULL;
}
+ }
- const gchar* name = (const gchar*)sp_attribute_name(this->attr);
- if(name && o) {
- SP_OBJECT_REPR(o)->setAttribute((const gchar*) name, this->entry.get_text().c_str());
- o->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ const gchar* name = (const gchar*)sp_attribute_name(this->attr);
+ if(name && o) {
+ SP_OBJECT_REPR(o)->setAttribute((const gchar*) name, this->entry.get_text().c_str());
+ o->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
- Glib::ustring undokey = "svgfonts:";
- undokey += name;
- sp_document_maybe_done(o->document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS,
- _("Set SVG Font attribute"));
- }
+ Glib::ustring undokey = "svgfonts:";
+ undokey += name;
+ sp_document_maybe_done(o->document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS,
+ _("Set SVG Font attribute"));
+ }
}
-Gtk::HBox* SvgFontsDialog::AttrCombo(gchar* lbl, const SPAttributeEnum attr){
+Gtk::HBox* SvgFontsDialog::AttrCombo(gchar* lbl, const SPAttributeEnum /*attr*/){
Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox());
hbox->add(* Gtk::manage(new Gtk::Label(lbl)) );
hbox->add(* Gtk::manage(new Gtk::ComboBox()) );
}
void GlyphComboBox::update(SPFont* spfont){
- if (!spfont) return
+ if (!spfont) return
//TODO: figure out why do we need to append_text("") before clearing items properly...
- this->append_text(""); //Gtk is refusing to clear the combobox when I comment out this line
+ this->append_text(""); //Gtk is refusing to clear the combobox when I comment out this line
this->clear_items();
for(SPObject* node = spfont->children; node; node=node->next){
}
void SvgFontsDialog::on_kerning_value_changed(){
- if (!this->kerning_pair) return;
- SPDocument* document = sp_desktop_document(this->getDesktop());
+ if (!this->kerning_pair) return;
+ SPDocument* document = sp_desktop_document(this->getDesktop());
- //TODO: I am unsure whether this is the correct way of calling sp_document_maybe_done
+ //TODO: I am unsure whether this is the correct way of calling sp_document_maybe_done
Glib::ustring undokey = "svgfonts:hkern:k:";
undokey += this->kerning_pair->u1->attribute_string();
undokey += ":";
undokey += this->kerning_pair->u2->attribute_string();
- //slider values increase from right to left so that they match the kerning pair preview
+ //slider values increase from right to left so that they match the kerning pair preview
this->kerning_pair->repr->setAttribute("k", Glib::Ascii::dtostr(get_selected_spfont()->horiz_adv_x - kerning_slider.get_value()).c_str());
sp_document_maybe_done(document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, _("Adjust kerning value"));
- //populate_kerning_pairs_box();
+ //populate_kerning_pairs_box();
kerning_preview.redraw();
_font_da.redraw();
}
global_vbox.set_sensitive(false);
glyphs_vbox.set_sensitive(false);
kerning_vbox.set_sensitive(false);
- }
+ }
}
/* Add all fonts in the document to the combobox. */
row[_columns.label] = lbl ? lbl : (id ? id : "font");
}
- update_sensitiveness();
+ update_sensitiveness();
}
void SvgFontsDialog::on_preview_text_changed(){
}
void SvgFontsDialog::on_kerning_pair_selection_changed(){
- SPGlyphKerning* kern = get_selected_kerning_pair();
- if (!kern) {
- kerning_preview.set_text("");
- return;
- }
- Glib::ustring str;
- str += kern->u1->sample_glyph();
- str += kern->u2->sample_glyph();
+ SPGlyphKerning* kern = get_selected_kerning_pair();
+ if (!kern) {
+ kerning_preview.set_text("");
+ return;
+ }
+ Glib::ustring str;
+ str += kern->u1->sample_glyph();
+ str += kern->u2->sample_glyph();
- kerning_preview.set_text(str);
- this->kerning_pair = kern;
+ kerning_preview.set_text(str);
+ this->kerning_pair = kern;
- //slider values increase from right to left so that they match the kerning pair preview
- kerning_slider.set_value(get_selected_spfont()->horiz_adv_x - kern->k);
+ //slider values increase from right to left so that they match the kerning pair preview
+ kerning_slider.set_value(get_selected_spfont()->horiz_adv_x - kern->k);
}
void SvgFontsDialog::update_global_settings_tab(){
- SPFont* font = get_selected_spfont();
- if (!font) return;
+ SPFont* font = get_selected_spfont();
+ if (!font) return;
- SPObject* obj;
- for (obj=font->children; obj; obj=obj->next){
- if (SP_IS_FONTFACE(obj)){
- _familyname_entry->set_text(((SPFontFace*) obj)->font_family);
- }
- }
+ SPObject* obj;
+ for (obj=font->children; obj; obj=obj->next){
+ if (SP_IS_FONTFACE(obj)){
+ _familyname_entry->set_text(((SPFontFace*) obj)->font_family);
+ }
+ }
}
void SvgFontsDialog::on_font_selection_changed(){
kerning_slider.set_draw_value(false);
kerning_slider.set_value(0);
- update_global_settings_tab();
- populate_glyphs_box();
- populate_kerning_pairs_box();
- update_sensitiveness();
+ update_global_settings_tab();
+ populate_glyphs_box();
+ populate_kerning_pairs_box();
+ update_sensitiveness();
}
void SvgFontsDialog::on_setwidth_changed(){
if (spfont){
spfont->horiz_adv_x = setwidth_spin.get_value();
//TODO: tell cairo that the glyphs cache has to be invalidated
- // The current solution is to recreate the whole cairo svgfont.
- // This is not a good solution to the issue because big fonts will result in poor performance.
+ // The current solution is to recreate the whole cairo svgfont.
+ // This is not a good solution to the issue because big fonts will result in poor performance.
update_glyphs();
}
}
void
SvgFontsDialog::populate_glyphs_box()
{
- if (!_GlyphsListStore) return;
+ if (!_GlyphsListStore) return;
_GlyphsListStore->clear();
- SPFont* spfont = this->get_selected_spfont();
- _glyphs_observer.set(spfont);
+ SPFont* spfont = this->get_selected_spfont();
+ _glyphs_observer.set(spfont);
for(SPObject* node = spfont->children; node; node=node->next){
- if (SP_IS_GLYPH(node)){
- Gtk::TreeModel::Row row = *(_GlyphsListStore->append());
- row[_GlyphsListColumns.glyph_node] = (SPGlyph*) node;
- row[_GlyphsListColumns.glyph_name] = ((SPGlyph*) node)->glyph_name;
- row[_GlyphsListColumns.unicode] = ((SPGlyph*) node)->unicode;
- }
+ if (SP_IS_GLYPH(node)){
+ Gtk::TreeModel::Row row = *(_GlyphsListStore->append());
+ row[_GlyphsListColumns.glyph_node] = (SPGlyph*) node;
+ row[_GlyphsListColumns.glyph_name] = ((SPGlyph*) node)->glyph_name;
+ row[_GlyphsListColumns.unicode] = ((SPGlyph*) node)->unicode;
+ }
}
}
void
SvgFontsDialog::populate_kerning_pairs_box()
{
- if (!_KerningPairsListStore) return;
+ if (!_KerningPairsListStore) return;
_KerningPairsListStore->clear();
- SPFont* spfont = this->get_selected_spfont();
+ SPFont* spfont = this->get_selected_spfont();
for(SPObject* node = spfont->children; node; node=node->next){
- if (SP_IS_HKERN(node)){
- Gtk::TreeModel::Row row = *(_KerningPairsListStore->append());
- row[_KerningPairsListColumns.first_glyph] = ((SPGlyphKerning*) node)->u1->attribute_string().c_str();
- row[_KerningPairsListColumns.second_glyph] = ((SPGlyphKerning*) node)->u2->attribute_string().c_str();
- row[_KerningPairsListColumns.kerning_value] = ((SPGlyphKerning*) node)->k;
- row[_KerningPairsListColumns.spnode] = (SPGlyphKerning*) node;
- }
+ if (SP_IS_HKERN(node)){
+ Gtk::TreeModel::Row row = *(_KerningPairsListStore->append());
+ row[_KerningPairsListColumns.first_glyph] = ((SPGlyphKerning*) node)->u1->attribute_string().c_str();
+ row[_KerningPairsListColumns.second_glyph] = ((SPGlyphKerning*) node)->u2->attribute_string().c_str();
+ row[_KerningPairsListColumns.kerning_value] = ((SPGlyphKerning*) node)->k;
+ row[_KerningPairsListColumns.spnode] = (SPGlyphKerning*) node;
+ }
}
}
// get corresponding object
SPGlyph *g = SP_GLYPH( document->getObjectByRepr(repr) );
-
+
g_assert(g != NULL);
g_assert(SP_IS_GLYPH(g));
}
void SvgFontsDialog::update_glyphs(){
- SPFont* font = get_selected_spfont();
- if (!font) return;
+ SPFont* font = get_selected_spfont();
+ if (!font) return;
populate_glyphs_box();
populate_kerning_pairs_box();
first_glyph.update(font);
second_glyph.update(font);
- get_selected_svgfont()->refresh();
+ get_selected_svgfont()->refresh();
_font_da.redraw();
}
sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add glyph"));
- update_glyphs();
+ update_glyphs();
}
void SvgFontsDialog::set_glyph_description_from_selected_path(){
if (sel->isEmpty()) return;
Inkscape::XML::Node* node = (Inkscape::XML::Node*) g_slist_nth_data((GSList *)sel->reprList(), 0);
if (!node || !node->matchAttributeName("d")) return;
- if (!node->attribute("d")) return; //TODO: give a message to the user
+ if (!node->attribute("d")) return; //TODO: give a message to the user
- Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d"));
+ Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d"));
- //This matrix flips the glyph vertically
+ //This matrix flips the glyph vertically
Geom::Matrix m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(0));
- pathv*=m;
- //then we offset it
- pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(get_selected_spfont()->horiz_adv_x));
+ pathv*=m;
+ //then we offset it
+ pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(get_selected_spfont()->horiz_adv_x));
- get_selected_glyph()->repr->setAttribute("d", (char*) sp_svg_write_path (pathv));
- sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves"));
+ get_selected_glyph()->repr->setAttribute("d", (char*) sp_svg_write_path (pathv));
+ sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves"));
- update_glyphs();
+ update_glyphs();
}
void SvgFontsDialog::missing_glyph_description_from_selected_path(){
if (sel->isEmpty()) return;
Inkscape::XML::Node* node = (Inkscape::XML::Node*) g_slist_nth_data((GSList *)sel->reprList(), 0);
if (!node || !node->matchAttributeName("d")) return;
- if (!node->attribute("d")) return; //TODO: give a message to the user
+ if (!node->attribute("d")) return; //TODO: give a message to the user
- Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d"));
+ Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d"));
- //This matrix flips the glyph vertically
+ //This matrix flips the glyph vertically
Geom::Matrix m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(0));
- pathv*=m;
- //then we offset it
-// pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(get_selected_spfont()->horiz_adv_x));
- pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(1000));//TODO: use here the units-per-em attribute?
-
- SPObject* obj;
- for (obj = get_selected_spfont()->children; obj; obj=obj->next){
- if (SP_IS_MISSING_GLYPH(obj)){
- obj->repr->setAttribute("d", (char*) sp_svg_write_path (pathv));
- sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves"));
- }
- }
+ pathv*=m;
+ //then we offset it
+// pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(get_selected_spfont()->horiz_adv_x));
+ pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(1000));//TODO: use here the units-per-em attribute?
+
+ SPObject* obj;
+ for (obj = get_selected_spfont()->children; obj; obj=obj->next){
+ if (SP_IS_MISSING_GLYPH(obj)){
+ obj->repr->setAttribute("d", (char*) sp_svg_write_path (pathv));
+ sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves"));
+ }
+ }
- update_glyphs();
+ update_glyphs();
}
void SvgFontsDialog::glyph_name_edit(const Glib::ustring&, const Glib::ustring& str){
- Gtk::TreeModel::iterator i = _GlyphsList.get_selection()->get_selected();
- if (!i) return;
+ Gtk::TreeModel::iterator i = _GlyphsList.get_selection()->get_selected();
+ if (!i) return;
- SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node];
- glyph->repr->setAttribute("glyph-name", str.c_str());
+ SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node];
+ glyph->repr->setAttribute("glyph-name", str.c_str());
SPDocument* doc = sp_desktop_document(this->getDesktop());
- sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Edit glyph name"));
+ sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Edit glyph name"));
- update_glyphs();
+ update_glyphs();
}
void SvgFontsDialog::glyph_unicode_edit(const Glib::ustring&, const Glib::ustring& str){
- Gtk::TreeModel::iterator i = _GlyphsList.get_selection()->get_selected();
- if (!i) return;
+ Gtk::TreeModel::iterator i = _GlyphsList.get_selection()->get_selected();
+ if (!i) return;
- SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node];
- glyph->repr->setAttribute("unicode", str.c_str());
+ SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node];
+ glyph->repr->setAttribute("unicode", str.c_str());
SPDocument* doc = sp_desktop_document(this->getDesktop());
- sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph unicode"));
+ sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph unicode"));
- update_glyphs();
+ update_glyphs();
}
void SvgFontsDialog::remove_selected_font(){
- SPFont* font = get_selected_spfont();
+ SPFont* font = get_selected_spfont();
sp_repr_unparent(font->repr);
SPDocument* doc = sp_desktop_document(this->getDesktop());
Gtk::TreeModel::iterator i = _GlyphsList.get_selection()->get_selected();
if(!i) return;
- SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node];
+ SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node];
sp_repr_unparent(glyph->repr);
SPDocument* doc = sp_desktop_document(this->getDesktop());
Gtk::TreeModel::iterator i = _KerningPairsList.get_selection()->get_selected();
if(!i) return;
- SPGlyphKerning* pair = (*i)[_KerningPairsListColumns.spnode];
+ SPGlyphKerning* pair = (*i)[_KerningPairsListColumns.spnode];
sp_repr_unparent(pair->repr);
SPDocument* doc = sp_desktop_document(this->getDesktop());
Gtk::HBox* missing_glyph_hbox = Gtk::manage(new Gtk::HBox());
Gtk::Label* missing_glyph_label = Gtk::manage(new Gtk::Label(_("Missing Glyph:")));
- missing_glyph_hbox->pack_start(*missing_glyph_label, false,false);
- missing_glyph_hbox->pack_start(missing_glyph_button, false,false);
- missing_glyph_button.set_label(_("From selection..."));
+ missing_glyph_hbox->pack_start(*missing_glyph_label, false,false);
+ missing_glyph_hbox->pack_start(missing_glyph_button, false,false);
+ missing_glyph_button.set_label(_("From selection..."));
missing_glyph_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::missing_glyph_description_from_selected_path));
- glyphs_vbox.pack_start(*missing_glyph_hbox, false,false);
+ glyphs_vbox.pack_start(*missing_glyph_hbox, false,false);
- glyphs_vbox.add(_GlyphsListScroller);
- _GlyphsListScroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
+ glyphs_vbox.add(_GlyphsListScroller);
+ _GlyphsListScroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
_GlyphsListScroller.set_size_request(-1, 290);//It seems that is does not work. Why? I want a box with larger height
- _GlyphsListScroller.add(_GlyphsList);
+ _GlyphsListScroller.add(_GlyphsList);
_GlyphsListStore = Gtk::ListStore::create(_GlyphsListColumns);
_GlyphsList.set_model(_GlyphsListStore);
_GlyphsList.append_column_editable(_("Glyph Name"), _GlyphsListColumns.glyph_name);
_GlyphsList.append_column_editable(_("Unicode"), _GlyphsListColumns.unicode);
Gtk::HBox* hb = Gtk::manage(new Gtk::HBox());
- add_glyph_button.set_label(_("Add Glyph"));
- add_glyph_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::add_glyph));
+ add_glyph_button.set_label(_("Add Glyph"));
+ add_glyph_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::add_glyph));
- hb->pack_start(add_glyph_button, false,false);
- hb->pack_start(glyph_from_path_button, false,false);
+ hb->pack_start(add_glyph_button, false,false);
+ hb->pack_start(glyph_from_path_button, false,false);
- glyphs_vbox.pack_start(*hb, false, false);
- glyph_from_path_button.set_label(_("Get curves from selection..."));
+ glyphs_vbox.pack_start(*hb, false, false);
+ glyph_from_path_button.set_label(_("Get curves from selection..."));
glyph_from_path_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::set_glyph_description_from_selected_path));
- dynamic_cast<Gtk::CellRendererText*>( _GlyphsList.get_column_cell_renderer(0))->signal_edited().connect(
- sigc::mem_fun(*this, &SvgFontsDialog::glyph_name_edit));
+ dynamic_cast<Gtk::CellRendererText*>( _GlyphsList.get_column_cell_renderer(0))->signal_edited().connect(
+ sigc::mem_fun(*this, &SvgFontsDialog::glyph_name_edit));
- dynamic_cast<Gtk::CellRendererText*>( _GlyphsList.get_column_cell_renderer(1))->signal_edited().connect(
- sigc::mem_fun(*this, &SvgFontsDialog::glyph_unicode_edit));
+ dynamic_cast<Gtk::CellRendererText*>( _GlyphsList.get_column_cell_renderer(1))->signal_edited().connect(
+ sigc::mem_fun(*this, &SvgFontsDialog::glyph_unicode_edit));
- _glyphs_observer.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::update_glyphs));
+ _glyphs_observer.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::update_glyphs));
return &glyphs_vbox;
}
void SvgFontsDialog::add_kerning_pair(){
- if (first_glyph.get_active_text() == "" ||
- second_glyph.get_active_text() == "") return;
+ if (first_glyph.get_active_text() == "" ||
+ second_glyph.get_active_text() == "") return;
//look for this kerning pair on the currently selected font
this->kerning_pair = NULL;
for(SPObject* node = this->get_selected_spfont()->children; node; node=node->next){
- //TODO: It is not really correct to get only the first byte of each string.
- //TODO: We should also support vertical kerning
+ //TODO: It is not really correct to get only the first byte of each string.
+ //TODO: We should also support vertical kerning
if (SP_IS_HKERN(node) && ((SPGlyphKerning*)node)->u1->contains((gchar) first_glyph.get_active_text().c_str()[0])
- && ((SPGlyphKerning*)node)->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){
+ && ((SPGlyphKerning*)node)->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){
this->kerning_pair = (SPGlyphKerning*)node;
continue;
}
if (this->kerning_pair) return; //We already have this kerning pair
- SPDocument* document = sp_desktop_document(this->getDesktop());
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
+ SPDocument* document = sp_desktop_document(this->getDesktop());
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
// create a new hkern node
- Inkscape::XML::Node *repr;
+ Inkscape::XML::Node *repr;
repr = xml_doc->createElement("svg:hkern");
- repr->setAttribute("u1", first_glyph.get_active_text().c_str());
- repr->setAttribute("u2", second_glyph.get_active_text().c_str());
- repr->setAttribute("k", "0");
+ repr->setAttribute("u1", first_glyph.get_active_text().c_str());
+ repr->setAttribute("u2", second_glyph.get_active_text().c_str());
+ repr->setAttribute("k", "0");
// Append the new hkern node to the current font
- SP_OBJECT_REPR(get_selected_spfont())->appendChild(repr);
- Inkscape::GC::release(repr);
+ SP_OBJECT_REPR(get_selected_spfont())->appendChild(repr);
+ Inkscape::GC::release(repr);
- // get corresponding object
+ // get corresponding object
this->kerning_pair = SP_HKERN( document->getObjectByRepr(repr) );
sp_document_done(document, SP_VERB_DIALOG_SVG_FONTS, _("Add kerning pair"));
kerning_selector->add(*Gtk::manage(new Gtk::Label(_("2nd Glyph:"))));
kerning_selector->add(second_glyph);
kerning_selector->add(add_kernpair_button);
- add_kernpair_button.set_label(_("Add pair"));
- add_kernpair_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::add_kerning_pair));
+ add_kernpair_button.set_label(_("Add pair"));
+ add_kernpair_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::add_kerning_pair));
_KerningPairsList.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_kerning_pair_selection_changed));
kerning_slider.signal_value_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_kerning_value_changed));
kerning_vbox.pack_start(*kerning_selector, false,false);
- kerning_vbox.add(_KerningPairsListScroller);
- _KerningPairsListScroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
- _KerningPairsListScroller.add(_KerningPairsList);
+ kerning_vbox.add(_KerningPairsListScroller);
+ _KerningPairsListScroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
+ _KerningPairsListScroller.add(_KerningPairsList);
_KerningPairsListStore = Gtk::ListStore::create(_KerningPairsListColumns);
_KerningPairsList.set_model(_KerningPairsListStore);
_KerningPairsList.append_column(_("First Unicode range"), _KerningPairsListColumns.first_glyph);
// create a new font
Inkscape::XML::Node *repr;
repr = xml_doc->createElement("svg:font");
-
- //By default, set the horizontal advance to 1024 units
- repr->setAttribute("horiz-adv-x", "1024");
+
+ //By default, set the horizontal advance to 1024 units
+ repr->setAttribute("horiz-adv-x", "1024");
// Append the new font node to defs
SP_OBJECT_REPR(defs)->appendChild(repr);
- //create a missing glyph
+ //create a missing glyph
Inkscape::XML::Node *fontface;
fontface = xml_doc->createElement("svg:font-face");
- fontface->setAttribute("units-per-em", "1024");
+ fontface->setAttribute("units-per-em", "1024");
repr->appendChild(fontface);
- //create a missing glyph
+ //create a missing glyph
Inkscape::XML::Node *mg;
mg = xml_doc->createElement("svg:missing-glyph");
- mg->setAttribute("d", "M0,0h1020v1024h-1020z");
+ mg->setAttribute("d", "M0,0h1020v1024h-1020z");
repr->appendChild(mg);
// get corresponding object
SPFont *f = SP_FONT( document->getObjectByRepr(repr) );
-
+
g_assert(f != NULL);
g_assert(SP_IS_FONT(f));
Inkscape::GC::release(mg);
}
void set_font_family(SPFont* font, char* str){
- if (!font) return;
- SPObject* obj;
- for (obj=font->children; obj; obj=obj->next){
- if (SP_IS_FONTFACE(obj)){
- obj->repr->setAttribute("font-family", str);
- }
- }
+ if (!font) return;
+ SPObject* obj;
+ for (obj=font->children; obj; obj=obj->next){
+ if (SP_IS_FONTFACE(obj)){
+ obj->repr->setAttribute("font-family", str);
+ }
+ }
sp_document_done(font->document, SP_VERB_DIALOG_SVG_FONTS, _("Set font family"));
}
font->setLabel(os.str().c_str());
os2 << "SVGFont " << count;
- SPObject* obj;
- for (obj=font->children; obj; obj=obj->next){
- if (SP_IS_FONTFACE(obj)){
- obj->repr->setAttribute("font-family", os2.str().c_str());
- }
- }
+ SPObject* obj;
+ for (obj=font->children; obj; obj=obj->next){
+ if (SP_IS_FONTFACE(obj)){
+ obj->repr->setAttribute("font-family", os2.str().c_str());
+ }
+ }
update_fonts();
// select_font(font);
_FontsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &SvgFontsDialog::fonts_list_button_release));
create_fonts_popup_menu(_FontsList, sigc::mem_fun(*this, &SvgFontsDialog::remove_selected_font));
-
- _defs_observer.set(SP_DOCUMENT_DEFS(sp_desktop_document(this->getDesktop())));
- _defs_observer.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::update_fonts));
+
+ _defs_observer.set(SP_DOCUMENT_DEFS(sp_desktop_document(this->getDesktop())));
+ _defs_observer.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::update_fonts));
_getContents()->show_all();
}
} // namespace Inkscape
#endif //#ifdef ENABLE_SVG_FONTS
+
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp
index 7f45901c3259f5fe9a099a36779eda90d5d7ec37..5741fee4d469016fd570f5136dd44c1633b43119 100644 (file)
--- a/src/ui/dialog/tile.cpp
+++ b/src/ui/dialog/tile.cpp
double const a_height = a->dimensions()[Y];
double const b_height = b->dimensions()[Y];
-
+
bool a_in_b_vert = false;
if ((a->min()[Y] < b->min()[Y] + 0.1) && (a->min()[Y] > b->min()[Y] - b_height)) {
a_in_b_vert = true;
if (a->min()[Geom::Y] < b->min()[Geom::Y]) {
return -1;
}
-
+
return 0;
}
g_slist_free (current_row);
}
- sp_document_done (sp_desktop_document (desktop), SP_VERB_SELECTION_GRIDTILE,
+ sp_document_done (sp_desktop_document (desktop), SP_VERB_SELECTION_GRIDTILE,
_("Arrange in a grid"));
}
void TileDialog::_apply()
{
- Grid_Arrange();
+ Grid_Arrange();
}
}
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- double col_width = 0;
- double row_height = 0;
// in turn, prevent listener from responding
updating = true;
SPDesktop *desktop = getDesktop();
index e84eaa45834da4294eedf9915887529a50bdb908..e21410df6f187c1037c08ee2d73c7341f546fd84 100644 (file)
{
this->changed_signal.emit(this->get_active());
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-
+
if (this->is_visible() && this->get_active() ) //only take action if toggled by user (to active)
{
if ( _value_type == VAL_STRING )
void
PrefSlider::init(Glib::ustring const &prefs_path,
- double lower, double upper, double step_increment, double page_increment, double default_value, int digits)
+ double lower, double upper, double step_increment, double page_increment, double default_value, int digits)
{
- _prefs_path = prefs_path;
-
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ _prefs_path = prefs_path;
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
double value = prefs->getDoubleLimited(prefs_path, default_value, lower, upper);
freeze = false;
Gtk::Table *table = Gtk::manage(new Gtk::Table());
Gtk::Alignment *alignment1 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0));
- Gtk::Alignment *alignment2 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0));
alignment1->add(_sb);
-
+
table->attach(_slider, 0, 1, 0, 1);
table->attach(*alignment1, 1, 2, 0, 1, static_cast<Gtk::AttachOptions>(0));
-
+
this->pack_start(*table, Gtk::PACK_EXPAND_WIDGET);
}
/**
initialize a combo box
- second form uses strings as key values
+ second form uses strings as key values
*/
void PrefCombo::init(Glib::ustring const &prefs_path,
Glib::ustring labels[], Glib::ustring values[], int num_items, Glib::ustring default_value)