[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

string-width error?



Are there any secrets I have to know to use the string-width? Why do
the first two examples return the same string width? I'm trying to
calculate the view-size to show a big string, but string-width does not 
allow to do that. Are there other ways?

view-size: 
  width 400
  height is determined by rows * line-height
                 
(make-point 400
            (* (line-heigth font)
               (truncate (1+ (/ (string-width string font) 400)))))

Example 1

(string-width 
 "This adds new patterns and catalysts to a soup. A nil
material can be used if nothing is added.
This adds new patterns and catalysts to a soup. A nil
material can be used if nothing is added.
This adds new patterns and catalysts to a soup. A nil
material can be used if nothing is added.
This adds new patterns and catalysts to a soup. A nil
material can be used if nothing is added."
 '("times" 12 :plain))

=> 1164

Example 2

(string-width 
 "This adds new patterns and catalysts to a soup. A nil
material can be used if nothing is added.
This adds new patterns and catalysts to a soup. A nil
material can be used if nothing is added.
This adds new patterns and catalysts to a soup. A nil
material can be used if nothing is added."
 '("times" 12 :plain))

=> 1164

But

(string-width 
 "This adds new patterns and catalysts to a soup. A nil
material can be used if nothing is added.
This adds new patterns and catalysts to a soup. A nil
material can be used if nothing is added."
 '("times" 12 :plain))

=> 876

Peter
psto@xs4all.nl