Re: Character placement off - bug or am I using it wrong?
ellie <[email protected]> Sun, 21 Aug 2022 15:55:33 +0200
| Newsgroups | gmane.comp.python.reportlab.user |
|---|---|
| Message-ID | <[email protected]> |
Update: reportlab support just confirmed to me this is a reportlab limitation/bug, and TTF fonts are placed without kerning. I'll try to sum up the main points I sent them (I CC'ed it here but messed up the CC): - I think whether this is visually acceptable for every font is debatable and I hoped this would be an option at least. For the example I linked with image I don't find no kerning visually acceptable, at least not for professional print. - I find it surprising simply because any other TTF using lib under the sun that isn't advertised as simple/stripped down seems to do kerning. (Maybe I'm wrong? But I haven't seen one that does yet.) - It seems to me this will cause interoperability problems for people. E.g. I layout with the help of a different TTF lib, then hammer that layout into reportlab with per word placement. But since reportlab doesn't use kerning (and the lib I layouted with does) the words are now too wide, so a lot of word pair spacing is unreadably wrong. I could use drawString() per character instead, but wouldn't I break ligatures or such things? - Summed up, I'm hoping TTF kerning will be added one day and I find this limitation somewhat notable. Also, I'm hoping for alternate python PDF library suggestions where TTF kerning is done out of the box. I hope that was an adequate summary! On 8/16/22 8:21 PM, ellie wrote: > Hi everyone, > > I have an issue with .drawString() called on reportlab.pdfgen.Canvas > shown in the attached image, it seems characters are placed wrong. For > example, look at the word "Two" in the upper paragraph (created with > reportlab's placement), see how the "T" and "w" are oddly apart. > > Also compare to the lower image (created via a hack overriding reportlab > placement), especially also all the commas which seem to be spaced too > far to the right by reportlab as well. > > I use reportlab open-source 3.6.10, Python 3.10.6, and the attached font > "Tex Gyre Pagella" from the LaTeX community in TTF format. > > > It looks like reportlab is placing letters with naive bounding boxes > rather than to properly overlap special pairs in whatever smart way the > font would provide. (That might be wrong, just my uninformed guess.) > > Is this a reportlab bug? Is it a problem with the reportlab install, > like a missing library? Or do I need to pass some option for better > placement? If it's a bug, is there hope for a fix? If it's an install > issue, can I detect this in Python to avoid silently generating broken > PDFs? > > Regards, ellie