字体光栅化

维基百科,自由的百科全书
跳转至: 导航搜索

字体光栅化是将文字从一个向量表示(比如一个TrueType字体)转化到光栅或者位图表示的过程。在这个过程中往往涉及到一些抗锯齿技术来使得屏幕上的字体更加平滑易读。这也经常会涉及到“字体微调英语font hinting”技术。

字体光栅化的类型[编辑]

File:Textsamples.PNG
抗锯齿, 灰阶抗锯齿和ClearType抗锯齿
没有抗锯齿的光栅化图像
没有微调的抗锯齿光栅化图像
File:Rasterization-antialiasing.png
带有微调的抗锯齿光栅化图像。像素被强行放入临近的整数像素格子里。
针对RGB平板显示器的带有微调和亚像素渲染的光栅化图像

在一个现代操作系统中,光栅化一般是通过一个共享库来提供的。这个库可以内建在操作系统或者桌面环境中,或者在以后被加入。原则上说,每个应用程序可以使用不同的库来进行字体光栅化,但是实际上操作系统一般更倾向于统一这个库。

在比较旧的系统和嵌入式系统中,字体是通过预先设置的特定大小的点阵图形来表示的。但是在大多数现代操作系统中,字体是通过数学的方式来表示的,从而允许任意大小的缩放。

光栅化的最简单的形式是简单线条绘制,而没有任何形式的抗锯齿。这是最快的方法(即它显示在屏幕上需要的计算最少)。这种方法的缺点是字形在小尺寸上会变得不清晰。因此,许多字体数据文件包含提示,帮助系统的光栅器决定在哪里对字形特别麻烦的地方渲染像素,或包含特定的像素大小手工调整过的位图。

一个更复杂的方法是使用计算机图形学中的抗锯齿技术。对于字符边缘处的每个像素,字符占据了该像素的比例可以确定,并将该像素绘制为对应的不透明度。例如,在白色背景上绘制一个黑色字母时,如果一个像素理想状态下应被填满一半(比如用对角线分割),它会被填充50%的灰色。这种方式的简单应用可以产生模糊的字形。例如,如果一个字符中有一条1像素宽的垂直线,但这条线正好落在两个像素之间,它在屏幕上会显示为一个2像素宽的灰线。这种方式以清晰度换取准确性。但是,如今的系统通常将线条的像素坐标强制为整数,这使字形看起来更锐利,但也使得打印出的线条比应有的宽度略宽或略窄。


子像素渲染的细节,呈现出组成白色字体的单个颜色的像素位置

Most computer displays have pixels made up of multiple subpixels (typically one each for red, green, and blue, which are combined to produce the full range of colours). In some cases, particularly with flat panel displays, it is possible to exploit this by rendering at the subpixel resolution rather than using whole pixels, which can increase the effective resolution of the screen. This is generally known as subpixel rendering. One proprietary implementation of subpixel rendering is Microsoft's ClearType.

目前使用的光栅化系统[编辑]

Microsoft WindowsWindows XP开始支持像素渲染。Windows的光栅器is an example of one that prioritizes clarity; by forcing text into integral coordinate positions (and not even antialiasing certain fonts at certain sizes), it becomes easier to read on the screen, but may appear somewhat different when printed.

Mac OS X's Quartz is distinguished by the use of floating-point positioning [來源請求]; it does not force glyphs into exact pixel locations, instead using various antialiasing techniques, including subpixel rendering, to position characters and lines to appear closer to the typographer's intent. The result is that the on-screen display looks extremely similar to printed output, but can occasionally be difficult to read at smaller point sizes. Contrary to other rasterizers, Quartz ignores any Postscript or TrueType hints in the font and solely relies on its own algorithm. A simpler type of font antialiasing was introduced in Mac OS 8.5, in 1998. Apple's technique can be seen on Windows in older versions of Safari for Windows. In more recent versions, however, Apple has switched to using system settings by default.[1]

RISC OS includes font anti-aliasing, first introduced before January 1989.[2] It uses its own font rendering system, which favours accurate shapes over readability, with features such as scaffolding and hinting, sub-pixel positioning and background blending.[3]

PDF通常使用Adobe CoolType渲染。

大部分其他系统使用FreeType库,which falls somewhere between Microsoft's and Apple's implementations; it supports hinting and anti-aliasing, and optionally performs subpixel rendering. The Free fonts included with most Linux distributions look better with FreeType's "auto-hinting" mode, which is high-quality and not encumbered by patents.

D-Type Font Engine is an independent, proprietary and portable font rasterization library.[4] It provides anti-aliasing, subpixel precision, automatic hinting, bitmap filtering and other techniques that can improve the appearance and legibility of text on screen. According to the authors, the display quality of D-Type Font Engine can be configured to match or exceed the quality of Windows and Mac OS X font rasterizers while using only non-hinted TrueType, OpenType or Type 1 fonts.[5]

参考文献[编辑]

  1. ^ A Treatise on Font Rasterisation With an Emphasis on Free Software. freddie.witherden.org. 2009-12-29 [2010-09-12]. 
  2. ^ Pountain, Dick. Screentest: Archie RISC OS. Personal Computer World. December 1988: (154) [2011-01-14]. "[ArcDraw] can also add text in multiple sizes and fonts to a drawing (including anti-aliased fonts)" 
  3. ^ Mike's Homepage - Words - Thoughts - RISC OS. Mikejs.com. 2006-12-07 [2009-11-10]. 
  4. ^ D-Type - Font Engine and Rasterizer. d-type.com. 2003-12-24 [2009-11-30]. 
  5. ^ D-Type - Font Engine and Rasterizer - Examples. d-type.com. 2003-12-24 [2009-11-30].