mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
36 lines
786 B
JavaScript
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;
|