Hi Jim,
There is a GDI API function GetGlyphIndices which will help you very much.
The function can be used to determine whether a glyph exists in a font.
Here is a demo below:
1. Add the class below into your project which is used to call the GDI
API function.
public class Win33
{
[DllImport("Gdi3 2.dll")]
public static extern IntPtr SelectObject(
IntPtr hdc, // handle to DC
IntPtr hgdiobj // handle to object
);
[DllImport("Gdi3 2.dll", CharSet=CharSet .Unicode)]
public static extern int GetGlyphIndices (
IntPtr hdc, // handle to DC
[MarshalAs(Unman agedType.LPWStr )]
string lpstr, // string to convert
int c, // number of characters in string
Int16[] pgi, // array of glyph indices
int fl // glyph options
);
}
2. In order to get the hdc easier, I hereby override the OnPaint()
function (as below). You may achieve your individual aim with your own
method.
protected override void
OnPaint(System. Windows.Forms.P aintEventArgs e)
{
FontFamily fontFamily = new FontFamily("Ari al");
Font font = new Font(
fontFamily,
14,
FontStyle.Regul ar,
GraphicsUnit.Po int);
System.IntPtr hd = e.Graphics.GetH dc();
Win33.SelectObj ect(hd,font.ToH font());
string str = "hello";
int count = str.Length;
Int16[] rtcode = new Int16[count];
Win33.GetGlyphI ndices(hd,str,c ount,rtcode,0xf fff);
e.Graphics.Rele aseHdc(hd);
}
If a certain char is not supported by the font, the
"rtcode"(as above) will return zero.
[INFO]
Here is a helpful link about glyph indices of font.:
http://support.microsoft.com/default...en-us%3B241020
Regards,
Peter Huang
=============
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Jim Puls" <j.****@ieee.or g>
Subject: international font selection
Date: Mon, 30 Jun 2003 20:57:36 -0500
Lines: 19
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <ui************ **@TK2MSFTNGP11 .phx.gbl>
Newsgroups:
microsoft.publi c.dotnet.genera l,microsoft.pub lic.dotnet.lang uages.csharpNNTP-Posting-Host: 12-208-112-188.client.attb i.com 12.208.112.188
Path: cpmsftngxa09.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP11.phx.g bl
Xref: cpmsftngxa09.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:2972 6
microsoft.publi c.dotnet.genera l:14254X-Tomcat-NG: microsoft.publi c.dotnet.genera l
I'm writing a Windows Forms application in C# which will run generally in a
Western environment; e.g., EN-US. I need to access a unicode font on the
user's system which is capable of displaying Japanese characters - often
there will be one or more of such fonts, but I don't know which ones by
name. If one does not exist, I need to default to a public domain font to
beincluded with the app.
How do I determine which fonts are available on the user's system, and if
they have the required characters? I could come up with a short list of
probable font name candidates, but is there a better way?
If there are any references to URLs which have discussed this, that would
befine!
Thanks,
- Jim