views:

715

answers:

3

I am writing a Japanese language quiz program and I don't want to require people to install the East Asian language pack for Windows XP. I am using GDI+ for drawing text. I tried downloading a free Unicode font and using that to draw text. I tested it on my computer (with East asian pack installed) and it displayed the Japanese characters correctly using the downloaded font, but on another computer without the language pack it didn't work.

I am looking for suggestions on how to make this work. The program is pretty simple and is written in C++ using only Win32 API, GDI+, and STL. If possible I would like to stick to just these libraries. I do have UNICODE #defined.

The code that I am basically using for drawing text is pasted below:

#include <gdiplus.h>
using namespace Gdiplus ;

Graphics * gi ;

PrivateFontCollection _fonts ;
_fonts.AddFontFile(fontFilename) ;
Font * currentFont = new Font(fontName, fontSize, FontStyleRegular, UnitPoint, &_fonts) ;

std::wstring text = L"Some text" ;
gi->DrawString(text.c_str(), (INT)text.size(), currentFont, rectangle, &format, &brush) ;
+1  A: 

The solution is fairly easy. Since you don't want to ship the font, and you can't count on any font being available, you will have to ship images of all characters you want to use. I suggest to use PNG, as JPEG is aimed at photos (lots of small gradients)

MSalters
I need to have several different sizes and colors of text, so using pre-rendered characters will not work very well.
Bakanekobrain
A: 

I was wrong. If you have a font that includes Japanese Characters it will display correctly in Windows XP even if East Asian language Pack is not installed.

If you have the East Asian Language Pack installed and if your font doesn't support Japanese characters, Windows will pick from between one of two fonts that it thinks matches your font the closest. This caused me to think that the fonts I was using included Japanese characters since it would change the way the characters were drawn when I switched between my font and the system font.

Microsoft has a free to install Japanese font called Meiryo Collection Version 5.00. Also here is a page listing more Japanese fonts , The only problem with the fonts listed is the licensing is not clear.

Bakanekobrain
A: 

There is also a font called Lucida Sans Unicode which may help to alleviate problems.