【问题标题】:How to get a font's name and its styles?如何获取字体的名称及其样式?
【发布时间】:2021-11-27 08:49:42
【问题描述】:

我有两个组合框:[_cmbxFontName, _cmbxStyleName]

我可以将所有已安装的字体加载到_cmbxFontName,但我无法加载字体样式。如果我在_cmbxFontName 中选择一个字体名称,那么另一个_cmbxstyleName 组合框想要加载它的样式。例如" [Regular、Normal、Bold、Italic 等]。

我知道所有字体都有不同的样式,但我怎样才能找到并加载它们?

【问题讨论】:

    标签: vb.net fonts


    【解决方案1】:

    您可以使用 System.Drawing.FontStyle 枚举来列出样式。我认为您可以在创建字体时在 FontStyle 中为任何字体指定任何样式。

    New Font(FontFamily.GenericSansSerif, 12.0F, FontStyle.Bold)
    

    您可以像这样将字体样式加载到组合框中:

    Dim styles() As FontStyle
    Dim style As FontStyle
    
    styles = System.Enum.GetValues(GetType(FontStyle))
    For Each style In styles
      combobox1.items.add(style.ToString)
    Next style
    

    【讨论】:

      猜你喜欢
      • 2011-06-02
      • 2020-06-23
      • 2012-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多