Font Size

本文解析了在不同分辨率下如何将字体大小从点转换为像素,并解释了字体高度与字体大小的区别。通过实例展示了如何计算不同尺寸和分辨率下的字体参数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Font Size

As explained in Screen Dots Per Inch one gets the font size in pixels by multiplying the font size in inches by the screen dpi. This calculated font size, the font name, and a whole raft of other parameters, are passed to the Windows Application Programming Interface (API ) which then instantiates the font so that the font driver can actually create it. Windows functions that create screen fonts require the requested font size to be in pixels, not points , so every application that allows you to choose a screen font size in points has to convert that point size to pixels, using the screen dpi value, before requesting the API to create the font. A program can, however, bypass this calculation by allowing screen font size to be directly specified in pixels and screen dpi is then ignored because a points to pixels conversion is not required. Firefox is one program that allows font sizes to be specified in pixels, and uses 16px as the default value.

Illustrating font size parameters Let’s have a look at some basic Windows font terms.

  • Font height = Ascent + Descent.
  • Font size = Font Height - Internal Leading.

Internal leading, pronounced ‘ledding’, is the space for diacritics (accent marks).

Arial 12pt at 96 dpi:

                      font size in points             12
font size in pixels = ------------------- × 96 dpi = ---- × 96 = 16 pixels
72 points per inch 72

The font name and requested font size (in pixels) is passed to the API . After the font is created its actual parameters can be obtained from, you guessed it, the API and this says that for Arial with a font size of 16 pixels:

ascent = 15 pixels,  descent = 3 pixels,  internal leading = 2 pixels
font height = ascent + descent = 15 + 3 = 18 pixels
font size = font height - internal leading = 18 - 2 = 16 pixels

Arial 48pt at 110 dpi:

                       48
font size in pixels = ---- × 110 = 73 pixels
72

ascent = 66 pixels,  descent = 16 pixels,  internal leading = 9 pixels
font height = 66 + 16 = 82 pixels
font size = 82 - 9 = 73 pixels

  • Font size is made up of three components i.e. ascent, descent, and internal leading and these components can vary widely for different fonts having the same font size

Let’s compare two quite different fonts having exactly the same font size i.e. Scriptina 48pt at 96 dpi and Arial 48pt at 96dpi.

                       48
font size in pixels = ---- × 96 = 64 pixels
72

illustrating that fonts having the same font size can have widely different heights Font size and font height are not the same thing . The font size of these fonts are identical at 64 pixels but the height of the 48 point Scriptina is 188 pixels, while that of the 48 point Arial is 72 pixels.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值