Skip to content

Commit b3065f5

Browse files
authored
Fixing bad API usage in examples (#2838)
* Fixing bad API usage in font-face example The code was using `setFont` + `setFontStyle` which is now a single combined call. * And more API fixes
1 parent 4497d22 commit b3065f5

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

examples/js/font-faces.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
var doc = new jsPDF();
1+
const doc = new jsPDF();
22

33
doc.text("This is the default font.", 20, 20);
44

5-
doc.setFont("courier");
6-
doc.setFontStyle("normal");
5+
doc.setFont("courier", "normal");
76
doc.text("This is courier normal.", 20, 30);
87

9-
doc.setFont("times");
10-
doc.setFontStyle("italic");
8+
doc.setFont("times", "italic");
119
doc.text("This is times italic.", 20, 40);
1210

13-
doc.setFont("helvetica");
14-
doc.setFontStyle("bold");
11+
doc.setFont("helvetica", "bold");
1512
doc.text("This is helvetica bold.", 20, 50);
1613

17-
doc.setFont("courier");
18-
doc.setFontStyle("bolditalic");
14+
doc.setFont("courier", "bolditalic");
1915
doc.text("This is courier bolditalic.", 20, 60);
2016

21-
doc.setFont("times");
22-
doc.setFontStyle("normal");
17+
doc.setFont("times", "normal");
2318
doc.text("This is centred text.", 105, 80, null, null, "center");
2419
doc.text("And a little bit more underneath it.", 105, 90, null, null, "center");
2520
doc.text("This is right aligned text", 200, 100, null, null, "right");

examples/js/string-splitting.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ var pageWidth = 8.5,
3232
// splitTextToSize takes your string and turns it in to an array of strings,
3333
// each of which can be displayed within the specified maxLineWidth.
3434
var textLines = doc
35-
.setFont("helvetica", "neue")
35+
.setFont("helvetica")
3636
.setFontSize(fontSize)
3737
.splitTextToSize(text, maxLineWidth);
38-
38+
3939
// doc.text can now add those lines easily; otherwise, it would have run text off the screen!
4040
doc.text(textLines, margin, margin + 2 * oneLineHeight);
4141

4242
// You can also calculate the height of the text very simply:
4343
var textHeight = (textLines.length * fontSize * lineHeight) / ptsPerInch;
4444
doc
45-
.setFontStyle("bold")
45+
.setFont("Helvetica", "bold")
4646
.text(
4747
"Text Height: " + textHeight + " inches",
4848
margin,

0 commit comments

Comments
 (0)