foliojs / pdfkit

A JavaScript PDF generation library for Node and the browser
http://pdfkit.org/
MIT License
9.89k stars 1.15k forks source link

Letters with different font faces should sit on the same baseline #334

Open laszbalo opened 9 years ago

laszbalo commented 9 years ago

I was trying to use a different font face to highlight a word in a sentence, but the highligheted word did not sit on the same baseline than the rest of words of the same sentence.

Here is a demo:

doc.fontSize(70)
    .font("Helvetica").text('A', {continued: true})
    .font("Helvetica-Bold").text('A', {continued: true})
    .font("Times-Roman").text('A', {continued: true})
    .font("Times-Italic").text('A', {continued: true})
    .font("Courier").text('A', {continued: true})
    .font("Equity").text('A')

And this is how the PDF renders:

baseline

I think it happens, because the for continued texts the (x,y) coordinate is calculated individually for every call of text().

AlgizLtd commented 7 years ago

+1 this I've been playing with PDFKit and Pdfmake. When adding text in Pdfmake, it keeps everything to the baseline but I need to control the layout and PDFKit gives me that control. Pdfmake has the ability to pass absolute co-ordinates to object, but I dont think that feature is fully implemented yet.