BigAdmin System Administration Portal
如何使用Truetype字体中的内嵌点阵字体
Print-friendly VersionPrint-friendly Version

如何使用Truetype字体中的内嵌点阵字体

William Wei Xue, April 2008

在某些Truetype字体中会嵌入某些比较小的尺寸的点阵字体。那么为什么要在Truetype字体中嵌入点阵字体呢?这是因为这样可以提高小号字符的可视效果,可以让它看提来更清晰。如果你有一个含有内嵌点阵字体的 Truetype字体,那么你就可以按照自己的需要定制是否在指定的尺寸(字号)使用内嵌的点阵字体,或者只是按照正常的Truetype数据渲染字体的外形。当然,前提是必须在你的 Truetype字体文件中必须提供这些小尺寸的内嵌点阵字体。本文给出一个如何通过修改配置文件激活Uming Truetype 字体(uming.ttf)的实例。

Uming字体(uming.ttf)提供了 11, 12, 13, 14, 15 和 16像素尺寸的内嵌点阵字体。为了是大家明显的看出使用点阵字和没有使用的不同,使用Solrais提供的工具 /usr/openwin/bin/xmag 放大测试用的字符,并且截取图片。图1是可缩放字体,也据是Truetype字体在10pt的放大截图。10pt这个尺寸应该有相应的内嵌点阵字体的支持,(关于像素尺寸和绝对尺寸(pt磅)之间的转换请读者自行查阅)但是现在内嵌点阵字体被禁用,这里看到的是真正Truetype字体:

Fig. 1

Figure 1: Scalable TrueType Font Without Embedded Bitmap Fonts
(Click to Enlarge)

为了激活优先使用内嵌点阵字体,向如下那样修改配置文件 /etc/fonts/fonts.conf :

<match target="font">
  <test name="prefer_bitmap">
    <bool>true</bool>
  </test>
  <test name="family">
    <string>AR PL ShanHeiSun Uni</string>
  </test>
  <test name="pixelsize" compare="more_eq">
    <double>11</double>
  </test>
  <test name="pixelsize" compare="less">
    <double>16</double>
  </test>
  <edit name="antialias" mode="assign">
  <bool>false</bool>
  </edit>
</match>

在段“ ”中,将值设置为“true”。最后三段是为了禁用从11像素到16像素的aa处理(anti-aliasing反锯齿处理,是一种最小化字体的锯齿,使其边缘更加平滑的技术,可参见附录的参考资料)。重新启动程序,你将看到现实的10磅字体已经变成点阵字体了,确实清晰了很多。如图-2所示:

Fig. 2

Figure 2: Scalable TrueType Font With Embedded Bitmap Fonts
(Click to Enlarge)

参考资料:


Comments (latest comments first)

Discuss and comment on this resource in the BigAdmin Wiki

Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License.


BigAdmin
  
 
BigAdmin Upgrade Hub