How to display a character map of a bitmap font
Last updated at 4:26 am UTC on 29 September 2006
updateMe
The code snippet was posted to the mailing list on 5 Jan 2000 by Andrew C. Greenberg and and enhanced by Hannes Hirzel.
To display a character chart of a font copy the code snippet below
to a workspace, if needed adapt choose another font in the dictionary TextConstants. Evaluate the code. A Form with the character chart will be shown and a gif file is written to the default directory.
Display restoreAfter:
[strFnt _ (TextConstants at: #Atlanta) fontArray at: 2.
f _ Form extent: 440@400.
0 to: 15 do: [:i | i hex displayOn: f at: 10@(20*i).
0 to: 15 do: [:j | ((ccode _ 16*i+j) between: 1 and: (strFnt xTable size - 2))
ifTrue: [ (strFnt characterFormAt: ccode asCharacter)
displayOn: f at: (20*j+50)@(20*i)]
]].
f displayAt: 20@100.
GIFReadWriter putForm: f onFileNamed: 'chartable3.gif'].
Tested in Squeak version 2.9a-3144 by Hannes Hirzel but should work in earlier versions too; retested successfully in 3.3a-4798, 3.5alpha-5168 and Squeak 3.6-5424