mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
Otherwise Adobe Illustrator says "This document uses fonts that are currently not available on your computer".
56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
import PDFFontFactory from '../../lib/font_factory';
|
|
import PDFDocument from '../../lib/document';
|
|
|
|
describe('EmbeddedFont', () => {
|
|
test('no fontLayoutCache option', () => {
|
|
const document = new PDFDocument();
|
|
const font = PDFFontFactory.open(
|
|
document,
|
|
'tests/fonts/Roboto-Regular.ttf'
|
|
);
|
|
const runSpy = jest.spyOn(font, 'layoutRun');
|
|
|
|
font.layout('test');
|
|
font.layout('test');
|
|
font.layout('test');
|
|
font.layout('test');
|
|
|
|
expect(runSpy).toBeCalledTimes(1);
|
|
});
|
|
|
|
test('fontLayoutCache = false', () => {
|
|
const document = new PDFDocument({ fontLayoutCache: false });
|
|
const font = PDFFontFactory.open(
|
|
document,
|
|
'tests/fonts/Roboto-Regular.ttf'
|
|
);
|
|
const runSpy = jest.spyOn(font, 'layoutRun');
|
|
|
|
font.layout('test');
|
|
font.layout('test');
|
|
font.layout('test');
|
|
font.layout('test');
|
|
|
|
expect(runSpy).toBeCalledTimes(4);
|
|
});
|
|
|
|
describe('emebed', () => {
|
|
test('sets BaseName based on font id and postscript name', () => {
|
|
const document = new PDFDocument();
|
|
const font = PDFFontFactory.open(
|
|
document,
|
|
'tests/fonts/Roboto-Regular.ttf',
|
|
undefined,
|
|
'F1099'
|
|
);
|
|
const dictionary = {
|
|
end: () => {},
|
|
};
|
|
font.dictionary = dictionary;
|
|
font.embed();
|
|
|
|
expect(dictionary.data.BaseFont).toBe('BAJJZZ+Roboto-Regular');
|
|
});
|
|
});
|
|
});
|