I have a Unicode project which displays Arabic/Cyrillic/Chinese in Win7, but when I copy the same exe file to a virtual machine with a fresh install of XP SP3 it shows black rectangles instead.
At the same time I have an owner-drawn control which displays them fine. I use Arial font in it. The default MFC controls seem to be using MS Sans Serif however. When I changed my owner-drawn control to use MS Sans Serif it started showing black rectangles as well.
So I assume that the problem is with MS Sans Serif in XP. Can MS Sans Serif display Unicode in XP?
On Windows, there are very few fonts with a wide enough character repertoire to represent all of Arabic, Cyrillic, and Chinese. The ones that I know about don’t ship with Windows by default.
Instead, most of the Windows APIs for drawing text will automatically switch between fonts as needed for coverage. For example, you might be drawing a string in Tahoma that has some Chinese characters in it. Windows will automatically switch from Tahoma to a font that has the Chinese characters for you. This creates the illusion of having a font with a huge character repertoire.
Windows does this automatically if the font you’ve chosen is one of the major TrueType or OpenType fonts. If you’ve chosen an obscure font or a bitmap font, it won’t. As another answer pointed out, MS Sans Serif is a bitmap font. Microsoft Sans Serif is a TrueType font.
Also, for this font linking and fallback stuff to work, it needs to have some font to fall back to. For example, if you don’t have any fonts with Chinese characters, then you’ll get placeholder boxes instead of Chinese. Newer versions of Windows (like Windows 7) have lots of fallback fonts available out of the box. Older versions of Windows (like XP) shipped region specific versions that had only the fonts for that region out of the box. If you have a “U.S.” installation of Windows XP, you probably have to go into the control panel and tell it that you need multi-lingual support, which will load fonts and tables for Chinese, Arabic, etc.
Update: Mark Ransom asked for documentation links. I’ve not found a single place that describes the details of font linking and font fallback in one place. What I know I’ve gathered from various sources, like MSDN blogs (especially Michael Kaplan and Raymond Chen) and Uniscribe documentation. Due to a project with extremely unusual constraints, I had to implement my own font linking and fallback. In the process I learned a lot about how Windows does it.
Here are a few tidbits:
Definitions of Font Linking and Font Fallback: http://msdn.microsoft.com/en-us/goglobal/bb688163
Clarification of the differences between them: http://www.siao2.com/2005/10/01/476022.aspx
Uniscribe documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/dd374091(v=vs.85).aspx
Some specifics on font fallback: http://msdn.microsoft.com/en-us/library/windows/desktop/dd374105(v=vs.85).aspx
Michael Kaplan’s blog posts on font substitution and font linking start here: http://www.siao2.com/2005/03/20/399322.aspx
You can learn a bit about font linking from the old MLang APIs provided by IE: http://msdn.microsoft.com/en-us/library/ie/aa767872(v=vs.85).aspx