manual:chapter3:fonts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
manual:chapter3:fonts [2019/11/22 15:53]
jojo1973 Font building, part 2
manual:chapter3:fonts [2019/11/23 09:11]
jojo1973 Finished
Line 7: Line 7:
 A font object is represented on the stack as ''FONTDATA xx yyy...'', where ''yyy...'' is a string of characters (''A''-''Z'', ''a''-''z'', ''$'' and ''#'') encoding the glyphs and the translation table that associates glyphs to Unicode code points while ''xx'' is the length (padded to a multiple of 4 bytes) of the aforementioned block, expressed in nibbles. A font object is represented on the stack as ''FONTDATA xx yyy...'', where ''yyy...'' is a string of characters (''A''-''Z'', ''a''-''z'', ''$'' and ''#'') encoding the glyphs and the translation table that associates glyphs to Unicode code points while ''xx'' is the length (padded to a multiple of 4 bytes) of the aforementioned block, expressed in nibbles.
  
-To install a font on the system it must be stored into a variable, whose name will become the name of the font. The command ''[[manual:chapter6:fonts:cmd_fntsto|FNTSTO]]'' is used to finalize the installation of the font. A font object can be recalled by the ''[[manual:chapter6:fonts:cmd_fntrcl|FNTRCL]]'' command and uninstalled by the ''[[manual:chapter6:fonts:cmd_fntpg|FNTPG]]'' command.+The installation of a font on the system is performed by storing the font object into a variable, whose name will become the name of the font. The command ''[[manual:chapter6:fonts:cmd_fntsto|FNTSTO]]'' executes this operation. A font object can be recalled to the stack by the ''[[manual:chapter6:fonts:cmd_fntrcl|FNTRCL]]'' command and uninstalled using the ''[[manual:chapter6:fonts:cmd_fntpg|FNTPG]]'' command.
  
 **newRPL** already provides 11 system fonts which are always available and can't be uninstalled. Smaller sizes are suited for soft keys, while larger sizes are preferable for stack display; however nothing prevents using large sizes for soft keys and small sizes for stack display. **newRPL** already provides 11 system fonts which are always available and can't be uninstalled. Smaller sizes are suited for soft keys, while larger sizes are preferable for stack display; however nothing prevents using large sizes for soft keys and small sizes for stack display.
Line 70: Line 70:
 A closer examination of the file reveals that the bitmap is actually 11 pixel high rather than 10. The extra bottom row of pixels is used to encode the width of each glyph: under the first glyph there are five black pixels, therefore the width of that glyph is 5 pixels; under the second glyph there are five white pixels thus its width is 5 pixels again, and so on until the end of the bitmap. A closer examination of the file reveals that the bitmap is actually 11 pixel high rather than 10. The extra bottom row of pixels is used to encode the width of each glyph: under the first glyph there are five black pixels, therefore the width of that glyph is 5 pixels; under the second glyph there are five white pixels thus its width is 5 pixels again, and so on until the end of the bitmap.
  
 +The structure of the translation table is even simpler: looking at the file ''[[https://sourceforge.net/p/newrpl/sources/ci/master/tree/bitmap/fonts/Font10_StyleA.txt|Font10_StyleA.txt]]'' one can see that, comments aside, each glyph in the font corresponds to a line in the file, listing one or more Unicode code points (multiple code points are separated by a comma).
 +
 +Code point ''0'' has a special meaning: any code point that doesn't match those present in the translation table will be mapped to the glyph with code point ''0''.
 +
 +Once the font has been drawn and the translation table written it's the time to actually build the font object using the ''bmp2font'' tool. Its syntax is the following:
 +<code>
 +bmp2font <font-bitmap-file.bmp> <font-text-file.txt> <output[.c or .nrpl]> [name of C variable]
 +</code>
 +where
 +  * ''font-bitmap-file.bmp'' is the bitmap (accepted formats are monochrome and 256 colors);
 +  * ''font-text-file.txt'' is the translation table;
 +  * ''output.*'' is the output file: it can be a **newRPL** object, directly transferrable to the calculator or a definition in C language ready to be included in the source code;
 +  * ''name of C variable'' is an optional parameter used to name internally the font in case the output of ''bmp2font'' is a C definition.
  • manual/chapter3/fonts.txt
  • Last modified: 2019/11/25 03:17
  • by jojo1973