18.6.2.2486.70 X-WIDTH XCHAR EXT

( xc-addr u -- n )

n is the number of monospace ASCII characters that take the same space to display as the xchar string xc-addr u; assuming a monospaced display font, i.e., xchar width is always an integer multiple of the width of an ASCII character.

Implementation:

: X-WIDTH ( xc-addr u -- n )
   0 ROT ROT OVER + SWAP ?DO
     I XC@+ SWAP >R XC-WIDTH +
   R> I - +LOOP ;

ContributeContributions