[reportlab-users] Font size, baseline and typography stuff
Dinu Gherman
gherman at darwin.in-berlin.de
Thu Aug 4 09:25:44 EDT 2011
Hi, long time no see!
I started a little project with strong requirements on
typography, which made me write the little attached
test script to see how much the reportlab library can
actually be helpful here. Doing so I noticed a couple
of things which make me state/raise the following re-
marks/questions:
1. The ascent/descent values seem to be numbers in the
range [0 ... 1000] representing a fraction of the font
size. That's fine, but I couldn't find a note in the
code saying so explicitly, which would just reduce a
bit of guess work.
2. I wonder if there is a way for any given font to
find the x-height defining the "mean line" (or
"midline") as described and illustrated here:
http://en.wikipedia.org/wiki/Typeface#Font_metrics
In the PDF generated by my script I approximated this
as shown by the dashed lines using an x-height equal
to the x-width which is not really acceptable, though.
3. Looking at the PDF output of the attached script,
you'll see that for Times-Italic the rightmost letter
N is slightly outside the grey box with a horizontal
size calculated by the function stringWidth with the
correct font name.
I'm not a typography expert, but I wonder if this be-
haviour is correct? If so, I wonder how the width of
slanted fonts is actually defined, then? Unfortunately,
the all knowing Wikipedia doesn't give an immediate
answer, at least not here:
http://en.wikipedia.org/wiki/Italic_type
http://en.wikipedia.org/wiki/Oblique_type
If you run the script in a directory that does also
contain the Rina.ttf file from the reportlab distri-
bution it will also be shown in the PDF.
Regards,
Dinu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_typometrics.py
Type: text/x-python
Size: 3549 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20110804/66f0d971/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_typometrics.pdf
Type: application/pdf
Size: 16483 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20110804/66f0d971/attachment-0001.pdf>
More information about the reportlab-users
mailing list