Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for TrueType Collection (.ttc) #801

Merged
merged 1 commit into from
Dec 30, 2016
Merged

Conversation

linkeo
Copy link

@linkeo linkeo commented Dec 30, 2016

Can use *.ttc fonts now.

For example:

var fonts = {
  // use normal fonts
  Roboto: {
    normal: 'fonts/Roboto-Regular.ttf',
    bold: 'fonts/Roboto-Medium.ttf',
    italics: 'fonts/Roboto-Italic.ttf',
    bolditalics: 'fonts/Roboto-Italic.ttf'
  },
  // use fonts in colleciton
  PingFangSC: {
    normal: ['fonts/pingfang.ttc', 'PingFangSC-Regular'],
    bold: ['fonts/pingfang.ttc', 'PingFangSC-Semibold'],
  }
};

var PdfPrinter = require('../src/printer');
var printer = new PdfPrinter(fonts);
var fs = require('fs');

var docDefinition = {
  content: [
    'First paragraph',
    'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines'
  ],
  defaultStyle: {
    font: 'PingFangSC',
    fontSize: 12
  }
};

var pdfDoc = printer.createPdfKitDocument(docDefinition);
pdfDoc.pipe(fs.createWriteStream('pdfs/basics.pdf'));
pdfDoc.end();

@liborm85 liborm85 merged commit 8fea4a3 into bpampuch:master Dec 30, 2016
@liborm85
Copy link
Collaborator

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants