font. Loading font file to make an inscription on an image
Besides drawing, Parser provides for a possibility of making inscription on an image. To realize this opportunity, it is necessary to have special files with font images. You can either use existing font files or create those of your own, with a needed set of characters.
Having loaded such a file with the help of method font, set of characters specified in method parameters is associated with fragments of image stored in a file. This must be an image in GIF format with unfilled background, containing image of necessary set of characters looking like the following:
Example of file digits.gif with image of numbers:
Height of each character is defined as the ratio of image height to the number of characters in the set.
The method has the following parameters:
Set of characters-list of characters included in the font file
Name and path-of and to the font file
Space character width-in pixels
Character width-optional parameter
Some paramaters could be specified as a hash:
$.space(0)-space character width. By default space character width is equal to gif width.
$.width(x)-character width for monospaced font. By default proportional font is used.
$.width(0)-use monospaced font with auto-detection character width (will be equal to gif width)
$.spacing(0)-intersymbol distance. By default equal 1 pixel
By default, when the file is loaded the width of each of its character is measured, and when outputting the text, proportional font is used. If you specify character width, monospaced font will be used.
All characters must be left aligned to start right from left edge of image.
In this case, the file will be loaded, containing images of characters from 0 to 9, and the set of characters will be associated with their graphic equivalents. After the font for the inscription is defined, one can use method text to make the inscription itself.