这里做一个网络备份。
前言
文中使用到的软件和字体有:
看到一些古文的文章,于是想找一款优质的字体制作成 PDF 放到 iPad 上,可很多字体一方面字形不够优美,另一方面字体在终端阅读体验不佳,最近刚好发现了方正屏显兰亭宋_GBK
这款字体,放在 iPad 上笔画看起来适中,阅读体验不错,于是想试试能不能竖排,然而悲剧的是,这款字体并不支持竖排,所以我用 Glyphs
这款软件编辑字体,添加了几个竖排的标点符号,先看看效果:
可以看到经过修改,标点符号已经符合标准,未修改之前是什么效果呢:
我们来看看是如何实现的吧,先理解几个概念
字体尺寸(Font Metrics)
上图定义了这款字体的默认字形的尺寸。下图是通用的尺寸图:
名词 | 描述 |
---|---|
baseline | 每一行都有一条基线,字体从左到右沿着基线排列 |
x height | 小写字母的高度,行的基本高度 |
cap height | 大写字母的高度 |
ascender | 基线为基准,行的最高高度 |
descender | 基线以下的高度 |
举个例子,修改后的句号是这样的:
位置靠右,在 的位置上下,放大看看:
字体的 features
这里定义了的一些基本特性,比如标点符号替换,字形全宽度和半宽度替换等,我们看看 AdobeSongStd-Light
的 features
:
我们这里只涉及到竖排的支持,所以只需关注 vert
。我已经整理一个简单的支持中文竖排的替换表(借鉴的是 AdobeSongStd-Light
):
item | unicode | alias | item | unicode | alias |
---|---|---|---|---|---|
uniFF1A | colon.full | uniE790 | colon.vert | ||
uniFF1B | semicolon.full | uniE791 | semicolon.vert | ||
uniFF01 | exclam.full | uniE792 | exclamation.vert | ||
uniFF1F | question.full | uniE793 | question.vert | ||
uniFF0E | period.full | period.full.vert | |||
uni3001 | comma-han | uniE78F | |||
uni3002 | period-han | uniE78E | |||
uni2018 | quoteleft | uniFE41 | |||
uni2019 | quote right | uniFE42 | cornerbracketright | ||
uni201C | quotedblleft | uniFE43 | whitecornerbracketleft | ||
uni201D | quotedblright | uniFE44 | |||
uniFF3B | bracketleft.full | bracketleft.full.vert | |||
uniFF3D | bracketright.full | bracketright.full.vert | |||
uniFF08 | parenleft.full | uniFE35 | parenleft.full.vert | ||
uniFF09 | parenright.full | uniFE36 | parenright.full.vert | ||
uni3008 | anglebracketleft | uniFE3F | anglebracketleft.vert | ||
uni3009 | anglebracketright | uniFE40 | anglebracketright.vert | ||
uni300A | dblanglebracketleft | uniFE3D | dblanglebracketleft.vert | ||
uni300B | dblanglebracketright | uniFE3E | dblanglebracketright.vert | ||
uni300C | cornerbracketleft | uniFE41 | cornerbracketleft.vert | ||
uni300E | whitecornerbracketleft | uniFE43 | |||
uni300D | cornerbracketright | uniFE42 | cornerbracketright.vert | ||
uni300F | whitecornerbracketright | uniFE44 | |||
uni3010 | blacklenticularbracketleft | uniFE3B | |||
uni3011 | blacklenticularbracketright | uniFE3C | |||
uniFF5B | braceleftsmall | uniFE37 | braceleft.full.vert | ||
uniFF5D | braceright.full | uniFE38 | braceright.full.vert |
制作竖排替换表
根据上表,我们依葫芦画瓢,得到如下的 features
:
script hani;
lookupflag RightToLeft;
# comment
# FZ Ping Xian Lan Ting Song GBK
sub uniFF01 by uniE792 ;
sub uniFF1A by uniE790 ;
sub uniFF1B by uniE791 ;
sub colon by uniE790;
sub comma by uniE78D;
sub quoteleft by uniFE41;
sub quoteright by uniFE42;
sub quotedblleft by uniFE43;
sub quotedblright by uniFE44;
sub uni3001 by uniE78F;
sub uni3002 by uniE78E;
sub uni3008 by uniFE3F;
sub uni3009 by uniFE40;
sub uni300A by uniFE3D;
sub uni300B by uniFE3E;
sub uni300C by uniFE41;
sub uni300D by uniFE42;
sub uni300E by uniFE43;
sub uni300F by uniFE44;
sub uni3010 by uniFE3B;
sub uni3011 by uniFE3C;
sub uniFE50 by uniE78D;
sub uniFE51 by uniE78F;
sub uniFE54 by uniE790;
sub uniFE55 by uniE791;
sub uniFF08 by uniFE35;
sub uniFF09 by uniFE36;
sub uniFF0C by uniE78D;
sub uniFF0E by notdef.27;
sub uniFF1F by uniE793;
sub uniFF3B by notdef.28;
sub uniFF3D by notdef.29;
sub uniFF5B by uniFE37;
sub uniFF5D by uniFE38;
sub
是替换的意思。
添加 features
的时候用 compile
进行测试,如果没有通过,就是 unicode 的编码不对或者没有对应的字形。在添加之前,我已经制作了竖排的标点符号:
最后的效果就非常出众了:
Bug
在 instances
有个一个自定义的字段:postscriptFullName
无法支持中文,所以需要改成英文的。
我们在 font
添加一个 localizedFamilyName
字段,这样其他程序就可以正确识别这个字体了: