VS2008 - VB.net Font Dialog - Filter Fonts by Codepage/Language
Update (in response to first answer, from Hans Passant): I guess I didn't explain my use-case well enough. This application will be designed for people to enter data in a "master" language (most likely English, but not necessarily), and then facilitate the entry of translations in another language. This is all don开发者_StackOverflowe with a rich-text box interface.
So, whatever font they want to use to enter the translations MUST be a font that supports the script of the language into which they are translating.
If I know the "target language", it would be nice to only list fonts that support entry of text IN that language.
======================================================================
I am working on a VB.net application with a SQL Server back-end. We are going to support Rich-Text entries (accepted from the user) in multiple languages, including those that are not in Western Script (e.g. Chinese, Japanese, Arabic, etc.)
We have a dialog from which the user can select the languages they want to use. For each language, user has to specify a suitable (default) font in which to enter any text in that language, in rich-text boxes in the application.
Example: user wants to enter text in Chinese, so selects "Chinese" as a language to use in our application. User has to specify a font in which to enter Chinese characters; so we display a Windows.Forms.FontDialog.
In this font-selection dialog I would like to be able to filter the list of available fonts based on the codepage (script) of the language that they chose.
e.g. the font "Brush Script MT" only supports Western characters - NOT Chinese - so if user is choosing a font for entering Chinese text, then "Brush Script MT" font should NOT appear in the list.
Does anybody have any ideas on how to accomplish this? I have started out by using System.Text.Encoding to obtain the number of the Windows codepage in use by the local system - am I going down the right path?
Thanks for any help!
Matt
First you call EnumFontFamiliesEx()
In the callback function you get a NEWTEXTMETRICEX
structure that describes the font's properties.
The structure contains an embedded structure that is named "ntmTm
" which has a field "tmCharSet
".
Some examples of values are:
128 = SHIFTJIS
129 = HANGUL
130 = JOHAB
134 = GB2312
136 = CHINESEBIG5
This way the font tells you that it supports for example the BIG5 charset.
Additionally the structure has another embedded structure "ntmFontSig
" that contains a field "fsUsb
" with a 128 Bit Unicode subset bitfield identifying up to 126 Unicode subranges.
精彩评论