简体   繁体   English

寻找在WinForms应用程序中使用自定义字体定义的最佳方法

[英]Looking for the optimal way to use custom font definitions in WinForms application

I have a Windows Forms application where I need to make all fonts of all UI elements configurable from a separate file. 我有一个Windows窗体应用程序,我需要在一个单独的文件中配置所有UI元素的所有字体。 Ie I want to be able to specify that a label has a font "TitleBarBoldFont" which would resolve to a real font, depending on the current locale. 即我希望能够指定标签具有字体“TitleBarBoldFont”,该字体将解析为真实字体,具体取决于当前的区域设置。 The configuration file may contain a corresponding section like this: 配置文件可能包含相应的部分,如下所示:

    <Font fontID="TitleBarBoldFont">
        <Display facename="Helvetica" pointSize="12">
            <Override lang="ja" facename="Meiryo Bold" pointSize="12"/>
            <Override lang="zh" facename="SimHei" pointSize="12"/>
            <Override lang="ru" facename="Arial Bold" pointSize="12"/>
        </Display>
    </Font>

My question is: is there a standard .NET/Windows Forms way to achieve this so that I could specify my custom fonts in the WinForms designer and wouldn't have to explicitly call a font resolution method for each GUI element in the code? 我的问题是:是否有一种标准的.NET / Windows Forms方法来实现这一点,以便我可以在WinForms设计器中指定我的自定义字体,而不必为代码中的每个GUI元素显式调用字体解析方法?

最简单的方法是将属性窗口中的font属性绑定到应用程序设置,该设置将最终出现在应用程序的app.config文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM