by Richard Russell, July 2007
The BBC BASIC for Windows *FONT command selects the font size in points (nominally units of 1/72 inch), and as a consequence the character height in pixels varies acccording to the current Dots Per Inch setting. This is the way font size selection in Windows normally works and is what you would expect. See the article Supporting different DPI values for more information.
However there can be occasions when you would prefer the font height to be a specific size in pixels and not to change according to the DPI setting. For example you may wish the text to align with a graphic image which isn't scaled according to the DPI. To do that use the following code:
@vdu%!220 = PixelHeight% *FONT FaceName
Note particularly that no size is specified in the *FONT command. So for example if you wanted to select the Arial font with a height of 40 pixels you could do that as follows:
@vdu%!220 = 40 *FONT Arial
This sets the height of the character cell. You can alternatively set the height of the character itself (i.e. excluding the internal leading) by specifying a negative value:
@vdu%!220 = -40 *FONT Arial
BBC BASIC for Windows version 6 only:
You can optionally specify a style such as bold, italic or underlined as follows:
@vdu%!220 = 40 *FONT Arial,B
You can also set the character's width independently of its height:
@vdu%!216 = -40 @vdu%!220 = 40 *FONT Arial
Note that you must specify the width as a negative value.