Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
5.00/5 (3 votes)
See more:
I have an application that requires display of Chinese characters (preferably Unicode). In In VS2008 C++ Pro I can filter the enumerated fonts via font signature:

int CALLBACK MyApp::EnumFontCallback(...)
{
ENUMLOGFONTEX *lpelfe;
NEWTEXTMETRICEX *lpntme;

int nSimpCh = (lpntme->ntmFontSig.fsCsb[0] >> 17) && 0x1;
if (nSimpCh!=1) return;
int nTradCh = (lpntme->ntmFontSig.fsCsb[0] >> 19) && 0x1;
if (nTradCh=1) return;
...
else ListBox1.Items.Add(".....fontname ...");
....
}


How can I do this in VS2010 C# (express)? The closest thingy is the InstalledFontCollection() and IsStyleAvailable() - but that is very simplistic and has no option to determine which of the font family contains Unicode Chinese.

Thanks.


[Edited]Code is wrapped in "pre" tags[/Edited]
Posted
Updated 7-Feb-11 21:28pm
v2
Comments
Sergey Alexandrovich Kryukov 8-Feb-11 3:27am    
Not a bad question; my vote of 5.
--SA

These days, Chinese is supported almost exclusively in Unicode (everything else must die). And most font support both scripts (simplified and traditional). However, this Question makes perfect sense.

The solution is explained here: http://stackoverflow.com/questions/1439551/get-supported-characters-of-a-font-in-c[^].

If something is not clear, post a comment to this answer, I'll answer later (I need to sleep :-))
I'm familiar with Chinese to certain point :-).

—SA
 
Share this answer
 
Comments
Henry Minute 8-Feb-11 21:53pm    
SA this is from the OP I have moved it from an Answer:

Thanks for quick reply.

The real issue is that the app will be run on many PC's which are out of my control. Each user may have different fonts installed. Some may not have MS Arial Unicode font. Others may not have MS Office/Publisher so they have to resort to use 3rd party/free/shareware fonts. I do not know the typeface name nor family name of such fonts that they have installed. All i need to know is if a particular font supports simplified or traditional chinese. In other cases I also need to know if the font supports certain glyphs, etc.

So my program needs to query the enumerated fonts for the following information:
- character ranges supported
- typeface
- Truetype or OpenType

Hope that is clear.
Thanks again.
Sergey Alexandrovich Kryukov 8-Feb-11 22:56pm    
Mick Leong,

Yes, this is clear. What you explain is pretty much how I understood the nature of the requirements when I said your question makes perfect sense. (Well, maybe it's not clear to me why you need to tell Truetype from OpenType; I thought all you need is Unicode sub-set supported (you require your text to render) and font metrics, please see below.)

As I can understand your requirements, you need some automatic fallback mechanism: you require certain Chinese scripts to be rendered on UI; if your suggested font is not available on some computer, the application could try to replace the font with some available font based on your requirements for the set of Unicode code points to be rendered (as I understand, Chinese scripts may require up to 5 or so Unicode ranges, is that right?).

I think you have everything to solve this problem. So, my question is: do you need more help? If you got enough, please formally except my Answer.
If you feel you need something else, please commend on it and explain. From your recent comment I still don't know if you're good to go or not.

--SA
SAKryukov

Many thanks for your help. You have been very helpful but really to hit the nail on the head:

I need to access the equivalent of VS C++'s "font signature" in VS2010 VS# express.

Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900