Font.st
changeset 5981 100d92bb2b39
parent 5907 ad7449037a9e
child 5990 13498d2ba36b
equal deleted inserted replaced
5980:91400212b3e4 5981:100d92bb2b39
   868     "return the height (device specific) of the argument;
   868     "return the height (device specific) of the argument;
   869      the argument must be a String.
   869      the argument must be a String.
   870      CAVEAT:
   870      CAVEAT:
   871         currently only constant height fonts are supported."
   871         currently only constant height fonts are supported."
   872 
   872 
       
   873     |sum|
       
   874 
   873     device isNil ifTrue:[
   875     device isNil ifTrue:[
   874         self errorNoDevice.
   876         self errorNoDevice.
   875         ^ 0
   877         ^ 0
   876     ].
   878     ].
   877     replacementFont notNil ifTrue:[
   879     replacementFont notNil ifTrue:[
   878         ^ replacementFont heightOf:textOrString
   880         ^ replacementFont heightOf:textOrString
   879     ].
   881     ].
   880 
   882     device supportsVariableHeightFonts ifFalse:[
   881     ^ descent + ascent
   883         ^ descent + ascent
       
   884     ].
       
   885 
       
   886     (textOrString isString) ifTrue:[
       
   887         ^ device heightOf:textOrString string inFont:fontId
       
   888     ].
       
   889     (textOrString isCharacter) ifTrue:[
       
   890         ^ device heightOf:textOrString asString inFont:fontId
       
   891     ].
       
   892 
       
   893     sum := 0.
       
   894     textOrString do:[:lineString |
       
   895         lineString isString ifTrue:[
       
   896             sum := sum + (device heightOf:lineString asString inFont:fontId).
       
   897         ]
       
   898     ].
       
   899     ^ sum
   882 
   900 
   883     "Created: 12.5.1996 / 11:05:00 / cg"
   901     "Created: 12.5.1996 / 11:05:00 / cg"
   884 !
   902 !
   885 
   903 
   886 heightOf:aString on:aDevice
   904 heightOf:aString on:aDevice
  1237 ! !
  1255 ! !
  1238 
  1256 
  1239 !Font class methodsFor:'documentation'!
  1257 !Font class methodsFor:'documentation'!
  1240 
  1258 
  1241 version
  1259 version
  1242     ^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.127 2012-04-25 19:05:49 stefan Exp $'
  1260     ^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.128 2013-01-07 15:50:23 stefan Exp $'
  1243 !
  1261 !
  1244 
  1262 
  1245 version_CVS
  1263 version_CVS
  1246     ^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.127 2012-04-25 19:05:49 stefan Exp $'
  1264     ^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.128 2013-01-07 15:50:23 stefan Exp $'
  1247 ! !
  1265 ! !
       
  1266 
  1248 
  1267 
  1249 Font initialize!
  1268 Font initialize!