[reportlab-users] the size of the lower_part of a character

ÿffffcaÿffffbfÿffffb7ÿffffbc ÿffffcdÿfffff5 reportlab-users@reportlab.com
Wed, 28 Apr 2004 08:02:34 +0800 (CST)


--0-1613883528-1083110554=:43440
Content-Type: text/plain; charset=gb2312
Content-Transfer-Encoding: 8bit

Andy Robinson :
        If I use CID Fonts ,what should I do?Is it the same to type 1 fonts?

Andy Robinson <andy@reportlab.com> wrote:
We don't provide an API to do this directly. Each font has an ascent
and descent attribute which you can query like this:

>>> from reportlab.pdfbase import pdfmetrics
>>> f = pdfmetrics.getTypeFace('Helvetica')
>>> f.descent
-207
>>> f.ascent
718
>>>
The units are in a logical 1000x1000 box. So, if you
had ten point text, this would tell you Helvetica descends
2.07 points below the baseline. Thus, if you did

canvas.setFont('Helvetica', 10)
canvas.drawString(100,200, 'Happy New Year')

then the baseline of the characters (bottom of 'Happ')
would be at y=200; the 'y' would PROBABLY be at or near
y = 197.03 (200-2.07); and the top of the capital letters
would probably be at y = 207.18.

BUT this is a single number for the whole font, and is
just a guideline provided by the font designer. It is
not necessarily accurate for each character.

You need extra software to find the bounding box of each
character. Just van Rossum's fonttools package can tell
you - it converts a font file to an XML description which
you can read with lots of data.

I hope this helps,

Andy Robinson
-----Original Message-----
From: reportlab-users-admin@reportlab.com
[mailto:reportlab-users-admin@reportlab.com]On Behalf Of
ÿffffcaÿffffbfÿffffb7ÿffffbc ÿffffcdÿfffff5
Sent: 23 April 2004 03:18
To: reportlab-users@reportlab.com
Subject: [reportlab-users] the size of the lower_part of a character


Hello:
First ,I'm a Chinese and my English is not very good,so there maybe
some wrongs in my words,please forgive me.
My question is:
How Can I know the size of the lower_part(I don't know how describe it
correctly) of a character?Is it has some relation to it's fontsize?
Can you understand me?




Do You Yahoo!?
»ÝÆÕTTÓÎÏ·¾ç£¬ÍæÓÎÏ·£¬Öд󽱣¡

_______________________________________________
reportlab-users mailing list
reportlab-users@reportlab.com
http://two.pairlist.net/mailman/listinfo/reportlab-users


---------------------------------
Do You Yahoo!?
»ÝÆÕTTÓÎÏ·¾ç£¬ÍæÓÎÏ·£¬Öд󽱣¡
--0-1613883528-1083110554=:43440
Content-Type: text/html; charset=gb2312
Content-Transfer-Encoding: 8bit

<DIV><STRONG><EM>Andy Robinson :</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</EM> <EM>If I use CID Fonts ,what should I do?Is it the same to type 1 fonts?</EM></STRONG><BR><BR><B><I>Andy Robinson &lt;andy@reportlab.com&gt;</I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">We don't provide an API to do this directly. Each font has an ascent<BR>and descent attribute which you can query like this:<BR><BR>&gt;&gt;&gt; from reportlab.pdfbase import pdfmetrics<BR>&gt;&gt;&gt; f = pdfmetrics.getTypeFace('Helvetica')<BR>&gt;&gt;&gt; f.descent<BR>-207<BR>&gt;&gt;&gt; f.ascent<BR>718<BR>&gt;&gt;&gt;<BR>The units are in a logical 1000x1000 box. So, if you<BR>had ten point text, this would tell you Helvetica descends<BR>2.07 points below the baseline. Thus, if you did<BR><BR>canvas.setFont('Helvetica', 10)<BR>canvas.drawString(100,200, 'Happy New Year')<BR><BR>then the baseline of the characters (bottom of 'Happ')<BR>would be at y=200; the 'y' would PROBABLY be at or near<BR>y = 197.03 (200-2.07); and the top of the capital letters<BR>would probably be at y = 207.18.<BR><BR>BUT this is a single number for the whole font, and is<BR>just a guideline provided by the
 font designer. It is<BR>not necessarily accurate for each character.<BR><BR>You need extra software to find the bounding box of each<BR>character. Just van Rossum's fonttools package can tell<BR>you - it converts a font file to an XML description which<BR>you can read with lots of data.<BR><BR>I hope this helps,<BR><BR>Andy Robinson<BR>-----Original Message-----<BR>From: reportlab-users-admin@reportlab.com<BR>[mailto:reportlab-users-admin@reportlab.com]On Behalf Of<BR>ÿffffcaÿffffbfÿffffb7ÿffffbc ÿffffcdÿfffff5<BR>Sent: 23 April 2004 03:18<BR>To: reportlab-users@reportlab.com<BR>Subject: [reportlab-users] the size of the lower_part of a character<BR><BR><BR>Hello:<BR>First ,I'm a Chinese and my English is not very good,so there maybe<BR>some wrongs in my words,please forgive me.<BR>My question is:<BR>How Can I know the size of the lower_part(I don't know how describe it<BR>correctly) of a character?Is it has some relation to it's fontsize?<BR>Can you understand
 me?<BR><BR><BR><BR><BR>Do You Yahoo!?<BR>»ÝÆÕTTÓÎÏ·¾ç£¬ÍæÓÎÏ·£¬Öд󽱣¡<BR><BR>_______________________________________________<BR>reportlab-users mailing list<BR>reportlab-users@reportlab.com<BR>http://two.pairlist.net/mailman/listinfo/reportlab-users</BLOCKQUOTE><p><br><hr size=1><b>Do You Yahoo!?</b><br>
<a href="http://cn.rd.yahoo.com/mail_cn/tag/SIG=1402c0to2/**http%3A%2F%2Fhp.allyes.com%2Flaserjet%2Fgamestory%2Findex.html%3Fjumpid%3Dex_hphqapcn_MongooseLJ1010%2F201073CN407016%2FYahoo" target=blank>»ÝÆÕTTÓÎÏ·¾ç£¬ÍæÓÎÏ·£¬Öд󽱣¡</a>
--0-1613883528-1083110554=:43440--