Incidentally, you can get a list of all the fonts that are installed on the current computer
using the shared SystemFontFamilies collection of the System.Windows.Media.Fonts class.
Here??™s an example that uses it to add fonts to a list box:
For Each fontFamily As FontFamily In Fonts.SystemFontFamilies
lstFonts.Items.Add(fontFamily.Source)
Next
The FontFamily object also allows you to examine other details, such as the line spacing
and associated typefaces.
nNote One of the ingredients that WPF doesn??™t include is a dialog box for choosing a font. The WPF Text
team has posted two much more attractive WPF font pickers, including a no-code version that uses data
binding (http://blogs.msdn.com/text/archive/2006/06/20/592777.aspx) and a more sophisticated
version that supports the optional typographic features that are found in some OpenType fonts
(http://blogs.msdn.com/text/archive/2006/11/01/sample-font-chooser.aspx).
Font Embedding
Another option for dealing with unusual fonts is to embed them in your application. That way,
your application never has a problem finding the font you want to use.
The embedding process is simple. First, you add the font file (typically, a file with the
extension .ttf) to your application and set the Build Action to Resource. (You can do this in
Visual Studio by selecting the font file in the Solution Explorer and changing its Build Action in
the Properties window.
Pages:
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373