字体问题

ffuu 2002-03-28 09:33:26
1 GetTextMetrics(hdc,&tm);
2 cxChar=tm.tmAveCharWidth;
3 cxCaps=(tm.tmPitchAndFamily & 1 ? 3:2)*cxChar/2;
4 cyChar=tm.tmHeight+tm.tmExternalLeading;
5 iMaxWidth=40*cxChar+22*cxCaps;

第3和5句是什么意思?
...全文
61 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
心念不空过 2002-03-28
  • 打赏
  • 举报
回复
是在说我吗?不是吧?是在说别人吧?:)
我没有QQ:(
ffuu 2002-03-28
  • 打赏
  • 举报
回复
牛!
这都看得出来,能把QQ号告诉我吗?以后我可以请教。---不是很过分吧?
心念不空过 2002-03-28
  • 打赏
  • 举报
回复
是Programming Windows上的代码吧?

#define TMPF_FIXED_PITCH 0x01
#define TMPF_VECTOR 0x02
#define TMPF_DEVICE 0x08
#define TMPF_TRUETYPE 0x04

tmPitchAndFamily & 1是说如果字体宽度可变,则采用1.5倍于平均字符宽度,也就是的该字体的最大宽度了,如果字体宽度固定,则用平均字符宽度就可以了(实际上也是该字体的最大宽度了,)最大宽度与平均宽度的关系,参见原书。

iMaxWidth=40*cxChar+22*cxCaps;
是为了定义横行滚动条出现的条件,因为下面的WM_PAINT中就是这么TextOut的。

OK?
AloneWolf 2002-03-28
  • 打赏
  • 举报
回复
3.
if(tm.tmPitchAndFamily & 1 !=0)
{
cxCaps=3*cxChar/2;
}
else cxCaps=2*cxChar/2;
tmPitchAndFamily
Specifies information about the pitch, the technology, and the family of a physical font.
The four low-order bits of this member specify information about the pitch and the technology of the font. A constant is defined for each of the four bits: Constant Meaning
TMPF_FIXED_PITCH If this bit is set the font is a variable pitch font. If this bit is clear the font is a fixed pitch font. Note very carefully that those meanings are the opposite of what the constant name implies.
TMPF_VECTOR If this bit is set the font is a vector font.
TMPF_TRUETYPE If this bit is set the font is a TrueType font.
TMPF_DEVICE If this bit is set the font is a device font.



An application should carefully test for qualities encoded in these low-order bits, making no arbitrary assumptions. For example, besides having their own bits set, TrueType and PostScript fonts set the TMPF_VECTOR bit. A monospace bitmap font has all of these low-order bits clear; a proportional bitmap font sets the TMPF_FIXED_PITCH bit. A Postscript printer device font sets the TMPF_DEVICE, TMPF_VECTOR, and TMPF_FIXED_PITCH bits.

The four high-order bits of tmPitchAndFamily designate the font's font family. An application can use the value 0xF0 and the bitwise AND operator to mask out the four low-order bits of tmPitchAndFamily, thus obtaining a value that can be directly compared with font family names to find an identical match. For information about font families, see the description of the LOGFONT structure.

16,550

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