> Hi everyone,
>
> I have an issue with .drawString() called on reportlab.pdfgen.Canvas,
> it seems characters are placed wrong. For example, for the word "Two"
> (created with reportlab's placement), the "T" and "w" are oddly apart.
> Commas are spaced wrong as well, when I use a hack to use a placement
> of another TTF lib it works.
>
> I use reportlab open-source 3.6.10, Python 3.10.6, and the font "Tex
> Gyre Pagella" from the LaTeX community in TTF format.
How did you convert it to a TTF? The font in the TeX library is an OTF
with Postscript outlines, which Reportlab doesn't support.
> 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.) Basically, like the sort of "placement hinting" of the font is
> off (my bad if that's not how it's called) and it looks horrible as a
> result.
"Kerning" is the word you're looking for. Reportlab knows about
kerning, so if they're in the font, it should work.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.
>
> There is also a TTF version which I used, sadly I can't attach it.
Where did you get it? My working theory is that the conversion to TTF
was done incorrectly.
> However, I noticed a screenshot alone works, so I attached that. Look
> at the "Tw" in "Two" or all the commas, upper render is reportlab
> placement, lower is with what should be with font kerning working
> (although due to my hacky approach to override it, maybe some hinting
> or other details isn't, so it's not 100% correct, just less wrong).
Were both of those generated from the TTF? Or was one from the OTF?
Most of the kerning looks just fine. There are only a couple of
placements that are bad. The comma is a bit off, and the "Tw" pair
could be closer.
> Given the kerning works with a different TTF library with the same
> font file, I would assume it's kind of out of the question the font
> contains it. That is why I'm wondering why it doesn't work with
> reportlab.
What do you mean by "different TTF library"? How did you generate the
other sample? What application? Same TTF, or was it the OTF? For that
matter, what does your Reportlab code look like? Are you using Platypus
to do automated layout?
> Is this a bug in reportlab then? Where can I report it with all the
> files like the font attached? I assume people would kind of hope for
> something like basic glyph placement in a PDF library to work, so
> maybe a fix might be worth a consideration.
Now, stand back a minute. "Basic glyph placement" is just fine. You
seem to have uncovered a potential kerning issue in a couple of kerning
pairs in a single font, but you haven't given them nearly enough to work
with. At this point, you haven't even convinced me that the problem is
in Reportlab. If you can't give them the actual font that fails, how
can they possibly do any debugging?