Converting between WPF font size and “standard” font size

帅比萌擦擦* 提交于 2019-12-03 01:14:30
Joseph Sturtevant

WPF uses pixels as its default unit for font size. The mapping between points (probably what you mean when you say "standard" font size) and pixels is: 1 pt = (96/72) px

This gives us a simple conversion function:

public static double PointsToPixels(double points)
{
    return points*(96.0/72.0);
}

See this question for more details.

Another method for conversion if you're going from point to WPF double is to use the System.Windows.FontSizeConverter class:

double sizeForWpf = (double) new FontSizeConverter().ConvertFrom("10pt");
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!