CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

字体问题

楼主ffuu()2002-03-28 09:33:26 在 VC/MFC / 基础类 提问

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句是什么意思? 问题点数:100、回复次数:4Top

1 楼AloneWolf(孤狼)回复于 2002-03-28 09:43:53 得分 50

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.    
   
  Top

2 楼rocmeteor(拄杖携残醉,扶风上九霄)回复于 2002-03-28 09:54:53 得分 50

是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?  
  Top

3 楼ffuu()回复于 2002-03-28 10:32:05 得分 0

牛!  
      这都看得出来,能把QQ号告诉我吗?以后我可以请教。---不是很过分吧?Top

4 楼rocmeteor(拄杖携残醉,扶风上九霄)回复于 2002-03-28 11:22:42 得分 0

是在说我吗?不是吧?是在说别人吧?:)  
  我没有QQ:(Top

相关问题

  • 字体呀字体?
  • 字体没了??
  • 字体问题
  • 字体颜色??????
  • 安装字体
  • 字体问题
  • 一种字体
  • 矢量字体???
  • ??矢量字体?????
  • 字体问题!

关键词

  • 字体
  • vector
  • tmpf
  • cxchar
  • tmpitchandfamily
  • cxcaps
  • 宽度
  • pitch
  • bits
  • font

得分解答快速导航

  • 帖主:ffuu
  • AloneWolf
  • rocmeteor

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo