Nerd Fonts - 为终端和编辑器添加强大图标支持

本文翻译整理自:https://github.com/ryanoasis/nerd-fonts


关于 Nerd Fonts

Nerd Fonts 是一个用大量字形(图标)修补开发人员目标字体的项目。特别是从流行的“标志性字体”中添加大量额外的字形,如字体真棒DeviconsOcticons其他

下面的流程图显示了当前包含的字形集:


在这里插入图片描述

使用@SankeyMATIC创建的图表


重要告示


TL;DR

Nerd Fonts 采用流行的编程字体并添加了一堆字形。 如果您想要的字体尚未修补,也可以使用字体修补程序。 有关更多高级信息,请参阅wiki。如果您正在寻找Vim插件,请参阅VimDevIcons


字体的各种下载选项

如果你…


特点


Glyph Sets

🔍🔍您可以通过NerdFonts.comCheat Sheet 很方便的搜索

请参阅Wiki:字形集和代码点了解更多详细信息


shell中的图标名称

请参阅Wiki:shell中的图标名称


修补字体

所有字体的预览可以在这里找到:https://www.nerdfonts.com/font-downloads

Font NameOriginal Font Name and Repositoryver*RFN
0xProto Nerd Font0xProto1.603NO
3270 Nerd Font32703.0.1NO
Agave Nerd FontAgave37NO
AnonymicePro Nerd FontAnonymous Pro1.002YES
Arimo Nerd FontArimo1.33NO
AurulentSansMono Nerd FontAurulent Sans Mono (Stephen G. Hartke)NO
BigBlueTerminal Nerd FontBigBlueTerminal (VileR)NO
BitstromWera Nerd FontVera Sans Mono (Bitstream Inc)1.1YES
BlexMono Nerd FontIBM Plex Mono2.004YES
CaskaydiaCove Nerd FontCascadia Code2111.01YES
CaskaydiaMono Nerd FontCascadia Mono2111.01YES
CodeNewRoman Nerd FontCode New Roman (Sam Radian)2.0NO
ComicShannsMono Nerd FontComic Shanns Mono1.3.1NO
CommitMono Nerd FontCommit Mono1.143NO
Cousine Nerd FontCousine1.211NO
D2Coding Nerd FontD2Coding1.3.2NO
DaddyTimeMono Nerd FontDaddyTimeMono1.2.3NO
DejaVuSansMono Nerd FontDejaVu2.37NO
DroidSansMono Nerd FontDroid Sans Mono (Ascender Corp)1.00-113NO
EnvyCodeR Nerd FontEnvy Code R0.79YES
FantasqueSansMono Nerd FontFantasque Sans Mono1.8.0NO
FiraCode Nerd FontFira Code6.2NO
FiraMono Nerd FontFira Mono3.206NO
GeistMono Nerd FontGeist Mono1.200NO
GoMono Nerd FontGo-Mono2.010NO
Gohu Nerd FontGohu TTF, Gohu2.0NO
Hack Nerd FontHack3.003NO
Hasklug Nerd FontHasklig1.2YES
HeavyDataMono Nerd FontHeavyData (Vic Fieger)1NO
Hurmit Nerd FontHermit2.0YES
iM-Writing Nerd FontiA-WriterDec 2018YES
Inconsolata Nerd FontInconsolata3.000NO
InconsolataGo Nerd FontInconsolataGo1.013NO
Inconsolata LGC Nerd FontInconsolata LGC1.5.2NO
IntoneMono Nerd FontIntel One Mono1.3.0YES
Iosevka Nerd FontIosevka29.0.4NO
IosevkaTerm Nerd FontIosevka Term29.0.4NO
IosevkaTermSlab Nerd FontIosevka Term Slab29.0.4NO
JetBrainsMono Nerd FontJetBrains Mono2.304NO
Lekton Nerd FontLekton34NO
Literation Nerd FontLiberation2.1.5YES
Lilex Nerd FontLilex2.400NO
MartianMono Nerd FontMartianMono1.0.0NO
Meslo Nerd FontMeslo1.21NO
Monaspice Nerd FontMonaspace1.0.0YES
Monofur Nerd FontMonofur (Tobias B Koehler)1.0NO
Monoid Nerd FontMonoid0.61NO
Mononoki Nerd FontMononoki1.6YES
M+ Nerd FontMPlus Fonts2023/09NO
Noto Nerd FontNotodivNO
OpenDyslexic Nerd FontOpenDyslexic2.001NO
Overpass Nerd FontOverpass3.0.5NO
ProFont Nerd FontProFont2.3, 2.2NO
ProggyClean Nerd FontProggyClean (Tristan Grimmer)2004/04/15NO
RecMono Nerd FontRecursive Mono1.085NO
RobotoMono Nerd FontRoboto Mono3.0NO
SauceCodePro Nerd FontSource Code Pro2.042YES
ShureTechMono Nerd FontShare Tech Mono1.003YES
SpaceMono Nerd FontSpace Mono1.001NO
Terminess Nerd FontTerminus TTF4.49.3YES
Tinos Nerd FontTinos1.23NO
Ubuntu Nerd FontUbuntu Font0.83NO
UbuntuMono Nerd FontUbuntu Font0.80NO
UbuntuSans Nerd FontUbuntu Sans1.004NO
VictorMono Nerd FontVictor Mono1.5.6NO
ZedMono Nerd FontZed Mono1.2.0NO

