INFO: Font Metrics and the Use of Negative lfHeight

 Print
 
Article translations 
This article was previously published under Q32667
Expand all | Collapse all

On This Page

SUMMARY

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)

Properties

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.

INFO: Font Metrics and the Use of Negative lfHeight的更多相关文章

  1. Getting Text Metrics in Firemonkey(delphiscience的博客)

    Firemonkey’s abstract TCanvas class has been providing the dimensions of the bounding rectangle of s ...

  2. [EMSE'17] A Correlation Study between Automated Program Repair and Test-Suite Metrics

    Basic Information Authors: Jooyong Yi, Shin Hwei Tan, Sergey Mechtaev, Marcel Böhme, Abhik Roychoudh ...

  3. Font and PDF

    1. 独立存在的Font文件 有三类: Type 1 Font TrueType Font OpenType Font Type 1 是由Adobe开发的,它是基于PostScript的Font,它通 ...

  4. css 常用单位

    em: 相对于应用在当前元素的字体尺寸,1em 等于当前的字体尺寸,2em 等于当前字体尺寸的两倍,一般浏览器字体大小默认为16px,则2em == 32px: W3原文:font size of t ...

  5. 你可能不知道的7个CSS单位

    如果你是一名前端开发工程师,一般px和em使用频率比较高.但是今天本文的重点是介绍一些我们使用很少.甚至么有听说的单位. 一.重温em <style type="text/css&qu ...

  6. Using Headless Mode in the Java SE Platform--转

    原文地址: By Artem Ananiev and Alla Redko, June 2006     Articles Index This article explains how to use ...

  7. 关于imagic拼接透明背景图片的问题

    目标: 为了做图片水印,需要水平拼接多个logo和文字... 之前用过imagick,所以继续使用. 第一个版本:实现了图片和文字的拼接,代码如下: package main import ( &qu ...

  8. IOS CoreText.framework --- 行 CTLineRef

    http://blog.csdn.net/fengsh998/article/details/8701738 前面两篇文章介绍了文字的样式,段落样式.本文章主要介绍行模式.CTLineRef 知识了解 ...

  9. iOS之富文本

    之前做项目时遇到一个问题: 使用UITextView显示一段电影的简介,由于字数比较多,所以字体设置的很小,行间距和段间距也很小,一大段文字挤在一起看起来很别扭,想要把行间距调大,结果在XCode中查 ...

随机推荐

  1. Java之集合(四)Vector和Stack

    转载请注明源出处:http://www.cnblogs.com/lighten/p/7296023.html 1.前言 本章介绍Java集合List中的Vector和其子类Stack.Vector类是 ...

  2. Vuejs 整合 MUi

    整合方法和使用axios的方法类似.具体步骤如下: 引入mui的css和js import mui from './lib/mui/js/mui.js' import './lib/mui/css/m ...

  3. C# base和this ---转载 小昊

    new关键字引起了大家的不少关注,尤其感谢 Anders Liu的补充,让我感觉博客园赋予的交流平台真的无所不在.所以,我们就有必要继续这个话题,把我认为最值得关注的关键字开展下去,本文的重点是访问关 ...

  4. 启动mongodb和redis服务器

    一.mongodb sudo service mongod start sudo service mongod restart sudo service mongod stop 二.redis red ...

  5. 玩转mongodb(五):mongodb 3.0+ 查询性能分析

    mongodb性能分析方法:explain() 为了演示的效果,我们先来创建一个有200万个文档的记录.(我自己的电脑耗了15分钟左右插入完成.如果你想插更多的文档也没问题,只要有耐心等就可以了.) ...

  6. I/O模式总结

    进程读取数据时要经过两个阶段: 1.等待内核准备数据: 2.将内核缓冲区中的数据复制到进程缓冲区中. 一.阻塞IO 进程会阻塞在等待内核准备数据和数据从内核空间复制到用户空间这两个阶段. 二.非阻塞I ...

  7. linux下mysql安装报错及修改密码登录等等

    1:下载 [root@localhost soft]# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.19-linux-glibc ...

  8. 求最短路径的三种算法: Ford, Dijkstra和Floyd

    Bellman-Ford算法 Bellman-Ford是一种容易理解的单源最短路径算法, Bellman-Ford算法需要两个数组进行辅助: dis[i]: 存储顶点i到源点已知最短路径 path[i ...

  9. 解决Tomcat出现内存溢出的问题

    Tomcat服务器出现java.lang.OutOfMemoryError:Java heap space异常 1.可能是程序错误,比如:程序陷入死循环 2.堆内存太小 一般情况下,java创建的对象 ...

  10. 设置navigationbar透明度时的坑

    1.需要设置导航条透明度时     UIImage *image = [UIImage imageNamed:@"bg_clear.png"]; //设置背景颜色 [nav2.na ...