Fixed-width Font .net Problem Between XP/Win7
I built a 开发者_JAVA百科.net application using Windows 7. One of the textboxes uses Consolas, a fixed-width font. When I run the application on XP some other non-fixed-width font is used. The fixed-width is important for legacy layout purposes.
What is going on here? Does XP somehow not have Consolas? Is there some other fixed-width font I can use? Is this some other issue entirely?
It is indeed the case that Consolas
was not originally part of XP. I only got it when I installed it as part of VS 2005 or 2008 - I can't remember now - but I think MS offered it originally as a separate download or something like that. It won't be redistributable, though - so clearly you won't be able to include it as part of your app.
I think it then became part of the OS offering from Vista onwards.
I would probably go with Courier New
in the absence of Consolas; there's also Courier
of course. You could enumerate the installed Fonts first to see if Consolas is available and use an alternative if not - using the InstalledFontCollection class.
I would assume that XP doesn't have Consolas, as it is a newer font than most system fonts. Try an older font like Courier New, that has been packaged in Windows for a while. See if that works for you.
精彩评论