API CreateFont 中使用的默认字体高度是多少?它如何选择字体?
What is the default font height used in the API CreateFont ? How does it choose a font face?
我修补了一些代码以使其能够识别 DPI
font = CreateFont (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FIXED_PITCH | FF_DONTCARE, TEXT ("FixedSys"));
成为
font = CreateFont ([some scaled value], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FIXED_PITCH | FF_DONTCARE, TEXT ("FixedSys"));
我不明白 height = 0(第一个参数)时的行为
根据女士
0
The font mapper uses a default height value when it searches for a match.
默认高度值是多少?
我有一位韩国客户抱怨说,在 100% 缩放比例下,应用程序中的文本在旧代码(高度 = 0)和新代码(高度 = 14)之间明显缩小。在英国 OS 上,文本显示相同。
映射器使用了不同的字体。
看起来像你need this code。字体高度由这个公式计算 nHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
PointSize
- 是字体大小,GetDeviceCaps(hDC, LOGPIXELSY)
是通过 GDI(旧东西)获取 DPI 的调用。
在我的 DPI 意识大战中,我使用了这段代码:
fontStruct.lfHeight = 0 - MulDiv( height, GetWindowDpi( window ), 72 );
GetWindowDpi
是一个包装器,它为 windows 10 调用 GetDpiForWindow
或为 Windows 8.1 调用 GetDpiForMonitor
或使用相同的旧东西 GetDeviceCaps(hDC, LOGPIXELSY)
对于 Windows 7.
我修补了一些代码以使其能够识别 DPI
font = CreateFont (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FIXED_PITCH | FF_DONTCARE, TEXT ("FixedSys"));
成为
font = CreateFont ([some scaled value], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FIXED_PITCH | FF_DONTCARE, TEXT ("FixedSys"));
我不明白 height = 0(第一个参数)时的行为
根据女士
0 The font mapper uses a default height value when it searches for a match.
默认高度值是多少? 我有一位韩国客户抱怨说,在 100% 缩放比例下,应用程序中的文本在旧代码(高度 = 0)和新代码(高度 = 14)之间明显缩小。在英国 OS 上,文本显示相同。
映射器使用了不同的字体。
看起来像你need this code。字体高度由这个公式计算 nHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
PointSize
- 是字体大小,GetDeviceCaps(hDC, LOGPIXELSY)
是通过 GDI(旧东西)获取 DPI 的调用。
在我的 DPI 意识大战中,我使用了这段代码:
fontStruct.lfHeight = 0 - MulDiv( height, GetWindowDpi( window ), 72 );
GetWindowDpi
是一个包装器,它为 windows 10 调用 GetDpiForWindow
或为 Windows 8.1 调用 GetDpiForMonitor
或使用相同的旧东西 GetDeviceCaps(hDC, LOGPIXELSY)
对于 Windows 7.