从C 中的大小计算字体高度
Calculate the font height from its size in C++?
我试图在示例上验证CFont
高度和大小之间的依赖性:
int main(int argc, char* argv[])
{
int myVariableFontHeight = 90;
CFont * font = new CFont();
LOGFONT lf;
memset(&lf,0,sizeof(LOGFONT));
lf.lfHeight = myVariableFontHeight;
lf.lfWeight =FW_BOLD;
lf.lfCharSet = 1;
_tcscpy_s(lf.lfFaceName , "Arial Unicode MS");
font->CreatePointFontIndirect(&lf);
font->GetLogFont(&lf);
int fontHeight = lf.lfHeight;
HWND console = GetConsoleWindow();
HDC dc = GetDC(console);
int nFontSize = -::MulDiv( lf.lfHeight, 72, ::GetDeviceCaps( dc, LOGPIXELSY ) );
delete font;
return 0;
}
,结果始终是nFontSize = myVariableFontHeight/10
。这是什么因素10?从哪里来?我可以从给定尺寸计算字体高度吗?
谢谢
它在MFC Souce代码中。它在文档中。CFONT :: CreatePointFontirect状态的在线文档的第一行:
此功能与CreateFontinirect相同 LogFont的LFHEIGHT成员在十分之一的解释 而不是设备单位。
所以,如果要创建10 pt字体,则将lf.lfheight设置为100。
相关文章:
- 为什么"do while"循环不断退出,即使条件计算结果为 false?
- 递归函数计算序列中的平方和(并输出过程)
- (C++)分析树以计算返回错误值的简单算术表达式
- 在C++中测量postscript字体宽度
- 我的字符计数代码计算错误.为什么
- 在计算中使用二的幂有多有利可图
- 如何计算文件中的"columns"数?
- 计算排序向量的向量中唯一值的计数
- 如何使用 std::累积在 C++ 中计算总和立方体
- 使用Qt C++计算类似Git的SHA1哈希
- OpenCV C++.快速计算混淆矩阵
- cpp二进制搜索问题,计算给定数组中输入元素的出现次数
- C++如何计算用户输入的数字中的偶数位数
- 如何计算数据类型的范围,例如int
- 类似枚举的计算常量
- 计算每个节点的树高,帮助我解释这个代码解决方案
- 多个If语句与使用逻辑运算符计算条件的单个语句的比较
- 计算缩放多边形的比例,得到给定的多边形面积
- 在C++中如何在没有pow的情况下进行基础计算
- 从C 中的大小计算字体高度