[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: [sqr-users] computing string size with proportional fonts



Bob: 
Three.5 ways: (assuming an HP LaserJet)
1. if what you want can be put into columns of known width you can use the 
horizontal cursor position function as a "hard tab key" to a fixed postion to 
the right of the left margin. 

you encode the function into a variable and then Print (or write) this 
variable before you print your string. if you make column 1 wide enough to 
cover the 
worst case, then you won't have run over. 

    where the number is the column number 
   ENCODE '<27>&a14C'    into $headercol
   ENCODE '<27>&a32C'    into $pagetopcol
   ENCODE '<27>&a59C'    into $emplidcol
   ENCODE '<27>&a78C'    into $ssncol
   ENCODE '<27>&a100C'   into $phonecol
   ENCODE '<27>&a130C'   into $farright
    to use this,...
    write $headercol
    write $yourstring

    write $ssncol 
    write $yourssnstring

you might try these font set ups which look quite attractive in comparison to 
courier and are native to the HP Laser Jet.

   ENCODE '<27>(s1p10v0s3b4168T' into $bigfont   !antique olive
   ENCODE '<27>(s0p14h3b4102T'   into $littlefont
   ENCODE '<27>(s1p8v0s2b4168T'  into $italfont  !antique olive
   ENCODE '<27>(s1p14v0s3b4168T' into $hugefont  !antique olive


2. Otherwise you need a table of "printer font metrics" which is a lookup 
table for the font, and weight you need and you will need to do a letter by 
letter parsing of the string to be printed accumulating the width of the 
resulting 
string in HP measure (decipoints) You will then multiply it by a constant for 
the point size of the type and then move the cursor accordingly. You could 
-with enough re-inventing of the wheel, actually do your own justification of 
the 
columns.  

3. a halfbaked version of 2. make about four categories of letter CAP W M Q 
etc = very wide = 4units, 
U T R S etc = wide = 3 units 
a b c = regular = 2 units
I i , . etc as narrow. = 1 unit  and assemble a metrics and multiply it by a 
point size constant etc.

You will have to tinker with the point size constant to get the line width 
you want.

4. somebody may know a better heuristic way eg. for normal english text in 
14pt Times Roman , allow 1.3 * Len(of the string) for the space it will take to 
print. 

personally I use method number 1

Hope this helps

Norman Dolph

_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users