• 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 os.path模块常用方法详解
    PHP脚本执行效率性能检测之WebGrind的使用
    Laravel操作上传文件的方法
    Nginx获取自定义头部header的值
    Laravel Nginx 除 `/` 外所有路由 404
    laravel查看执行的sql语句
    laravel 安装excel扩展
    mysql 按值排序
    处理laravel表单提交默认将空值转为null的问题
    设置虚拟机里的Centos7的IP
  • 原文地址:https://www.cnblogs.com/xingyayang/p/3488649.html
Copyright © 2020-2023  润新知