zoukankan      html  css  js  c++  java
  • INFO: Font Metrics and the Use of Negative lfHeight

    INFO: Font Metrics and the Use of Negative lfHeight

     
    Article translations Article translations
    Article ID: 32667 - View products that this article applies to.
    This article was previously published under Q32667
    Expand all | Collapse all

    Collapse imageOn This Page

    Collapse imageSUMMARY

    The following illustrations show the most commonly used font metrics, including Character Height, which is selected with negative values of each illustration is followed by notes describing the metrics.
     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
                         O    O
     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
                           / 
                          /   
                         /     
     _ _ _ _ _ _ _ _ _  /______ _ _ _ ___   _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
                       /             /   |
                      /             |     |
     _ _ _ _ _ _ _ _ /_ _ _ _ _ _  _ \___/| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
                                           |
                                           |
     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\___/_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
                                                          |
                                                          |- External Leading
     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _
                                                          |
                         O    O                           |- Internal Leading
     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _
                  |        / 
                  |       /   
                  |      /     
                  |     /______ _ _ _ ___   _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
     Char Height -|    /             /   |
                  |   /             |     |
                  |  /_ _ _ _ _ _  _ \___/| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
                  |                        |
                  |                        |
     _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _\___/_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
                  |                                           |
                  |      O    O                               |
                  |                                           |
                  |        /                                 |
                  |       /                                  |
                  |      /                                   |- Ascent
     Cell Height -|     /______       ___                    |
                  |    /             /   |                  |
                  |   /             |     |                  |
                  |  /_ _ _ _ _ _  _ \___/| _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _
                  |                        |                  |
                  |                        |                  |- Descent
     _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _\___/_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _
    				

    Cell Height

    This is the height selected on positive lfHeight in the LOGFONT. It is the height of the font bitmap for raster fonts. It is returned as tmHeight in the TEXTMETRIC structure from GetTextMetrics().

    Character Height (Also Known as Em)

    This is the height selected on negative lfHeight in the LOGFONT. (That is, the mapper will try to match a font whose character height matches the absolute value of the requested height.) 

    NOTE: By definition, the Em is equal to Cell Height minus Internal Leading. The Em defines the point size of a font. In MM_TEXT mapping mode, the Em is related to the point size as follows:
       Em=dpiY*point_size/72;  // where dpiY is dots per inch in Y direction
    				
    The dpiY of a font is equal to tmDigitizedAspectY in the TEXTMETRICS structure.

    Internal Leading

    This is returned as tmInternalLeading in the TEXTMETRIC structure from GetTextMetrics() and often, but not necessarily, describes how much space has been left inside the font bitmap for diacritical marks (accents).

    External Leading

    This is returned as tmExternalLeading in the TEXTMETRIC structure from GetTextMetrics() and describes how much extra space the font designer expects the application to leave between rows of the font. It is not included in the bitmap and is not modified by TextOut()/ExtTextOut(), even in OPAQUE mode. When outputting multiple lines of text, the lines should be separated by (tmHeight + tmExternalLeading).
     Character Width                       Character Width
            |                                     |
     |-------------|                       |-------------|
     |          |                         /          /   |
     |          |                        /          /    |
     |          |                       /          /     |
     |          |                      /          /      |
     |----------|                     /----------/       |
     |          |                    /          /        |
     |          |                   /          /         |
     |          |                  /          /          |
     |          |                 /          /           |
                                                |________|
     |_____________|              |_____________|    |
            |                            |           Overhang
       Character width        Character width
     (including white space)  (including white space)
       Overhang = 0                  Overhang > 0
    				

    Overhang

    tmOverhang specifies the per string extra width that may be added to some synthesized fonts. When synthesizing some attributes such as bold or italic, GDI or a device may have to add width to a string on both a per character and per string basis. For example, GDI synthesizes embolding by expanding the intercharacter spacing and overstriking with an offset and italicizes a font by skewing the string. 

    In either case, there is an overhang past the basic string. For bold strings, it is the distance by which the overstrike is offset. For italic strings, it is the amount the top of the font is skewed past the bottom of the font. tmOverhang allows the application to determine how much of the character width returned by a GetTextExtent() call on a single character is the actual character width and how much is the per string extra width. The actual width is the extent less the overhang. In other words, tmOverhang is the difference between the width of a character when it is output singly versus its width when it is in the interior of a string. 

    For more information, look up the following topics in the Windows Software Development Kit reference: 

    • CreateFont() (in Volume 1 of the version 3.0 reference)
    • TEXTMETRIC (in Volume 2 of the version 3.0 reference)

    Collapse imageProperties

    Article ID: 32667 - Last Review: March 21, 2005 - Revision: 1.1
    APPLIES TO
    • Microsoft Windows Software Development Kit 3.1
    Keywords: 
    kbinfo KB32667
    Retired KB Content Disclaimer
    This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
  • 相关阅读:
    利用Python获取文件类型
    删除目录和文件
    创建目录和空文件
    读取文件内容
    sort方法
    python实例5-表格打印
    ngx.lua中遇到的小问题
    mysql 更改自动增长字段值的重新设定
    全面讲解进程池原理
    测试工程师Docker基础
  • 原文地址:https://www.cnblogs.com/xingyayang/p/3488649.html
Copyright © 2011-2022 走看看