Hello!
If I use a monospaced font inbetween other fonts, they are not aligned at their baselines.
See the attached screenshot and PDF for details. Using Write() and writeHTML() both produce the same error. I'm however not sure why they don't start on the same X-position, this might be another bug.
<? include '../vendor/autoload.php'; $pdf = new TCPDF(); $pdf->addPage(); $html = 'Normal <span style="font-family: monospace">Monospace</span> Normal <span style="font-family: serif">Serif</span> Normal'; $pdf->writeHTML($html, true, false, true, false, 'L'); $pdf->Write(0, 'Normal '); $pdf->SetFont('courier'); $pdf->Write(0, 'Monospace'); $pdf->SetFont('helvetica'); $pdf->Write(0, ' Normal '); $pdf->SetFont('times'); $pdf->Write(0, 'Serif'); $pdf->SetFont('helvetica'); $pdf->Write(0, ' Normal'); $pdf->Output('monotest.pdf', 'F'); ?>
This seems happening only with the courier font and not with other default monospaced fonts. Probably some metrics in the courier font are not quite right.
It also happens with Computer Modern Typewriter (see here for font files: http://cm-unicode.sourceforge.net/)
I'm having trouble finding unaffected fonts.
At least these monospaced fonts are displayed above the baseline:
Anonymous Pro
Courier
Computer Modern Typewriter
Consolas
FreeMono
Lekton
SaxMono
Displayed below the baseline:
DroidSansMono
Not affected (as far as I can tell):
DejaVu Mono
UbuntuMono
A really, really bad workaround would be to manually set a lower Y-Position for the misaligned text and then retuning it afterwards, as the less-dirty (but still bad) CSS-Version using "vertical-align" has no effect.
Seems that the issue is caused by the "Ascent" and "Descent" values in the $desc array in courier.php font description file.
You can manually adjust them to fix the issue.
OK. Fixed in TCPDF 6.0.092.
Thank you for reporting this issue.
I'm sorry: A fresh installed TCPDF 6.2.6 shows exactly this problem with the courier font. The files courier*.php in tcpdf/fonts are dated Oct 2, 2011. Perhaps 6.2.6 contains the uncorrected font files?