User Tools

Site Tools


selecting_20a_20font_20by_20pixel_20height

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
selecting_20a_20font_20by_20pixel_20height [2018/04/17 13:52]
richardrussell Tidied up formatting
selecting_20a_20font_20by_20pixel_20height [2018/04/17 18:37] (current)
tbest3112 Added syntax highlighting
Line 2: Line 2:
  
 //by Richard Russell, July 2007//\\ \\  The BBC BASIC for Windows [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwin8.html#​font|*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%20different%20DPI%20values|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:​\\ ​ //by Richard Russell, July 2007//\\ \\  The BBC BASIC for Windows [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwin8.html#​font|*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%20different%20DPI%20values|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 bb4w>
         @vdu%!220 = PixelHeight%         @vdu%!220 = PixelHeight%
         *FONT FaceName         *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:​\\ ​ 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 bb4w>
         @vdu%!220 = 40         @vdu%!220 = 40
         *FONT Arial         *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:​\\ ​ 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 bb4w>
         @vdu%!220 = -40         @vdu%!220 = -40
         *FONT Arial         *FONT Arial
 +</​code>​
 ---- ----
  
 **BBC BASIC for Windows version 6 only**:\\ \\  You can optionally specify a style such as **bold**, //italic// or __underlined__ as follows:​\\ ​ **BBC BASIC for Windows version 6 only**:\\ \\  You can optionally specify a style such as **bold**, //italic// or __underlined__ as follows:​\\ ​
 +<code bb4w>
         @vdu%!220 = 40         @vdu%!220 = 40
         *FONT Arial,B         *FONT Arial,B
 +</​code>​
 You can also set the character'​s width independently of its height:​\\ ​ You can also set the character'​s width independently of its height:​\\ ​
 +<code bb4w>
         @vdu%!216 = -40         @vdu%!216 = -40
         @vdu%!220 = 40         @vdu%!220 = 40
         *FONT Arial         *FONT Arial
 +</​code>​
 Note that you must specify the width as a negative value. Note that you must specify the width as a negative value.
selecting_20a_20font_20by_20pixel_20height.txt ยท Last modified: 2018/04/17 18:37 by tbest3112