Selecting+a+font+by+pixel+height

//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: code format="bb4w" @vdu%!220 = PixelHeight% *FONT FaceName code 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: code format="bb4w" @vdu%!220 = 40 *FONT Arial code 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: code format="bb4w" @vdu%!220 = -40 *FONT Arial code


 * BBC BASIC for Windows version 6 only**:

You can optionally specify a style such as **bold**, //italic// or __underlined__ as follows: code format="bb4w" @vdu%!220 = 40 *FONT Arial,B code You can also set the character's width independently of its height: code format="bb4w" @vdu%!216 = -40 @vdu%!220 = 40 *FONT Arial code Note that you must specify the width as a negative value.