[reportlab-users] What is the current status of Truetype support?

Henning von Bargen reportlab-users@reportlab.com
Thu, 31 Jul 2003 11:05:26 +0200


What is the current status of TrueType support?

Background is as follows:
Our company uses Oracle Reports for high-quality report generation.
A fine tool, but is does not support what Microsoft calls "text with
layout".
It is not possible to load text with some markup (that is to say: HTML or
RTF)
from the database and render it on paper.
(Markup needed: sup, sub, bold, italics, underline, greek letters)

Now the only solution (don't laugh...) is to use some other program to
render
the formatted text into a bitmap image file and let report include the
image.

The solution we use now is a bit complicated:
Oracle Reports call a Python script using the ReportLab toolkit 
(in particular, the class for paragraphs with HTML support)
to create PDF output from HTML input.
Then Ghostscript converts the PDF to a PCX file,
which is then included in the report layout.

Any better solution is welcome!!!
PIL does support TrueType only with the commercial license and that's much
too expensive.

For our customers it is important that the text generated as bitmap graphics
looks almost the same as normal text and doesn't use visibly different
fonts,
i.e. the other text is rendered as "Arial Narrow" and the "text bitmaps" 
generated via ReportLab should be able to use that font, too.

So we need some kind of TrueType support in paragraphs.
We don't need a full-blown up solution that let's you use TrueType like any
built-in font.
I consider something like this:

Step 1: prepare a font translation table like this:
assign a name like "ArialNarrow" to a table:
Style    TTF File, Index
plain     arialn.ttf, 0
bold	arialnb.ttf, 0
italic     arialni.ttf, 0
bold italic    arialnbi.ttf, 0
Unfortunately, the naming convention for the fonts
 (suffix i for italic, b for bold) is not always obeyed.
That's why I would like to able to do this mapping manually.

Step 2: Use the new font in paragraph as any other font:
"<font face="ArialNarrow">Plain <b>Bold</b> Plain again. Water is
H<sub>2</sub>O</font>"

This wasn't possible with 1.1.7. Is this possible now? And how?

Henning