forked from foliojs/pdfkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfont.js
More file actions
37 lines (29 loc) · 716 Bytes
/
font.js
File metadata and controls
37 lines (29 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class PDFFont {
constructor() {}
encode() {
throw new Error('Must be implemented by subclasses');
}
widthOfString() {
throw new Error('Must be implemented by subclasses');
}
ref() {
return this.dictionary != null
? this.dictionary
: (this.dictionary = this.document.ref());
}
finalize() {
if (this.embedded || this.dictionary == null) {
return;
}
this.embed();
this.embedded = true;
}
embed() {
throw new Error('Must be implemented by subclasses');
}
lineHeight(size, includeGap = false) {
const gap = includeGap ? this.lineGap : 0;
return ((this.ascender + gap - this.descender) / 1000) * size;
}
}
export default PDFFont;