Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion src/jspdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3616,7 +3616,8 @@ function jsPDF(options) {

//baseline
var height = activeFontSize / scope.internal.scaleFactor;
var descent = height * (lineHeightFactor - 1);
var descent = height * (lineHeight - 1);

switch (options.baseline) {
case "bottom":
y -= descent;
Expand Down
15 changes: 15 additions & 0 deletions test/specs/jspdf.unit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2523,6 +2523,21 @@ This is a test too.`,
]);
});

it('jsPDF test text with line height', function() {
const doc1 = new jsPDF();
let writeArray1 = [];
doc1.__private__.setCustomOutputDestination(writeArray1);
doc1.setLineHeightFactor(1.5);
doc1.text('Some text', 10, 10, { baseline: 'middle' });

let writeArray2 = [];
const doc2 = new jsPDF();
doc2.__private__.setCustomOutputDestination(writeArray2);
doc2.text('Some text', 10, 10, { lineHeightFactor: 1.5, baseline: 'middle' });

expect(writeArray1).toEqual(writeArray2);
});

it("jsPDF private function setLineCap", () => {
var doc = jsPDF({ floatPrecision: 2 });

Expand Down