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

Kerning support #82

Closed
RGBz opened this issue Mar 21, 2018 · 3 comments
Closed

Kerning support #82

RGBz opened this issue Mar 21, 2018 · 3 comments

Comments

@RGBz
Copy link
Contributor

RGBz commented Mar 21, 2018

It doesn't look like kerning information is used with ASM or OTF fonts. Both examples below show gaps between the A and the V:

const fs = require('fs');
const pdf = require('pdfjs');
const openSans = new pdf.Font(fs.readFileSync('pdfjs/test/fixtures/font/opensans/bold.ttf'));
const times = new pdf.Font(require('pdfjs/font/Times-Bold.json'));

const doc = new pdf.Document({ font: times, padding: 10 });
doc.pipe(fs.createWriteStream('output.pdf'));

doc.text('AVA', { font: times });
doc.text('AVA', { font: openSans });

doc.end();
@rkusa
Copy link
Owner

rkusa commented Mar 22, 2018

Yes, this is unfortunately currently not supported. While the kerning offset is already read (https://github.com/rkusa/pdfjs/blob/master/lib/font/otf.js#L55) the correct placement within the PDF document is not implemented. Since this is something just recently requested from customers of the application where I am using this library, I might have a look at it soon.

rkusa added a commit that referenced this issue Mar 26, 2018
Limitation: does not work when appending text, yet

Refs #82
@rkusa
Copy link
Owner

rkusa commented Mar 26, 2018

I've implemented kerning. Please let me know if you see anything strange. There is still one limitation, the kerning does not yet work when appending text, e.g.

doc.text('A').append('VA');

@RGBz
Copy link
Contributor Author

RGBz commented Mar 26, 2018

Great thanks! I tested it out and it seems this fixed kerning for ASM, but not OTF. After some diving, I think this PR should get OTF to work as well: #84

@rkusa rkusa closed this as completed Apr 26, 2018
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

No branches or pull requests

2 participants