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("Gdi32.dll")]
public static extern IntPtr SelectObject(
IntPtr hdc, // handle to DC
IntPtr hgdiobj // handle to object
);
[DllImport("Gdi32.dll", CharSet=CharSet.Unicode)]
public static extern int GetGlyphIndices(
IntPtr hdc, // handle to DC
[MarshalAs(UnmanagedType.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.PaintEventArgs e)
{
FontFamily fontFamily = new FontFamily("Arial");
Font font = new Font(
fontFamily,
14,
FontStyle.Regular,
GraphicsUnit.Point);
System.IntPtr hd = e.Graphics.GetHdc();
Win33.SelectObject(hd,font.ToHfont());
string str = "hello";
int count = str.Length;
Int16[] rtcode = new Int16[count];
Win33.GetGlyphIndices(hd,str,count,rtcode,0xffff);
e.Graphics.ReleaseHdc(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.org>
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.public.dotnet.general,microsoft.public.d otnet.languages.csharpNNTP-Posting-Host: 12-208-112-188.client.attbi.com 12.208.112.188
Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.languages.csharp:29726
microsoft.public.dotnet.general:14254X-Tomcat-NG: microsoft.public.dotnet.general
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