pdfkit/lib/font.js
2019-01-07 20:51:06 -03:00

41 lines
779 B
JavaScript

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();
return (this.embedded = true);
}
embed() {
throw new Error('Must be implemented by subclasses');
}
lineHeight(size, includeGap) {
if (includeGap == null) {
includeGap = false;
}
const gap = includeGap ? this.lineGap : 0;
return ((this.ascender + gap - this.descender) / 1000) * size;
}
}
export default PDFFont;