diff options
| author | Felipe Corr??a da Silva Sanches <juca@members.fsf.org> | 2008-12-28 18:35:14 +0000 |
|---|---|---|
| committer | JucaBlues <JucaBlues@users.sourceforge.net> | 2008-12-28 18:35:14 +0000 |
| commit | c3e30311de25dc8b874ce99ccdb864e0a18cf7d6 (patch) | |
| tree | 1a9d0a2de159bd94fab214717136e1474d4db08c /src/display | |
| parent | Makes sure a Gaussian filter is applied to premultiplied data. (diff) | |
| download | inkscape-c3e30311de25dc8b874ce99ccdb864e0a18cf7d6.tar.gz inkscape-c3e30311de25dc8b874ce99ccdb864e0a18cf7d6.zip | |
Now users can design a font within inkscape, save it and then open the
SVG file in Fontforge in order to export a truetype font (or other
system font formarts fontforge supports).
This improves previous workflow of font design using Inkscape which
involved creating one SVG for each glyph. Now user only needs to create
a single SVG file containing an SVGFont.
Glyph kerning settings for the font can also be defined withing Inkscape
itself with live preview. The kerning management still needs some
improvements but is currently functional at least.
Improvements in the SVGFonts dialog:
* In Global Settings tab you can define the font family name. Other
attributes should be added to this tab in the future.
* Glyphs tab allows the user to:
** see a list (combobox) of glyphs available in the currently selected
font.
** add/remove glyphs
** edit glyph name and unicode
** set the glyph curves based on a given path (selected from canvas).
Same feature for the missing glyph.
* Kerning tab allows user to:
** add new kerning pairs
** adjust kerning values of selected kerning pair
** live preview while adjusting the kerning values
Code refactoring:
* Inner classes DocumentProperties::SignalObserver and
FilterEffectsDialog::SignalObserver were duplicated code and another
instance would be needed in SVGFonts dialog. So, I moved it to
Inkscape::XML::SignalObserver (in helper-observer.{cpp,h})
* changed SPGlyph->glyph_name and SPGlyph->unicode from char* to
Glib::ustring
* added sp_remove_resource to the release method in sp-font.cpp
* glyph curves used to be stored (in d attribute) and rendered
upside-down. Now that bug is fixed.
Sorry about this huge commit. I got one week away from the Internet
during a xmas travel. The lack of 'net connection made me work more
intensely in Inkscape :-D
Felipe Sanches
(bzr r7029)
Diffstat (limited to 'src/display')
| -rw-r--r-- | src/display/nr-svgfonts.cpp | 35 | ||||
| -rw-r--r-- | src/display/nr-svgfonts.h | 1 |
2 files changed, 23 insertions, 13 deletions
diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp index 723929ea7..633f4cddd 100644 --- a/src/display/nr-svgfonts.cpp +++ b/src/display/nr-svgfonts.cpp @@ -91,7 +91,7 @@ SvgFont::scaled_font_init (cairo_scaled_font_t *scaled_font, return CAIRO_STATUS_SUCCESS; } -unsigned int size_of_substring(gchar* substring, gchar* str){ +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){ @@ -129,7 +129,7 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, while(g_utf8_get_char(_utf8) != 0){ missing = true; for (i=0; i < (unsigned long) this->glyphs.size(); i++){ - if ( (len = size_of_substring(this->glyphs[i]->unicode, _utf8)) ){ + if ( (len = size_of_substring(this->glyphs[i]->unicode.c_str(), _utf8)) ){ //TODO: store this cluster _utf8+=len; count++; @@ -144,7 +144,6 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, } } -//g_warning("count is %d", count); //We use that info to allocate memory for the glyphs *glyphs = (cairo_glyph_t*) malloc(count*sizeof(cairo_glyph_t)); @@ -159,7 +158,7 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, while(g_utf8_get_char(_utf8) != 0){ len = 0; for (i=0; i < (unsigned long) this->glyphs.size(); i++){ - if ( (len = size_of_substring(this->glyphs[i]->unicode, _utf8)) ){ + if ( (len = size_of_substring(this->glyphs[i]->unicode.c_str(), _utf8)) ){ //check whether is there a glyph declared on the SVG document // that matches with the text string in its current position for(SPObject* node = this->font->children;previous_unicode && node;node=node->next){ @@ -168,7 +167,7 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, if ( (((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)) + || ((SPHkern*)node)->g2->contains(this->glyphs[i]->glyph_name.c_str())) )//TODO: verify what happens when using unicode strings. x -= (((SPHkern*)node)->k / this->font->horiz_adv_x); } @@ -176,13 +175,13 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, if ( (((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)) + || ((SPVkern*)node)->g2->contains(this->glyphs[i]->glyph_name.c_str())) )//TODO: idem y -= (((SPVkern*)node)->k / this->font->vert_adv_y); } } - previous_unicode = this->glyphs[i]->unicode;//used for kerning checking - previous_glyph_name = this->glyphs[i]->glyph_name;//used for kerning checking + 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; @@ -227,10 +226,8 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t *scaled_font, if (glyph == this->glyphs.size()){ if (!this->missingglyph) return CAIRO_STATUS_SUCCESS; node = (SPObject*) this->missingglyph; - g_warning("RENDER MISSING-GLYPH"); } else { node = (SPObject*) this->glyphs[glyph]; - g_warning("RENDER %s", this->glyphs[glyph]->unicode); } //glyphs can be described by arbitrary SVG declared in the childnodes of a glyph node @@ -248,9 +245,16 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t *scaled_font, 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 Geom::Scale s(1.0/((SPFont*) node->parent)->horiz_adv_x); + //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)); + 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() ) - feed_pathvector_to_cairo (cr, pathv, s, area, false, 0); + + feed_pathvector_to_cairo (cr, pathv, s*m, area, false, 0); cairo_fill(cr); } @@ -263,11 +267,9 @@ SvgFont::get_font_face(){ if (!this->userfont) { for(SPObject* node = this->font->children;node;node=node->next){ if (SP_IS_GLYPH(node)){ - g_warning("glyphs.push_back((SPGlyph*)node); (node->unicode='%s')", ((SPGlyph*)node)->unicode); this->glyphs.push_back((SPGlyph*)node); } if (SP_IS_MISSING_GLYPH(node)){ - g_warning("missingglyph=(SPMissingGlyph*)node;"); this->missingglyph=(SPMissingGlyph*)node; } } @@ -275,4 +277,11 @@ SvgFont::get_font_face(){ } return this->userfont->face; } + +void SvgFont::refresh(){ + this->glyphs.clear(); + delete this->userfont; + this->userfont = NULL; +} + #endif //#ifdef ENABLE_SVG_FONTS diff --git a/src/display/nr-svgfonts.h b/src/display/nr-svgfonts.h index a41627f86..ebf5ad08b 100644 --- a/src/display/nr-svgfonts.h +++ b/src/display/nr-svgfonts.h @@ -32,6 +32,7 @@ cairo_font_face_t* face; class SvgFont{ public: SvgFont(SPFont* spfont); +void refresh(); cairo_font_face_t* get_font_face(); cairo_status_t scaled_font_init (cairo_scaled_font_t *scaled_font, cairo_font_extents_t *metrics); cairo_status_t 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); |
