计算逻辑字体大小 [英] Calculating the logical font size

查看:79
本文介绍了计算逻辑字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

许多示例显示了以下根据字体大小来计算字体的逻辑大小的方法,这也是我的代码多年来所做的事情:

Many examples show the following way of calculating a font's logical size from its point size, which is also how my code has been doing it for years:

SizeLogical = -MulDiv(SizePt, GetDeviceCaps(hdc, LOGPIXELSY), 72);

但是我最近注意到诸如

But I recently noticed that examples like this one use a factor of 96 instead of 72. Is this because the monitors' physical resolution has increased over the years, so they display 96 pixels per inch as opposed to typography's classic 72 points per inch? If so, the correct solution would be to determine the factor dynamically, but which Windows API does one call to do that? Or am I misunderstanding it all anyway?

推荐答案

72是每英寸的点数,它永远不会改变. 96是每英寸的像素数,它可以在系统之间变化.

72 is the number of points per inch, this never changes. 96 is the number of pixels per inch, and it can change from system to system.

我相信您使用的公式直接来自Microsoft文档.编辑-这是: http://msdn .microsoft.com/en-us/library/dd183499%28v = vs.85%29.aspx

I believe the formula you're using is straight from the Microsoft documentation. Edit - Here it is: http://msdn.microsoft.com/en-us/library/dd183499%28v=vs.85%29.aspx

您不必担心96,因为这就是GetDeviceCaps返回的内容.

You don't have to worry about the 96 because that's what is being returned by GetDeviceCaps.

这篇关于计算逻辑字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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