*RFN=保留字体名称


Variations


字体安装


Option 1: Release Archive Download

如果您想要存档或完整的字体系列变体(粗体、斜体等),最好的选择。

字体可作为包下载在最新版本 一个很好的概述是在 Nerd Fonts 网站上(但错过了更紧凑的xv档案)。

如果您想在可以使用的脚本中下载给定字体的最新版本(将“JetBrainsMono”替换为您的字体):

curl -OL https://github.com/ryanoasis/nerd-fonts/releases/latest/download/JetBrainsMono.tar.xz

Option 2: Homebrew Fonts

如果在macOS上并且想使用Homebrew,最好的选择。

所有字体都可以通过macOS(OS X)上的Homebrew Cask获得

brew install font-hack-nerd-font

Option 3: Unofficial Chocolatey or Scoop Repositories

Windows选项,想要使用Chocolatey或Scoop。

Chocolatey用户可以下载发布到Chocolatey社区存储库(CCR)的字体:

choco install nerd-fonts-hack

Scoop用户可以使用Nerd字体的Scoop存储桶下载字体:

scoop bucket add nerd-fonts
scoop install Hack-NF

Option 4: Arch Extra Repository

选择拱形Linux,并希望使用额外的包。

大多数字体可通过Arch Extra软件包获得。 一些特殊的包是在AUR


Option 5: Ad Hoc Curl Download

可选:如果你想使用 curl命令 或用于 脚本

注意:将无法获得更新的字体,因为它们不再在repo中。


Linux
mkdir -p ~/.local/share/fonts
cd ~/.local/share/fonts && curl -fLO https://github.com/ryanoasis/nerd-fonts/raw/HEAD/patched-fonts/DroidSansMono/DroidSansMNerdFont-Regular.otf

注意: 已弃用替代路径:~/.fonts


苹果操作系统(OS X)
cd ~/Library/Fonts && curl -fLO https://github.com/ryanoasis/nerd-fonts/raw/HEAD/patched-fonts/DroidSansMono/DroidSansMNerdFont-Regular.otf

Option 6: Install Script

如果您想自动安装或在脚本中使用,最好的选择。

