[reportlab-users] Using bold and italic with a generic TTF

Lorenzo Mancini lmancini at develer.com
Mon Mar 12 13:07:52 EDT 2007


Hello,

I'm using Reportlab 1.20 to generate PDF files. Since I have to include
Korean and Turkish text, I'm using the Arial Unicode TTF.

Everything works fine, until I try to use the <b> and <i> tags to obtain
bold or italic glyphs. The tags are processed, but seem to be ignored: I
always get regular text.

After some experiments with registerFont/addMapping, it came to my mind
that maybe the Arial Unicode font has only "regular" glyphs, and not the
"italic" and "bold" ones.

So, when I use registerFont/addMapping on a font that has only "regular"
glyphs, Reportlab doesn't do any magic to convert them to bold and
italic, it merely uses those regular glyphs even when the processed xml
calls for bold and italic.

(...correct?)


That seemed to make sense, until I noticed that using that same font
within OpenOffice, I can actually export to PDF with bold and italic
characters from it (I've tried with Turkish and Korean text too, obviously).

Actually, I can export to PDF with bold and italic from *any* TTF. This
can lead to one of the following:

1) Every TTF has the italic and bold variants of all its glyphs (???),
but Reportlab 1.20 doesn't know how to extract/use them.

2) OpenOffice uses the italic and bold TTF variants of a family when
available (e.g. Arial family is composed by four TTFs, one for each
style - regular, bold, italic, bold italic); if only regular style
glyphs are available, it modifies the glyphs to make them look like bold
and italic.

As I see it, the second scenario is much more realistic than the first,
but I'd be glad to be corrected. If the second scenario is the right
one: is a trick similar to OO's in the works for Reportlab, to obtain
bold and italic glyphs even if the currently used TTF only has regular ones?


Back to my original problem: to be able to have italic and bold glyphs
for Korean and Turkish text, I thought that I could find out what TTFs
have the italic and bold variants of the Korean/Turkish glyphs and use
them, instead of Arial Unicode.

Is that a good solution? If so, is somewhere out there a comprehensive
list of such fonts?

Thanks in advance!

p.s. if someone wants to do some quick experiments, I'm attaching a
little script that tries to produce italic glyphs from Turkish and
Korean text.

--
Lorenzo Mancini
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rep2.py
Type: text/x-python
Size: 1291 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20070312/43e0e938/attachment.py>


More information about the reportlab-users mailing list