简体   繁体   中英

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. 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. 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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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