获取特定字体的字体样式 [英] get fontstyles of particular font

查看:110
本文介绍了获取特定字体的字体样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个组合框combobox1& combobox2我要在combobox1中获取所有系统字体,我需要获取combobox2中选定字体的字体样式.

i have two comboboxes combobox1 & combobox2 i am getting all system fonts in combobox1 i need to get fontstyles of a select font in combobox2

Dim fc As New Drawing.Text.InstalledFontCollection
   Dim ff As FontFamily() = fc.Families()
   For Each family As FontFamily In ff
       Me.ComboBox1.Items.Add(family.Name)
   Next


当我为例如选择字体名称时. Monotype Corsiva字体只有斜体&斜体粗体字体样式

简而言之,我需要获取与我在combobox1中选择的字体相关的字体,因为字体针对不同的字体而有所不同


when i select font name for eg. Monotype Corsiva font have only italic & italic bold font style

in brief i need to get fontstyles related to the font i select in combobox1 because fontstyles are different for different fonts

推荐答案

这可能对您有所帮助:
http://stackoverflow.com/questions/5659610/重新获得字体名称和自己的样式 [
this might help you:
http://stackoverflow.com/questions/5659610/re-how-to-get-font-name-and-its-own-styles[^]


我认为这样做的方法是测试每个 FontFamily.IsStyleAvailable [ ^ ]方法.

我还看到(书籍,Microsoft Windows窗体编程,Charles Petzold,Microsoft Press,2006)尝试创建每种样式的字体(带有异常陷阱),但没有任何理由比明确的样式可用性测试更喜欢这种字体.

艾伦.
I think the way to do this to test each of the styles Regular, Bold, Italic and Bold|Italic with the FontFamily.IsStyleAvailable[^] method.

I have also seen (Book, Programming Microsoft Windows Forms, Charles Petzold, Microsoft Press, 2006) trial creation of a font in each style with exception trapping, but can''t think of any reason to prefer this over the explicit style availability test.

Alan.


这篇关于获取特定字体的字体样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