C#如何保存运行时字体设置

Bra*_*rad 3 c#

我允许用户能够为列表视图做出自己的字体选择.您认为最好的方法是什么?我应该将它保存到注册表或应用程序文件夹中的文件,以及应该保存哪些属性以确保在重新启动应用程序时正确地重新显示该字体?

谢谢你的建议.

编辑:

感谢您的所有答案.回答您的一个问题 - 该机器不会用于多个用户.

我应该保存什么才能重新创建设置.

如果我将它保存到分隔的字符串,字体类可以解析这个吗?"Microsoft Sans Serif,8.25pt,style = Bold"

aku*_*aku 13

关于在何处/如何保存应用程序设置,请参阅此答案

您可以将字体保存为字符串,稍后使用以下代码加载它:

Font font1 = new Font("Arial", 12, FontStyle.Italic);
TypeConverter converter = TypeDescriptor.GetConverter(typeof(Font));
// Saving Font object as a string
string fontString = converter.ConvertToString(font1);
// Load an instance of Font from a string
Font font = (Font)converter.ConvertFromString(fontString);
Run Code Online (Sandbox Code Playgroud)