Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Graphics > Typefaces, fonts > Calculate strin...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 3651 of 3820
Post > Topic >>

Calculate stringwidth of opentype font

by Steve Baldwin <steve.baldwin@[EMAIL PROTECTED] > Mar 20, 2008 at 08:44 AM

Hi,

I am attempting to write a routine to calculate the width of a string to 
be rendered (via postscript) with an opentype font.  I am using Perl and 
via the Font::TTF family of modules have access to the various tables 
contained in the font file.

I am assuming the logic to calculate the string width goes something like 
this :

set stringwidth to 0
for each character in the string
  obtain the glyph index from the cmap table
  obtain the glyph width from the hmtx->advance structure->glyph_index
  add the glyph width to stringwidth
next

If this is OK so far, then I'm on the right track.  However from what I 
can see, the glyph widths in the hmtx->advance structure are in "font 
design units".  How do I convert from these to (say) points (e.g. as 
would be returned from the postscript stringwidth operator?

Thanks for your help,

Steve
 




 5 Posts in Topic:
Calculate stringwidth of opentype font
Steve Baldwin <steve.b  2008-03-20 08:44:51 
Re: Calculate stringwidth of opentype font
Armadillo <reply@[EMAI  2008-03-20 11:08:42 
Re: Calculate stringwidth of opentype font
Steve Baldwin <steve.b  2008-03-20 10:32:16 
Re: Calculate stringwidth of opentype font
Vid the Kid <vidthekid  2008-03-21 21:23:38 
Re: Calculate stringwidth of opentype font
xymarkd <devries@[EMAI  2008-03-27 08:25:50 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Nov 20 9:19:20 CST 2008.