Converting between WPF font size and “standard” font size

后端 未结 2 510
太阳男子
太阳男子 2021-02-05 04:12

I\'ve noticed in WPF, the default font size of 12 points is roughly equivalent to 9 points in \"normal\" applications (e.g. WordPad), 10 pt in WPF is roughly 7 pt standard, and

2条回答
  •  离开以前
    2021-02-05 04:29

    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.

提交回复
热议问题