[pdf4st] AW: Width of string

  • From: "Christian Haider" <Christian.Haider@xxxxxxxxxxxxxxxxxxxxxxx>
  • To: <pdf4st@xxxxxxxxxxxxx>
  • Date: Fri, 20 Apr 2012 16:03:07 +0200

(Originally submitted by ChristianHaider on Tue, 2011-11-29 12:49.) 

:-) I added this the other day to the article Painting a Page. I paste
it here again:

For justification, you need to know the length of a string. For this you
can use 

aFont stringWidthOf: aString at: aFontsize.

Using our example you would write 

(Graphics.Fonts.Font fontAt: #Helvetica) stringWidthOf: 'Hello' at: 10.

returning 22.78 which is the width in PostScript points in an unscaled
coordinate system. 

 

 

Von: pdf4st-bounce@xxxxxxxxxxxxx [mailto:pdf4st-bounce@xxxxxxxxxxxxx] Im
Auftrag von Christian Haider
Gesendet: Freitag, 20. April 2012 16:00
An: pdf4st@xxxxxxxxxxxxx
Betreff: [pdf4st] Width of string

 

(Originally submitted by bobn on Tue, 2011-11-29 12:22.) 

For the report layout: is there a way to know the font size when
calculating layout? My understanding is that the report code will have
to deal with word wrap and text justification. I will need to know how
long a string of characters in a given font. For now I'm using estimated
values. It works, but it's not the correct solution. 

 

Other related posts:

  • » [pdf4st] AW: Width of string - Christian Haider