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