473,750 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

international font selection

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 be
included 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 be
fine!

Thanks,

- Jim
Jul 19 '05 #1
3 2643
To determine which fonts are available, you can instantiate an
InstalledFontCo llection object and then read its Families property.
This will give you an array of FontFamily objects, and FontFamily.Name
gives you the font name.

I'm not sure how to detect which characters are available in a font,
though. I'd be surprised if there wasn't a way to do it, but I didn't
see it in a quick skim through the docs.
Jim Puls wrote:
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 be
included 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 be
fine!

Thanks,

- Jim


Jul 19 '05 #2
Looking specifically for Japanese, you can base it on a font charset value
of 128?
--
MichKa [MS]

This posting is provided "AS IS" with
no warranties, and confers no rights.
"Joe White" <ip***@hotmail. com> wrote in message
news:3F******** ******@hotmail. com...
To determine which fonts are available, you can instantiate an
InstalledFontCo llection object and then read its Families property.
This will give you an array of FontFamily objects, and FontFamily.Name
gives you the font name.

I'm not sure how to detect which characters are available in a font,
though. I'd be surprised if there wasn't a way to do it, but I didn't
see it in a quick skim through the docs.
Jim Puls wrote:
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 be included 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 be fine!

Thanks,

- Jim

Jul 19 '05 #3
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


Jul 19 '05 #4

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

Similar topics

4
3661
by: Michel Joly de Lotbiniere | last post by:
I hope this is the correct newsgroup for this subject. The other day I came across a site www.safesquid.com that specified font-family:Terminal font-size:9pt in the inline css for command-line displays in the page content. On my Windows 2000 PC, Terminal is a bit-mapped font that comes in various fixed sizes. The rendering differences between Mozilla 1.7.2 (which is my default browser) and MS IE 6 (latest patches) are fully illustrated...
3
351
by: Jim Puls | last post by:
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 be included with the app. How do I determine which fonts are available on...
2
1820
by: MLH | last post by:
This is NOT of paramount importance. I'm sure there are others whose questions are mission critical. Mine is not. I have always wanted a report that looked like this... Here is some sample text in Alba. Here is some sample text in Alba Matter. Here is some sample text in Alba Super. .... Here is some sample text in Times New Roman
1
2384
by: Joerg | last post by:
I am in the process of creating an international GUI application with C# on ..NET1.1 (Win2k), which is supposed to implement a particular look/design. In order to achieve this, I plan amongst others to define a certain font (MS Arial Unicode) for the user controls, and provide custom controls which have the font property fixed set to this font. The application is supposed to be used in different countries (including China), so I wonder...
2
3956
by: Michael A. Covington | last post by:
When you change the Font property of a RichTextBox, does it change the font of all the contents, or only the text subsequently added, or only the selection, or what?
2
8756
by: Hariharan S | last post by:
Hi Guys, Have an issue with the Font object. I have a text box in which I can enter text and I have included a small button which upon selection, should enable me to change the newly entered text into bold. But it is not what is happening. All the previous information entered in the regular font too gets changed to bold. The code on the button click event handler is as follows ...
1
3683
by: | last post by:
Is there any way i can disable Font Style and Size Section that comes on Font Dialog Box.
4
4610
by: H-S | last post by:
Please help. This is a real puzzler! Originally posted on microsoft.public.dotnet.framework.windowsforms but no answer found! I have a read-only textBox which shows the results of a selection on another form. When the selection changes from the saved data, I wish to show it a different colour. As it is read-only the ForeColor property has no effect.
1
2597
by: hmkaddoura | last post by:
Hi All, Am trying to change the MS word font in my vb.net application by using the following code Dim sizo As Single = 14 ... doc.ActiveWindow.Selection.SetRange(doc.Paragraphs(1).Range.Start, doc.Paragraphs(app.ActiveDocument.Paragraphs.Count()).Range.End) doc.ActiveWindow.Selection.Font.Bold = 1 doc.ActiveWindow.Selection.Font.Name = "Traditional Arabic" ...
0
9001
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9583
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9396
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9342
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6081
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4716
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4888
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.