views:

185

answers:

1

I'm trying to change the FontFamily of a ListBox to a fixed-width font, but I don't know what's available. Here's what I have:

<ListBox Margin="12,55,12,12" Name="listBox1" FontFamily="Arial" />

When I try something like FontFamily="Courier", it won't show up as Courier, which leads me to believe that font may not be available. I've tried searching for the last 10 minutes, but I can't find a list of fonts that I can use by default in WPF.

+2  A: 

Try Courier New.

Courier is a raster font, and raster fonts are not supported by WPF.

Courier New is a TrueType font, so it should work fine.

The easiest way to check for a specific font is to look in the Font dropdown in Word.
Raster fonts such as Courier will have a pixelated printer icon; TrueType fonts will have a TT or an O.

EDIT:

In answer to your comment, WPF can use any font installed on the end-user's system.
Here is a list of fonts included with each version of Windows. These fonts will always be available. If you want to use a different font, you'll have to distribute it with your app. (And check the font's license terms)

SLaks
I thought I had tried that, but I guess not, because it worked. It'd still be cool to find a list of `FontFamily` fonts for reference, though.
Ben McCormack
A list of which `FontFamily` fonts?
SLaks
ones that I can use in the `ListBox` control. I don't know where WPF is looking to find fonts that it can use in the `ListBox` control. Is it in the host operating system? The BCL? For example, `Courier New` works but `Courier` does not. What determines that and how do I know which fonts will work?
Ben McCormack
I guess I had to pick a non-true-type font to make this complicated :-). Thanks for your help.
Ben McCormack
sure, how much later? (I didn't think accepted answers affected the rep limit).
Ben McCormack
You deleted the comment where you asked me to wait to accept your answer so you could go over the rep limit. That kind of makes my above reply sound a little silly :-).
Ben McCormack
You can delete your reply as well.
SLaks