diff options
Diffstat (limited to 'src/libnrtype')
| -rw-r--r-- | src/libnrtype/Layout-TNG-Compute.cpp | 35 | ||||
| -rw-r--r-- | src/libnrtype/Layout-TNG-Scanline-Makers.cpp | 8 |
2 files changed, 29 insertions, 14 deletions
diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp index 2ae13efa6..cd86d2450 100644 --- a/src/libnrtype/Layout-TNG-Compute.cpp +++ b/src/libnrtype/Layout-TNG-Compute.cpp @@ -475,14 +475,18 @@ static void dumpUnbrokenSpans(ParagraphInfo *para){ Layout::Line new_line; new_line.in_paragraph = _flow._paragraphs.size() - 1; new_line.baseline_y = _scanline_maker->yCoordinate(); - if( !_flow._input_wrap_shapes.empty() ) { - // Flowed text - if( _block_progression == RIGHT_TO_LEFT || _block_progression == LEFT_TO_RIGHT ) { - // Vertical text, use em box center as baseline - new_line.baseline_y += 0.5 * line_height.emSize(); - } else { - new_line.baseline_y += line_height.getTypoAscent(); - } + + // The y coordinate is at the beginning edge of the line box (top for horizontal text, left + // edge for vertical lr text, right edge for vertical rl text. We align, by default to the + // alphabetic baseline for horizontal text and the central baseline for vertical text. + if( _block_progression == RIGHT_TO_LEFT ) { + // Vertical text, use em box center as baseline + new_line.baseline_y -= 0.5 * line_height.emSize(); + } else if ( _block_progression == LEFT_TO_RIGHT ) { + // Vertical text, use em box center as baseline + new_line.baseline_y += 0.5 * line_height.emSize(); + } else { + new_line.baseline_y += line_height.getTypoAscent(); } new_line.in_shape = _current_shape_index; @@ -533,8 +537,19 @@ static void dumpUnbrokenSpans(ParagraphInfo *para){ // Save baseline _flow._lines.back().baseline_y = new_line.baseline_y; - // Set the initial y coordinate of the next line. - _scanline_maker->setNewYCoordinate(new_line.baseline_y); + double top_of_line_box = new_line.baseline_y; + if( _block_progression == RIGHT_TO_LEFT ) { + // Vertical text, use em box center as baseline + top_of_line_box += 0.5 * line_height.emSize(); + } else if (_block_progression == LEFT_TO_RIGHT ) { + // Vertical text, use em box center as baseline + top_of_line_box -= 0.5 * line_height.emSize(); + } else { + top_of_line_box -= line_height.getTypoAscent(); + } + + // Set the initial y coordinate of the next line (see above). + _scanline_maker->setNewYCoordinate(top_of_line_box); } // Reset relative y_offset ("dy" attribute is relative but should be reset at diff --git a/src/libnrtype/Layout-TNG-Scanline-Makers.cpp b/src/libnrtype/Layout-TNG-Scanline-Makers.cpp index 67fffd620..ea487a597 100644 --- a/src/libnrtype/Layout-TNG-Scanline-Makers.cpp +++ b/src/libnrtype/Layout-TNG-Scanline-Makers.cpp @@ -141,7 +141,7 @@ std::vector<Layout::ScanlineMaker::ScanRun> Layout::ShapeScanlineMaker::makeScan std::vector<ScanRun> result(1); result[0].x_start = line_rasterization.runs[0].st; result[0].x_end = line_rasterization.runs[0].st; - result[0].y = _negative_block_progression ? -_current_line_height - _y : _y; + result[0].y = _negative_block_progression ? - _y : _y; return result; } @@ -150,7 +150,7 @@ std::vector<Layout::ScanlineMaker::ScanRun> Layout::ShapeScanlineMaker::makeScan for (unsigned i = 0 ; i < result.size() ; i++) { result[i].x_start = line_decent_length_runs.runs[i].st; result[i].x_end = line_decent_length_runs.runs[i].en; - result[i].y = _negative_block_progression ? -_current_line_height - _y : _y; + result[i].y = _negative_block_progression ? - _y : _y; } return result; @@ -163,14 +163,14 @@ void Layout::ShapeScanlineMaker::completeLine() double Layout::ShapeScanlineMaker::yCoordinate() { - if (_negative_block_progression) return -_current_line_height - _y; + if (_negative_block_progression) return - _y; return _y; } void Layout::ShapeScanlineMaker::setNewYCoordinate(double new_y) { _y = (float)new_y; - if (_negative_block_progression) _y = -_current_line_height - _y; + if (_negative_block_progression) _y = - _y; // what will happen with the rasteriser if we move off the shape? // it's not an important question because <flowSpan> doesn't have a y attribute } |
