Skip to content

Commit

Permalink
Implement text rise for the SVG back-end
Browse files Browse the repository at this point in the history
The property and the setter for text rise were already present, but they
were never used or called. This patch completes the implementation by
calling the setter when the operator is encountered and by using the
text rise value when rendering text.
  • Loading branch information
timvandermeij committed Aug 19, 2017
1 parent 7969802 commit c2b4360
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/display/svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,9 @@ SVGGraphics = (function SVGGraphicsClosure() {
this.setTextMatrix(args[0], args[1], args[2],
args[3], args[4], args[5]);
break;
case OPS.setTextRise:
this.setTextRise(args[0]);
break;
case OPS.setLineWidth:
this.setLineWidth(args[0]);
break;
Expand Down Expand Up @@ -782,9 +785,16 @@ SVGGraphics = (function SVGGraphicsClosure() {
current.tspan.setAttributeNS(null, 'fill', current.fillColor);
}

// Include the text rise in the matrix since the `pm` function creates
// the SVG element's `translate` entry. Work on a copy to not alter the
// original text matrix.
let matrix = current.textMatrix.slice();
if (current.textRise !== 0) {
matrix[5] += current.textRise;
}

current.txtElement.setAttributeNS(null, 'transform',
pm(current.textMatrix) +
' scale(1, -1)');
pm(matrix) + ' scale(1, -1)');
current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
current.txtElement.appendChild(current.tspan);
current.txtgrp.appendChild(current.txtElement);
Expand Down

0 comments on commit c2b4360

Please sign in to comment.