Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix lineHeightFactor bug #3283

Merged
merged 3 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -3612,7 +3612,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