pdfkit/lib/font.js
2018-11-29 08:14:45 -08:00

36 lines
786 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;