summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2010-07-25 07:22:23 +0000
committertavmjong-free <tavmjong@free.fr>2010-07-25 07:22:23 +0000
commitf609e7dd0247868da596d0ee1327a9146e35290d (patch)
tree9bade4ada3461dad92911ba433e2ff0b22007159 /src
parentPixmap fix by Leo Jackson (diff)
downloadinkscape-f609e7dd0247868da596d0ee1327a9146e35290d.tar.gz
inkscape-f609e7dd0247868da596d0ee1327a9146e35290d.zip
Fix rendering of "plain" SVG text.
(bzr r9606.1.22)
Diffstat (limited to 'src')
-rw-r--r--src/libnrtype/Layout-TNG-Compute.cpp41
-rw-r--r--src/sp-text.cpp2
2 files changed, 31 insertions, 12 deletions
diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp
index 192596ecf..77e21ef56 100644
--- a/src/libnrtype/Layout-TNG-Compute.cpp
+++ b/src/libnrtype/Layout-TNG-Compute.cpp
@@ -445,22 +445,32 @@ class Layout::Calculator
// we may also have y move orders to deal with here (dx, dy and rotate are done per span)
- // Comment added: 1 June 2010:
- // The first line in a normal <text> object is placed by the read-in "y" value. The rest are
- // determined by Inkscape. This is to allow insertation of new lines in the middle
- // of a <text> object. New "y" values are then stored in each <tspan> that represents
- // a new line. The line spacing should depend only on font-size and line-height (and not
- // on any y-kerning). Line spacing is already handled by the calling routine. Note that
- // this may render improperly any SVG with <tspan>s created/edited by other programs.
+ // Comment updated: 23 July 2010:
+ // We must handle two cases:
+ //
+ // 1. Inkscape SVG where the first line is placed by the read-in "y" value and the
+ // rest are determined by 'font-size' and 'line-height' (and not by any
+ // y-kerning). <tspan>s in this case are marked by sodipodi:role="line". This
+ // allows new lines to be inserted in the middle of a <text> object. On output,
+ // new "y" values are calculated for each <tspan> that represents a new line. Line
+ // spacing is already handled by the calling routine.
+ //
+ // 2. Plain SVG where each <text> or <tspan> is placed by its own "x" and "y" values.
+ // Note that in this case Inkscape treats each <text> object with any included
+ // <tspan>s as a single line of text. This can be confusing in the code below.
+
if (!it_chunk->broken_spans.empty() // Not empty paragraph
&& it_chunk->broken_spans.front().start.char_byte == 0 ) { // Beginning of unbroken span
- // If empty or new line
+ // If empty or new line (sodipode:role="line")
if( _flow._characters.empty() ||
_flow._characters.back().chunk(&_flow).in_line != _flow._lines.size() - 1) {
+ // This is the Inkscape SVG case.
+ //
// If <tspan> "y" attribute is set, use it (initial "y" attributes in
- // <tspans> other than the first have already been stripped).
+ // <tspans> other than the first have already been stripped for <tspans>
+ // marked with role="line", see sp-text.cpp: SPText::_buildLayoutInput).
if( it_chunk->broken_spans.front().start.iter_span->y._set ) {
// Use set "y" attribute
@@ -475,9 +485,17 @@ class Layout::Calculator
}
// Reset relative y_offset ("dy" attribute is relative but should be reset at
- // the beginning of each <tspan>.)
+ // the beginning of each line since each line will have a new "y" written out.)
_y_offset = 0.0;
+ } else {
+
+ // This is the plain SVG case
+ //
+ // "x" and "y" are used to place text, simulating lines as necessary
+ if( it_chunk->broken_spans.front().start.iter_span->y._set ) {
+ _y_offset = it_chunk->broken_spans.front().start.iter_span->y.computed - new_line.baseline_y;
+ }
}
}
_flow._chunks.push_back(new_chunk);
@@ -1243,8 +1261,9 @@ bool Layout::Calculator::_findChunksForLine(ParagraphInfo const &para,
UnbrokenSpanPosition span_pos;
for( ; ; ) {
std::vector<ScanlineMaker::ScanRun> scan_runs;
- scan_runs = _scanline_maker->makeScanline(*line_height);
+ scan_runs = _scanline_maker->makeScanline(*line_height); // Only one line with "InfiniteScanlineMaker
while (scan_runs.empty()) {
+ // Only used by ShapeScanlineMaker
if (!_goToNextWrapShape()) return false; // no more shapes to wrap in to
scan_runs = _scanline_maker->makeScanline(*line_height);
}
diff --git a/src/sp-text.cpp b/src/sp-text.cpp
index bae625f58..36f67aa88 100644
--- a/src/sp-text.cpp
+++ b/src/sp-text.cpp
@@ -528,7 +528,7 @@ unsigned SPText::_buildLayoutInput(SPObject *root, Inkscape::Text::Layout::Optio
}
else if (SP_IS_TSPAN(root)) {
SPTSpan *tspan = SP_TSPAN(root);
- // x, y attributes are stripped from some tspans as we do our own line layout
+ // x, y attributes are stripped from some tspans marked with role="line" as we do our own line layout.
// This should be checked carefully, as it can undo line layout in imported SVG files.
bool use_xy = !in_textpath && (tspan->role == SP_TSPAN_ROLE_UNSPECIFIED || !tspan->attributes.singleXYCoordinates());
tspan->attributes.mergeInto(&optional_attrs, parent_optional_attrs, parent_attrs_offset, use_xy, true);