「Fontconfig」- fonts.conf(学习笔记) @20210411

本文深入解析Fontconfig配置机制,涵盖配置文件结构、字体属性、匹配流程等关键内容,帮助开发者理解如何有效配置字体。

参考 Font configuration - ArchWiki 页面。

fonts.conf,字体配置文件。

配置文件路径及加载顺序(SYNOPSIS)

/etc/fonts/fonts.conf
/etc/fonts/fonts.dtd
/etc/fonts/conf.d

$XDG_CONFIG_HOME/fontconfig/conf.d
$XDG_CONFIG_HOME/fontconfig/fonts.conf

~/.fonts.conf.d
~/.fonts.conf

配置文件描述(DESCRIPTION)

Fontconfig是一个库,旨在提供系统范围的字体配置、定制、应用程序访问。

功能概览(FUNCTIONAL OVERVIEW)

Fontconfig contains two essential modules, the configuration module which builds an internal configuration
from XML files and the matching module which accepts font patterns and returns the nearest matching font.

FONT CONFIGURATION

The configuration module consists of the FcConfig datatype, libexpat and FcConfigParse which walks over an
XML tree and amends a configuration with data found within. From an external perspective, configuration of
the library consists of generating a valid XML tree and feeding that to FcConfigParse. The only other mecha‐
nism provided to applications for changing the running configuration is to add fonts and directories to the
list of application-provided font files.

The intent is to make font configurations relatively static, and shared by as many applications as possible.
It is hoped that this will lead to more stable font selection when passing names from one application to
another. XML was chosen as a configuration file format because it provides a format which is easy for exter‐
nal agents to edit while retaining the correct structure and syntax.

Font configuration is separate from font matching; applications needing to do their own matching can access
the available fonts from the library and perform private matching. The intent is to permit applications to
pick and choose appropriate functionality from the library instead of forcing them to choose between this
library and a private configuration mechanism. The hope is that this will ensure that configuration of fonts
for all applications can be centralized in one place. Centralizing font configuration will simplify and regu‐
larize font installation and customization.

字体的属性(FONT PROPERTIES)

While font patterns may contain essentially any properties, there are some well known properties with associ‐
ated types. Fontconfig uses some of these properties for font matching and font completion. Others are pro‐
vided as a convenience for the applications' rendering mechanism.

 Property        Type    Description
 --------------------------------------------------------------
 family          String  Font family names
 familylang      String  Languages corresponding to each family
 style           String  Font style. Overrides weight and slant
 stylelang       String  Languages corresponding to each style
 fullname        String  Font full names (often includes style)
 fullnamelang    String  Languages corresponding to each fullname
 slant           Int     Italic, oblique or roman
 weight          Int     Light, medium, demibold, bold or black
 size            Double  Point size
 width           Int     Condensed, normal or expanded
 aspect          Double  Stretches glyphs horizontally before hinting
 pixelsize       Double  Pixel size
 spacing         Int     Proportional, dual-width, monospace or charcell
 foundry         String  Font foundry name
 antialias       Bool    Whether glyphs can be antialiased
 hinting         Bool    Whether the rasterizer should use hinting
 hintstyle       Int     Automatic hinting style
 verticallayout  Bool    Use vertical layout
 autohint        Bool    Use autohinter instead of normal hinter
 globaladvance   Bool    Use font global advance data (deprecated)
 file            String  The filename holding the font
 index           Int     The index of the font within the file
 ftface          FT_Face Use the specified FreeType face object
 rasterizer      String  Which rasterizer is in use (deprecated)
 outline         Bool    Whether the glyphs are outlines
 scalable        Bool    Whether glyphs can be scaled
 color           Bool    Whether any glyphs have color
 scale           Double  Scale factor for point->pixel conversions (deprecated)
 dpi             Double  Target dots per inch
 rgba            Int     unknown, rgb, bgr, vrgb, vbgr, none - subpixel geometry
 lcdfilter       Int     Type of LCD filter
 minspace        Bool    Eliminate leading from line spacing
 charset         CharSet Unicode chars encoded by the font
 lang            String  List of RFC-3066-style languages this font supports
 fontversion     Int     Version number of the font
 capability      String  List of layout capabilities in the font
 fontformat      String  String name of the font format
 embolden        Bool    Rasterizer should synthetically embolden the font
 embeddedbitmap  Bool    Use the embedded bitmap instead of the outline
 decorative      Bool    Whether the style is a decorative variant
 fontfeatures    String  List of the feature tags in OpenType to be enabled
 namelang        String  Language name to be used for the default value of familylang, stylelang, and fullnamelang
 prgname         String  String  Name of the running program
 postscriptname  String  Font family name in PostScript

字体匹配(FONT MATCHING)

Fontc

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值