字体转换为字符串,然后再返回 [英] convert font to string and back again

查看:190
本文介绍了字体转换为字符串,然后再返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的用户改变字体和字体颜色为不同的标签等应用程序,他们将它保存到一个文件,但我需要能够到指定标签的字体转换为字符串写入到文件中,然后当他们打开该文件我的程序将这个字符串转换回一个字体对象。如何才能做到这一点?我还没有发现任何地方,显示它是如何做。

i have an application where my user changes font and font color for different labels etc and they save it to a file but i need to be able to convert the font of the specified label to a string to be written to file, and then when they open that file my program will convert that string back into a font object. How can this be done? I haven't found anywhere that shows how it can be done.

感谢您

巴尔

推荐答案

这是很容易去从字体到字符串来回回来的System.Drawing.FontConverter类。例如:

It is easy to go back and forth from a font to a string and back with the System.Drawing.FontConverter class. For example:

        var cvt = new FontConverter();
        string s = cvt.ConvertToString(this.Font);
        Font f = cvt.ConvertFromString(s) as Font;

这篇关于字体转换为字符串,然后再返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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