Windows里FONT相关的一些术语

估计很多人用过CreateFont系列的函数吧,那里面关于字体高度的指定可以为正,也可以为负,但是他们的区别是什么呢,反正我对于这块儿一直是稀里糊涂,今天刚好遇到了这样的问题,就顺便往下面挖了一下:

MSDN上是这么说的,

 

lfHeight

Specifies the height, in logical units, of the font’s character cell or character. The character height value (also known as the em height) is the character cell height value minus the internal-leading value. The font mapper interprets the value specified in lfHeight in the following manner.

Value
Description

> 0
The font mapper transforms this value into device units and matches it against the cell height of the available fonts.

0
The font mapper uses a default height value when it searches for a match.

< 0
The font mapper transforms this value into device units and matches its absolute value against the character height of the available fonts.

那么,到底什么是cell height,什么又是character height呢?msdn搜了一下,找到了如下解释:

 

   ----------  <------------------------------
   |        |           |- Internal Leading  |
   | |   |  |  <---------                    |
   | |   |  |        |                       |- Cell Height
   | |---|  |        |- Character Height     |
   | |   |  |        |                       |
   | |   |  |        |                       |
   ----------  <------------------------------
 

所以,CreateFont高度分别为16和-16,那么前者是cell height,后者是character height,所以创建出来的字体后者一般要比前者大一些

那么GetTextMetrics返回值里面的tmHeight指的又是什么呢?MSDN说了:

tmHeight
Specifies the height (ascent + descent) of characters.

这个ascent和descent又都指的哪一部分呢?

再搜,呵呵,发现下面的更详细的解释

 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

                     O    O
 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

                       /\ 
                      /  \ 
                     /    \ 
 _ _ _ _ _ _ _ _ _  /______\ _ _ _ ___   _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
                   /        \     /   \|
                  /          \   |     |
 _ _ _ _ _ _ _ _ /_ _ _ _ _ _ \ _ \___/| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
                                       |
                                       |
 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\___/_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
                                                      |
                                                      |- External Leading
 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _
                                                      |
                     O    O                           |- Internal Leading
 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _
              |        /\ 
              |       /  \ 
              |      /    \ 
              |     /______\ _ _ _ ___   _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
 Char Height -|    /        \     /   \|
              |   /          \   |     |
              |  /_ _ _ _ _ _ \ _ \___/| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
              |                        |
              |                        |
 _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _\___/_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

              |                                           |
              |      O    O                               |
              |                                           |
              |        /\                                 |
              |       /  \                                |
              |      /    \                               |- Ascent
 Cell Height -|     /______\       ___                    |
              |    /        \     /   \|                  |
              |   /          \   |     |                  |
              |  /_ _ _ _ _ _ \ _ \___/| _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _
              |                        |                  |
              |                        |                  |- Descent
 _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _\___/_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _
 

翻啊翻啊翻,居然找到了下面一大堆的术语,嘿嘿,这次搜的结果不错:

cell height

character height

external leading

internal leading

ascent

descent

character width

overhang

内容太多了,一不小心就会忘掉,所以贴在这里当作笔记,呵呵

 
				
Advertisements
This entry was posted in Win32 Programming. Bookmark the permalink.

2 Responses to Windows里FONT相关的一些术语

  1. Zhicheng says:

    如果我没有记错的话,Kruglinski那本VC内幕好像有写到这些,每次看的时候都跳过。

  2. Xuan says:

    我以前也在哪儿见过,不过看着font就烦,所以一般都是直接略过,现在没有办法了,就搞这个,所以就硬着头皮看了

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s