Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Run prettier and revert dropping hpf
  • Loading branch information
owenl131 committed Oct 2, 2021
commit 00cd1323a70af558e9ac944fc82fbeb9394e2619
21 changes: 13 additions & 8 deletions src/jspdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3854,7 +3854,7 @@ function jsPDF(options) {
text = [];
len = da.length;
maxWidth = maxWidth !== 0 ? maxWidth : pageWidth;
let backToStartX = 0
let backToStartX = 0;
for (var l = 0; l < len; l++) {
newY = l === 0 ? getVerticalCoordinate(y) : -leading;
newX = l === 0 ? getHorizontalCoordinate(x) : backToStartX;
Expand All @@ -3867,12 +3867,13 @@ function jsPDF(options) {
wordSpacingPerLine.push(spacing);
backToStartX = 0; // distance to reset back to the left
for (let i = 1; i < words.length; i++) {
let shiftAmount = (findWidth(words[i-1] + " " + words[i]) -
findWidth(words[i])) * scaleFactor + spacing;
if (i == words.length - 1)
text.push([words[i], shiftAmount, 0]);
else
text.push([words[i] + " ", shiftAmount, 0]);
let shiftAmount =
(findWidth(words[i - 1] + " " + words[i]) -
findWidth(words[i])) *
scaleFactor +
spacing;
if (i == words.length - 1) text.push([words[i], shiftAmount, 0]);
else text.push([words[i] + " ", shiftAmount, 0]);
wordSpacingPerLine.push(spacing);
backToStartX -= shiftAmount;
}
Expand All @@ -3892,7 +3893,11 @@ function jsPDF(options) {
newX = l === 0 ? getHorizontalCoordinate(x) : 0;
if (l < len - 1) {
wordSpacingPerLine.push(
scale((maxWidth - lineWidths[l]) / (da[l].split(" ").length - 1))
hpf(
scale(
(maxWidth - lineWidths[l]) / (da[l].split(" ").length - 1)
)
)
);
} else {
wordSpacingPerLine.push(0);
Expand Down