473,467 Members | 1,514 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Get Font language?

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?
Sep 14 '08 #1
3 2580
No replies... Does that mean that this task is impossible with BCL?

On Sep 14, 10:59*pm, Sin Jeong-hun <typing...@gmail.comwrote:
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?
Sep 16 '08 #2
On Mon, 15 Sep 2008 22:33:18 -0700, Sin Jeong-hun <ty*******@gmail.com>
wrote:
No replies... Does that mean that this task is impossible with BCL?
At most, all you can say for sure is that no one who read your question
and who had time to reply knows the answer. :)

As for the specific question, if any program can do it on Windows, then
all programs can do it. At worst, you might have to use p/invoke to get
at the unmanaged Windows API that the other programs use. However,
looking at the .NET docs, it looks to me as though you _might_ be able to
get this information using the System.Windows.Media namespace version of
the FontFamily class. That includes a FamilyMaps property that returns a
collection of FontFamilyMap instances that describe different languages
supported by a font.

I don't have any first-hand experience with it, but it's something you
might look at if you haven't already.

Pete
Sep 16 '08 #3
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.
--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Sep 17 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: StaZ | last post by:
Hello I have a ASP script that generates a jpg/gif image using the Overpower.ImageLib component. I do all my tests on my own intranet server before uploading it to the webhost Actually i...
5
by: Mike M | last post by:
Hi all, Attempting to do css for cross platform/browser compatibility. Have an issue with IE6 sp1 running on NT4. When using IE6 sp1, example 1 works fine, example 2 produces unreadable text....
0
by: Hariharan Subramony | last post by:
Hi Guys, I have the following issue ... I have a form with two richTextBoxes named (01) richTextBox1 (02) richTextBox2 with some controls for selecting Font types (Arial, Courier, etc)...
4
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a...
2
by: alberto.ribao | last post by:
Hello, I'm making some proofs of concept about localization with .NET Framework 2.0 My trouble is I'm trying to display the next string with a call to MessageBox.Show method: ...
9
by: MadingS | last post by:
Is there an HTML (or CSS) way to say "use the user's INPUT font, whatever that might be."? Most browsers have the ability for the user to pick his or her own preference for what font to use...
14
by: Roedy Green | last post by:
Is there a shortcut way to define the default font family (and characteristics) to be applied to all styles? -- Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
16
by: Laszlo Nagy | last post by:
I need to create multi lingual invoices from reportlab. I think it is possible to use UTF 8 strings but there is a problem with the font. I could not find any free TTF font that can do latin1,...
2
by: desertavataraz | last post by:
I am going write an application in C++ that allows the user to see two languages at once, and allows them to search each individual language for words or keywords. I have a font that I made...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.