转换以英寸为单位的字体大小 [英] Convert the Font size in inch

查看:123
本文介绍了转换以英寸为单位的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Drawing.Font.Size(浮点数,?)和WPF FontSize(双倍,WPF像素)之间进行转换.

I need to convert between Drawing.Font.Size (float, ?) and WPF FontSize (double, WPF pixels).

最后,我决定将字体大小以英寸为单位存储在数据库中.

Finally, I decided to store in the database the fontSize in inch...

如何将GDI字体大小转换为英寸,将WPF字体大小转换为英寸?

How can I convert the GDI FontSize to inch and the WPF FontSize to inch?

sizeInInch = wpfFontSize / 96
sizeInInch = gdiFontSize / ?

我可以使用独立于DPI的东西吗?也许System.Windows.FontSizeConverter?

Can I use something DPI independent? Maybe System.Windows.FontSizeConverter?

我需要转换为某种东西,这将使我能够在WPF和GDI之间切换多个时间,而无需更改实际值".

I need to convert to something, that will allow me to switch multiple time between WPF and GDI without changing the "real value".

每次除法和随后的乘法运算都会累积错误...

Each division and following multiplication will accumulate errors...

FontSizeConverter执行ConvertTo,但是我不知道如何使用它: 说

FontSizeConverter does a ConvertTo, but I don't understand to use it: say

myUniversalFontSize = (double)(myFontSizeConverter.ConvertFrom(
    gdiFont.SizeInPoints.ToString() + "pt"))

会在...中转换我的gdiFont大小吗? WPF像素?

will transform my gdiFont size in ...? WPF Pixels?

现在我应该如何将该值转换回GDI?

How now should I convert back that value to GDI?

gdiFont.SizeInPoints = myUniversalFontSize / 96 * 72???

我也可以在第二个示例中使用myFontSizeConverter吗?

Can I use in the second example the myFontSizeConverter too?

推荐答案

请参阅文档

使用LengthConverter进行转换. http://msdn.microsoft.com/en-us/library /system.windows.lengthconverter.aspx

Use a LengthConverter for conversion. http://msdn.microsoft.com/en-us/library/system.windows.lengthconverter.aspx

这篇关于转换以英寸为单位的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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