注意:从现在开始需要(浅)克隆存储库:-(注意:将无法获得更新的字体,因为它们不再在存储库中。


所有字体:
  • 安装所有打补丁的字体(警告:这是很多字体加起来很大的尺寸)
./install.sh

或者,在Powershell中(仅限Windows):

./install.ps1

单一字体:
  • 安装您选择的单个字体
./install.sh <FontName>
./install.sh Hack
./install.sh HeavyData

或者,在Powershell中(仅限Windows):

./install.ps1 <FontName>
./install.ps1 Hack
./install.ps1 HeavyData
./install.ps1 FiraCode, Hack
./install.ps1 DejaVuSansMono -WhatIf

Option 7: Clone the Repo

完全控制、全部或部分字体或有助于开发的最佳选择。

注意:将无法获得更新的字体,因为它们不再在repo中。

如果您只对一组有限的字体感兴趣,则不需要此存储库的完整克隆,也不高效(主要是由于存储库大小)。

如果您确实想克隆整个repo,请务必浅克隆:

git clone --depth 1

即使您进行开发,您也可能不需要旧版本的字体文件。使用此命令,您可以获得所有提交,但不是所有旧数据-只有在您签出旧二进制文件(或进行责备)时才会加载它:

git clone --filter=blob:none git@github.com:ryanoasis/nerd-fonts

如果您只想克隆一个子目录,请使用git sparse-checkout

git clone --filter=blob:none --sparse git@github.com:ryanoasis/nerd-fonts
cd nerd-fonts
git sparse-checkout add patched-fonts/JetBrainsMono

Option 8: Patch Your Own Font

修补您自己的字体或完全自定义修补后的字体的选项。

使用提供的Python命令行脚本从您自己的字体生成修补字体以获取额外的新字形

请参阅:字体修补程序的用法

  • 如果您不想使用提供的字体
  • 您仍然需要将生成的字体复制到系统上正确的字体目录

字体修补程序

Nerd Fonts Patcher


修补您自己选择的字体:

  • 使用脚本
    • 下载脚本及其辅助文件作为存档和解压
    • 仅仅下载font-patcher脚本是不够的。
    • 需要:Fontforge、Python 3、python-fontforge 和 argparse 包
      • 可以以包的形式安装 Fontforge
      • 或在OSX上通过brew install fontforge 安装
      • 或作为AppImage
    • 用法,推荐:
    fontforge -script font-patcher PATH_TO_FONT
    
    • 用法,直接(更方便的调用,如果它适合您):
    ./font-patcher PATH_TO_FONT
    
    • 使用Fontforge AppImage
      注意chmod u+x下载后的AppImage。所有提供的路径都需要是绝对的,并且需要显式输出路径!如果所有内容都位于同一目录中,您可以使用$PWD速记。
    ./FontForge.AppImage -script $PWD/font-patcher $PWD/BaseFont.ttf -out /tmp
    
  • 使用docker
    • 默认并行任务
    docker run --rm -v /path/to/fonts:/in:Z -v /path/for/output:/out:Z nerdfonts/patcher [OPTIONS]
    
    • 单进程(慢)
    docker run --rm -v /path/to/fonts:/in:Z -v /path/for/output:/out:Z -e "PN=1" nerdfonts/patcher [OPTIONS]
    
    • 将并行任务编号指定为10
    docker run --rm -v /path/to/fonts:/in:Z -v /path/for/output:/out:Z -e "PN=10" nerdfonts/patcher [OPTIONS]
    

注:生成的字体系列(又名字体名称)将在CamelCash之后设置为原始系列,删除空格并附加 Nerd Font。例如,iosevka term将成为IosevkaTerm Nerd Font

完整选项如下,另请参阅解释所有选项的页面

Nerd Fonts Patcher v3.1.0-6 (4.8.1) (ff 20230101)
usage: font-patcher [-h] [-v] [-s] [--variable-width-glyphs]
                    [--debug [{0,1,2,3}]] [-q] [--careful] [-ext EXTENSION]
                    [-out OUTPUTDIR] [--makegroups [{-1,0,1,2,3,4,5,6}]] [-c]
                    [--codicons] [--fontawesome] [--fontawesomeext]
                    [--fontlogos] [--material] [--octicons] [--powersymbols]
                    [--pomicons] [--powerline] [--powerlineextra] [--weather]
                    [--boxdrawing] [--configfile CONFIGFILE] [--custom CUSTOM]
                    [--dry] [--glyphdir GLYPHDIR] [--has-no-italic] [-l]
                    [--metrics {HHEA,TYPO,WIN}] [--name FORCE_NAME]
                    [--postprocess POSTPROCESS] [--removeligs]
                    [--xavgcharwidth [XAVGWIDTH]]
                    [--progressbars | --no-progressbars]
                    font

Nerd Fonts Font Patcher: patches a given font with programming and development related glyphs

* Website: https://www.nerdfonts.com
* Version: 3.1.0-6
* Development Website: https://github.com/ryanoasis/nerd-fonts
* Changelog: https://github.com/ryanoasis/nerd-fonts/blob/-/changelog.md

positional arguments:
  font                  The path to the font to patch (e.g., Inconsolata.otf)

options:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -s, --mono, --use-single-width-glyphs
                        Whether to generate the glyphs as single-width not double-width (default is double-width) (Nerd Font Mono)
  --variable-width-glyphs
                        Do not adjust advance width (no "overhang") (Nerd Font Propo)
  --debug [{0,1,2,3}]   Verbose mode (optional: 1=just to file; 2*=just to terminal; 3=display and file)
  -q, --quiet           Do not generate verbose output
  --careful             Do not overwrite existing glyphs if detected
  -ext EXTENSION, --extension EXTENSION
                        Change font file type to create (e.g., ttf, otf)
  -out OUTPUTDIR, --outputdir OUTPUTDIR
                        The directory to output the patched font file to
  --makegroups [{-1,0,1,2,3,4,5,6}]
                        Use alternative method to name patched fonts (default=1)

Symbol Fonts:
  -c, --complete        Add all available Glyphs
  --codicons            Add Codicons Glyphs (https://github.com/microsoft/vscode-codicons)
  --fontawesome         Add Font Awesome Glyphs (http://fontawesome.io/)
  --fontawesomeext      Add Font Awesome Extension Glyphs (https://andrelzgava.github.io/font-awesome-extension/)
  --fontlogos           Add Font Logos Glyphs (https://github.com/Lukas-W/font-logos)
  --material, --mdi     Add Material Design Icons (https://github.com/templarian/MaterialDesign)
  --octicons            Add Octicons Glyphs (https://octicons.github.com)
  --powersymbols        Add IEC Power Symbols (https://unicodepowersymbol.com/)
  --pomicons            Add Pomicon Glyphs (https://github.com/gabrielelana/pomicons)
  --powerline           Add Powerline Glyphs
  --powerlineextra      Add Powerline Extra Glyphs (https://github.com/ryanoasis/powerline-extra-symbols)
  --weather             Add Weather Icons (https://github.com/erikflowers/weather-icons)

Expert Options:
  --boxdrawing          Force patching in (over existing) box drawing glyphs
  --configfile CONFIGFILE
                        Specify a file path for JSON configuration file (see sample: src/config.sample.json)
  --custom CUSTOM       Specify a custom symbol font, all glyphs will be copied; absolute path suggested
  --dry                 Do neither patch nor store the font, to check naming
  --glyphdir GLYPHDIR   Path to glyphs to be used for patching
  --has-no-italic       Font family does not have Italic (but Oblique), to help create correct RIBBI set
  -l, --adjust-line-height
                        Whether to adjust line heights (attempt to center powerline separators more evenly)
  --metrics {HHEA,TYPO,WIN}
                        Select vertical metrics source (for problematic cases)
  --name FORCE_NAME     Specify naming source ('full', 'postscript', 'filename', or concrete free name-string)
  --postprocess POSTPROCESS
                        Specify a Script for Post Processing
  --removeligs, --removeligatures
                        Removes ligatures specificed in JSON configuration file (needs --configfile)
  --xavgcharwidth [XAVGWIDTH]
                        Adjust xAvgCharWidth (optional: concrete value)
  --progressbars        Show percentage completion progress bars per Glyph Set (default)
  --no-progressbars     Don't show percentage completion progress bars per Glyph Set

例子
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf -s -q
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --use-single-width-glyphs --quiet

./font-patcher Inconsolata.otf --fontawesome
./font-patcher Inconsolata.otf --fontawesome --octicons --pomicons
./font-patcher Inconsolata.otf

./FontForge.AppImage -script /tmp/nerdfonts/font-patcher /tmp/nerdfonts/CascadiaMonoPL-Semibold.ttf --fontawesome -out /tmp
./FontForge.AppImage -script $PWD/font-patcher $PWD/CascadiaMonoPL-Semibold.ttf --octicons -out $HOME

docker run --rm -v ~/myfont/patchme:/in:Z -v ~/myfont/patched:/out:Z nerdfonts/patcher
docker run --rm -v ~/Desktop/myfont/patchme:/in:Z -v ~/Desktop/myfont/patched:/out:Z nerdfonts/patcher --fontawesome

通常您需要--complete选项。


必须修补他们所有字体补丁!

  • 供贡献者或开发者使用
  • 重新修补未修补目录中的所有字体:
    ./gotta-patch-em-all-font-patcher\!.sh
    
  • 可以选择限制为特定的字体名称模式:
    ./gotta-patch-em-all-font-patcher\!.sh Hermit
    
  • 或以特定目录名称开始:
    ./gotta-patch-em-all-font-patcher\!.sh /Heavy
    

完整选项:

Usage: ./gotta-patch-em-all-font-patcher!.sh [OPTION] [FILTER]

    OPTION:
        -c, --checkfont     Create the font(s) in check-fonts/ instead
        -t, --keeptime      Try to preserve timestamp of previously patched
                            font in patched-fonts/ directory
        -v, --verbose       Show more information when running
        -i, --info          Rebuild JUST the readmes
        -j, --jobs          Run up to 8 patch processes in parallel
        -h, --help          Show this help

    FILTER:
        The filter argument to this script is a filter for the fonts to patch.
        The filter is a regex (glob * is expressed as [^/]*, see `man 7 glob`)
        All font files that start with that filter (and are ttf, otf, or sfd files) will
        be processed only.
          Example ./gotta-patch-em-all-font-patcher\!.sh "iosevka"
          Process all font files that start with "iosevka"
        If the argument starts with a '/' all font files in a directory that matches
        the filter are processed only.
          Example ./gotta-patch-em-all-font-patcher\!.sh "/iosevka"
          Process all font files that are in directory "iosevka"

不稳定的文件路径

⚠️警告:文件路径可能会根据版本(尤其是主要版本颠簸)而改变

引用发布标签或分支而不是主分支,因为每个版本的路径都可能发生变化

  • 比如
    • ✅用途:https://github.com/ryanoasis/nerd-fonts/tree/**v3.0.0**/patched-fonts/Hermit/Regular/HurmitNerdFont-Regular.otf
    • ✅用途:https://github.com/ryanoasis/nerd-fonts/blob/**0.9.0**/patched-fonts/Hermit/Medium/complete/Hurmit%20Medium%20Nerd%20Font%20Complete.otf
    • ❌ 替代:https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/Hermit/Medium/complete/Hurmit%20Medium%20Nerd%20Font%20Complete.otf

其他需要修补的好字体

可以从修补中受益但由于许可证(专有、商业等)未包含在 Nerd Fonts 中的字体的非详尽列表:


2024-08-04(日)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值