Previous | Index | Next 

[HOWTO] Determine the font used for forms and controls

VB.NET doesn’t support the following standard (non True Type) fonts: Courier, Fixedsys, Modern, MS Sans Serif, MS Serif, Roman, Script, Small Fonts, System, Terminal, and all WST_* fonts. VB Migration Partner automatically converts references to these fonts to references to Courier New (if the font is monospaced, as is the case of Courier and Fixedsys) or Arial (in all other cases). If the default substitution strategy doesn’t work well for you, or if you want to change fonts during the migration process, you can use one of the following three pragmas.

First, you can use the FormFont pragma to set the Font property of all the forms that don’t specify a given font themselves. This pragma can affect the current form only, or you can use project-level scope to affect all the forms in the application. This is the easiest way to change fonts for all the forms in the application:

         '## project:FormFont Courier New

You can specify a font size too:

         '## project:FormFont Courier New, 12

Second, you can replace all occurrences of a given font with a different font, while keeping the original font size, by means of the ReplaceFont pragma. Again, this pragma can have form- and project-level scope. For example, you can replace all Arial fonts with Arial Narrow fonts using this pragma:

         '## project:ReplaceFont Arial, Arial Narrow

Third, you can replace specific combinations of font name/font size with a different name/size combination by means of the ReplaceFontSize pragma. For example, you can replace all occurrences of Arial 10 with Arial Narrow 12, using this pragma:

         '## project:ReplaceFontSize Arial, 10, Arial Narrow, 12


Previous | Index | Next