summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authormiklosh <miklosh@users.sourceforge.net>2007-08-17 12:06:38 +0000
committermiklosh <miklosh@users.sourceforge.net>2007-08-17 12:06:38 +0000
commit84d2e3121ecfd08b25e80e0c5d4af7742a885921 (patch)
treed420973a919435f583c9eeb5d09ab64d51278de6 /src
parentAdded initial transparency group and softmask support (diff)
downloadinkscape-84d2e3121ecfd08b25e80e0c5d4af7742a885921.tar.gz
inkscape-84d2e3121ecfd08b25e80e0c5d4af7742a885921.zip
Optimized text output by not repeating glyph coordinates when they are identical
(bzr r3492)
Diffstat (limited to 'src')
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index c2b467499..28da78d09 100644
--- a/src/extension/internal/pdfinput/svg-builder.cpp
+++ b/src/extension/internal/pdfinput/svg-builder.cpp
@@ -1083,6 +1083,8 @@ void SvgBuilder::_flushText() {
g_free(transform);
bool new_tspan = true;
+ bool same_coords[2] = {true, true};
+ NR::Point last_delta_pos;
unsigned int glyphs_in_a_row = 0;
Inkscape::XML::Node *tspan_node = NULL;
Glib::ustring x_coords;
@@ -1111,8 +1113,16 @@ void SvgBuilder::_flushText() {
if ( new_tspan || i == _glyphs.end() ) {
if (tspan_node) {
// Set the x and y coordinate arrays
- tspan_node->setAttribute("x", x_coords.c_str());
- tspan_node->setAttribute("y", y_coords.c_str());
+ if ( same_coords[0] ) {
+ sp_repr_set_svg_double(tspan_node, "x", last_delta_pos[0]);
+ } else {
+ tspan_node->setAttribute("x", x_coords.c_str());
+ }
+ if ( same_coords[1] ) {
+ sp_repr_set_svg_double(tspan_node, "y", last_delta_pos[1]);
+ } else {
+ tspan_node->setAttribute("y", y_coords.c_str());
+ }
TRACE(("tspan content: %s\n", text_buffer.c_str()));
if ( glyphs_in_a_row > 1 ) {
tspan_node->setAttribute("sodipodi:role", "line");
@@ -1146,6 +1156,13 @@ void SvgBuilder::_flushText() {
if ( glyphs_in_a_row > 0 ) {
x_coords.append(" ");
y_coords.append(" ");
+ // Check if we have the same coordinates
+ const SvgGlyph& prev_glyph = (*prev_iterator);
+ for ( int p = 0 ; p < 2 ; p++ ) {
+ if ( glyph.text_position[p] != prev_glyph.text_position[p] ) {
+ same_coords[p] = false;
+ }
+ }
}
// Append the coordinates to their respective strings
NR::Point delta_pos( glyph.text_position - first_glyph.text_position );
@@ -1158,6 +1175,7 @@ void SvgBuilder::_flushText() {
Inkscape::CSSOStringStream os_y;
os_y << delta_pos[1];
y_coords.append(os_y.str());
+ last_delta_pos = delta_pos;
// Append the character to the text buffer
text_buffer.append((char *)&glyph.code, 1);