(document, src, family, id)
| 4 | |
| 5 | export class PDFFont { |
| 6 | static open(document, src, family, id) { |
| 7 | let font; |
| 8 | |
| 9 | if (typeof src === 'string') { |
| 10 | if (StandardFont.isStandardFont(src)) { |
| 11 | return new StandardFont(document, src, id); |
| 12 | } |
| 13 | font = fontkit.openSync(src, family); |
| 14 | } else if (Buffer.isBuffer(src)) { |
| 15 | font = fontkit.create(src, family); |
| 16 | } else if (src instanceof Uint8Array) { |
| 17 | font = fontkit.create(Buffer.from(src), family); |
| 18 | } else if (src instanceof ArrayBuffer) { |
| 19 | font = fontkit.create(Buffer.from(new Uint8Array(src)), family); |
| 20 | } else if (typeof src === 'object') { |
| 21 | font = src; |
| 22 | } |
| 23 | |
| 24 | if (font == null) { |
| 25 | throw new Error('Not a supported font format or standard PDF font.'); |
| 26 | } |
| 27 | |
| 28 | return new EmbeddedFont(document, font, id); |
| 29 | } |
| 30 | |
| 31 | encode(text) { |
| 32 | throw new Error('Must be implemented by subclasses'); |
no test coverage detected