[reportlab-users] UC Accented character problem

Robin Becker robin at reportlab.com
Mon Jul 19 08:42:50 EDT 2021


On 19/07/2021 12:09, Satchell Julian via reportlab-users wrote:
> We have been using Platypus / Reportlab to generate printable PDFs of questionnaire responses in a multi-language application. We use the stock Helvetica font.
> 
> Polish answers render with black squares for the non-ASCII characters, presumably because they lie outside the range of the stock font. In principle, we could also get answers in other European languages, like modern Greek, Maltese, and Bulgarian, which uses a Cyrillic character set, but we hit the problem with Polish first.
> 
> We could embed a font with a wider character range, like for example Free Sans. But by the time we have added Bold, Oblique and BoldOblique variants, we are putting in something like 2Mbytes of embedded data, increasing the file size by a factor of a hundred.
> 
> My (limited) understanding is that we want font subsetting, so that only data for the glyphs actually used is put in the file.
> 

Hi Juilian, yes the ReportLab Toolkit does support subsetting for TrueType fonts. I think that is turned on by default 
for those fonts which allow embedding/subsetting. So just use

from reportlab.pdfbase import pdfmetrics, ttfonts
......
pdfmetrics.registerFont(ttfonts.TTFont("DejaVuSans", "DejaVuSans.ttf"))
......
canvas.setFont('DejaVuSans',12)
......

or similar. Some systems may require a more explicit path to the font.


> Does Reportlab support font subsetting? If so, are there examples of how to do it out there? I didn't see anything in the documentation.
> 
> Plan B is just to embed everything, but it seems inefficient.
> 
> Julian Satchell
> Principal Eng/Tech/Sci
> 
> M 0777 2069998
> D 01684 895003
> jssatchell at QinetiQ.com<mailto:jssatchell at QinetiQ.com>
> 
> www.QinetiQ.com<https://www.qinetiq.com> | Our blog<https://www.qinetiq.com/blog> | LinkedIn<https://www.linkedin.com/company/qinetiq_2> | Twitter<https://twitter.com/QinetiQ>
./.......
-- 
Robin Becker


More information about the reportlab-users mailing list