VS2008 - VB.net 字体对话框 - 按代码页/语言过滤字体

发布于 2024-09-27 03:54:31 字数 812 浏览 9 评论 0原文

更新(回应汉斯·帕桑特的第一个答案): 我想我没有很好地解释我的用例。该应用程序旨在让人们以“主”语言(很可能是英语,但不一定)输入数据,然后方便输入另一种语言的翻译。这一切都是通过富文本框界面完成的。

因此,无论他们想要使用什么字体来输入翻译,都必须是支持他们要翻译的语言的脚本的字体。

如果我知道“目标语言”,最好只列出支持该语言文本输入的字体。

=================================================== ====================

我正在开发带有 SQL Server 后端的 VB.net 应用程序。我们将支持多种语言的富文本条目(从用户处接受),包括那些非西方文字的条目(例如中文、日语、阿拉伯语等)。

我们有一个对话框,用户可以从中选择语言他们想使用。对于每种语言,用户必须指定合适的(默认)字体,以便在应用程序的富文本框中输入该语言的任何文本。

示例:用户想要用中文输入文本,因此选择“中文”作为我们应用程序中使用的语言。用户必须指定输入汉字的字体;所以我们显示一个Windows.Forms.FontDialog。

在此字体选择对话框中,我希望能够根据他们选择的语言的代码页(脚本)过滤可用字体列表。

例如,字体“Brush Script MT”仅支持西文字符,不支持中文,因此如果用户选择输入中文文本的字体,则“Brush Script MT”字体不应出现在列表中。

有人对如何实现这一目标有任何想法吗?我首先使用 System.Text.Encoding 来获取本地系统使用的 Windows 代码页的编号 - 我走的路正确吗?

感谢您的帮助!

马特

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 done 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

亽野灬性zι浪 2024-10-04 03:54:31

首先,您调用 EnumFontFamiliesEx()

在回调函数中,您将获得一个描述字体属性的 NEWTEXTMETRICEX 结构。

该结构包含一个名为“ntmTm”的嵌入结构,该结构具有一个字段“tmCharSet”。

一些值的示例如下:

128 = SHIFTJIS
129 = HANGUL
130 = JOHAB
134 = GB2312
136 = CHINESEBIG5

通过这种方式,字体会告诉您它支持 BIG5 字符集等。

此外,该结构还有另一个嵌入结构“ntmFontSig”,其中包含字段“fsUsb”,该字段具有可识别最多 126 个 Unicode 子范围的 128 位 Unicode 子集位字段。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文