Inconsolata 及字体相关

Versions

  • 个人改造

个人一直以来用的 Inconsolata 版本是一个好多年前的祖传版本,中间经过许多人个性定制,单双引号也早就变成了竖直的,后续又手动补充了 Powerline 系列字符,base 的版本已经不可考

  • 官方版本

https://fonts.google.com/specimen/Inconsolata

https://github.com/googlefonts/inconsolata

目前已经更新到 3.000,已经内置了更多的字符,包括 Braille Patterns(盲文), Geometric Shapes, Box Drawing, Block Elements 等,可以让你的 tui 更加炫酷,如 btop++ 等的进度条和统计图的显示

但似乎迟迟不添加 Powerline,也是迷惑

新版本还添加了对 ligatures 的支持,可以理解为连字,比如 >= 变成占一个字符的真正的大于等于号,=>, === 等也有变形,这个版本的字体叫 Ligconsolata

  • InconsolataDz & Inconsolata-g

https://leonardo-m.livejournal.com/77079.html

早期的对官方 Inconsolata 的著名修改版,因为官方版长期不更新。主要修改包括,把单双引号变直;把点和逗号变得更明显;把加斜杠的 0 变成加点的 0;把 ^ 变得更宽等

但也很久没有更新了,没有现在这些乱七八糟字体的支持,也没有 Powerline

  • Inconsolata for Powerline

Powerline 是啥不用多说,官方放出了许多 patched 好的各种字体,其中也包括 Inconsolata, Inconsolata-g, InconsolataDz, 都命名为Inconsolata xxx for Powerline

优点自然是支持 Powerline 字符了,左右小三角啦,branch 图标啦

缺点就是官方 patched 基于的 Inconsolata 字体也是比较老的,不会随 googlefonts 的更新,自然也没有后续字符的加入

  • 个人再定制

https://github.com/powerline/fontpatcher

Powerline 的项目中也带了一个 fontpatcher,基于 FontForge。但装起来麻烦,个人推荐另一款,可以 docker

Nerd Fonts

https://www.nerdfonts.com/

https://github.com/ryanoasis/nerd-fonts#font-patcher

提供docker pull nerdfonts/patcher免去安装 FontForge 的麻烦

通过docker run --rm -v ~/myfont/patchme:/in -v ~/myfont/patched:/out nerdfonts/patcher执行

常用参数有

1
2
3
4
5
     --mono: 代码用字体,mono 少不了
-c: 我全都要.jpg
--careful: Do not overwrite existing glyphs if detected
-w: 增强 Windows 兼容性,Limit the internal font name to 31 characters (for Windows compatibility)
--powerline: --啥就添啥

是目前用得最爽的一款 fontpatcher,让 Inconsolata 焕发新生!

一个程序员 = 一把键盘: HHKB + 一款字体: Inconsolata + 一套配色: Molokia

1
2
curl 'wttr.in?format=3'
Beijing, China: ☀️ +5°C

OS 差异

  • macOS

macOS 上使用 iTerm2,字体安装的话很方便,可以brew install font-inconsolata,其中的 inconsolata 是随 googlefonts 比较新的,inconsolata-for-powerline 等是上面提到的其它 repo 的比较旧的。

iTerm2 的 Powerline 支持可以直接,Preference > Profiles > Text,勾上 Use built-in Powerline glyphs,省去自己打 Inconsolata 补丁的麻烦。

macOS 还是适合程序员啊!

  • Windows

Windows 上就比较麻烦,需要先给 Inconsolata 打补丁以支持 Powerline 字符。nerdfonts 打出来的字体没有被标记为 fixed-width,所以默认不会被 SecureCRT 承认,需要修改 Global.ini,位置详见 SecureCRT 的 Global Options > Configuration Paths,修改 Allow Proportional Fonts 那行的值为 00000001,重新打开 SecureCRT 即可