Get Font language?

S

Sin Jeong-hun

Windows comes with many fonts. When I'm writing with a word processor,
it's always annoying that fonts of the languages which I can't even
read (such as arabic) fill the font list making it hard for me to
choose the fonts I use. Those fonts are really useless because even if
I accidentally encounter web pages in those languages I can't even
understand what it says. I guess this situation is true for most
people. They always find font lists that are filled with fonts that
they have never used and never will.

Adobe Photoshop somehow groups the fonts according to their language.
I don't know about other languages but I can recognize that at least
Japanese, Korean, Simplified Chinese and Traditional Chinese fonts are
properly grouped. I would like to do the same thing. I would like to
show only the fonts that belong to some specific language so that
users can easily choose what they want.

First, I tried,
InstalledFontCollection fonts = new InstalledFontCollection();
foreach (FontFamily ff in fonts.Families)
{
try
{
Font f = new Font(ff, 10);
Debug.WriteLine(ff.Name+ " : " + f.GdiCharSet.ToString());
}
catch{ }
}
But it returned all 1's for all fonts. I've searched Google and fixed
the code like,
InstalledFontCollection fonts = new InstalledFontCollection();
foreach (FontFamily ff in fonts.Families)
{
try
{
Font f = new Font(ff, 10);
LOGFONT lf = new LOGFONT();
f.ToLogFont(lf);
Debug.WriteLine(ff.Name+ " : " + lf.lfCharSet.ToString());
}
catch{ }
}
Now, not all fonts returned 1's but I could clearly notice that all
the Korean fonts and all the Japanese fonts returned 1's. With these
values, I can't tell Korean fonts from Japanese fonts. What went wrong?
 
M

Mihai N.

No replies... Does that mean that this task is impossible with BCL?

You might try using GetFontUnicodeRanges.
Or you might try setting lfCharSet in LOGFONT to each charset possible,
and call EnumFontFamiliesEx for each one.

But this breaks down these days, when one font supports more than one
language. I find that at times the "smart" grouping in PS (and others)
is so smart, that I can hardly find what I want.

M.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top