tags:

views:

373

answers:

6

I'm building a .net application with windows forms. I'm pondering on the following problem: If I specify fonts in my application that are available only in Vista and Office 07, what will happen when the application tries to run in a machine without these ?

I suppose the system won't be able to fall back to a font of it's family, since they are initialized internally using strings (eg "Segoe UI").

What's the best practice to follow, such that I will still be able to specify fonts through the forms designer and not worry about things like this breaking ?

A: 

Check the EULA first in both Office and Vista to make sure the fonts aren't sacred, but you may be able to include those fonts in your installer package and have it install them.

Brian Cline
according to the EULA, it's impossible.
KCorax
+2  A: 

Either check the OS and use Tahoma on XP and Segoe UI on Vista or let the user choose in an options dialog. Installing Segoe UI on XP seems to be considered not-done by most.

Jasper Bekkers
+1  A: 

I agree with Brian Cline, if you can include them that would be best.

A great way to see what will happen with a clean OS is to start up a virtual machine on your system and install the program on it. Microsoft has a free virtual machine program called 'Microsoft Virtual PC'. Using this, you can load up any operating system within a virtual machine and test how your application will react in a 'clean' install environment. It will act the same as a regular computer and will only have the programs you install on it specifically. I use this for my winforms applications and it works great!

Let me know if this helps! JFV

JFV
@JFV I'm aware of the solution and I have plenty of VMs, but not an XP one. I thought that asking here could save me the hassle. Still I'm looking to hear to best practices.
KCorax
A: 

Barring the ability to redistribute the fonts in your installer, you may have to check for the existence of said fonts first. If they are not there, have your app pick an alternative font from a static list of fallback choices.

Brian Cline
+1  A: 

I think it's System.Drawing.SystemFonts.MessageBoxFont that gives Segoe UI, Tahoma, then MS Sans Serif depending on the OS. As long as your layout is fluid enough---WPF is good at this, but in Windows Forms it's much harder---then it'll work great. Regardless, it'd be worth using that setting then testing in VMs to see if it works.

Also rather unfortuantely the designer doesn't have support for setting the font like that, and it will reset things to hard-coded Segoe UI sometimes (if you're using Vista).

This kind of thing was actually one of the reasons I'm starting to move to WPF :).

Domenic
A: 

Either take Jasper's advice, or follow mine: Don't do it. Unless you're reskinning the whole app for some reason, just use the fonts already defined on the system. If you look like every other battleship gray (or mildly themed) app, except the fonts, it looks a little odd to users.

Either way, including the fonts is a EULA violation. Users can download the Office 2007 Compatibility Pack and get most of them, but the one notable exception will be (I believe) Segoe UI: This font is a Vista-only font.

If you do want to be different, then take Jasper's advice and detect XP vs Vista. If you're on XP, either use Tahoma or Trebuchet MS. If you're on Vista, go ahead and use the cool new fonts.

John Rudy