diff --git a/Makefile b/Makefile index 18e6e4e..2759617 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ SRCD = sourceFonts DIST = dists TMPD = tmp +NERD = FontPatcher VERSION = $(shell date '+%Y%m%d%H%M%S') all: build @@ -10,13 +11,13 @@ build: download @PYTHONPATH=$(CURDIR)/scripts \ python3 -c "import sys;import build; sys.exit(build.build('$(VERSION)'))" -download: dl_rmgen dl_fsm dl_twemoji dl_icons +download: dl_rmgen dl_fsm dl_notoemoji dl_nerdfontsymbolonly dl_rmgen: - @[ -d $(SRCD) ] || mkdir -p $(SRCD) + @[ -d $(SRCD) ] || mkdir -p $(SRCD) @if [ ! -f $(SRCD)/rounded-x-mgenplus-1mn-regular.ttf ] ; then\ echo "Download Rounded Mgen+" ;\ - wget https://osdn.jp/downloads/users/8/8599/rounded-x-mgenplus-20150602.7z ;\ + wget https://ftp.iij.ad.jp/pub/osdn.jp/users/8/8599/rounded-x-mgenplus-20150602.7z ;\ unar rounded-x-mgenplus-20150602.7z ;\ cp -v rounded-x-mgenplus-20150602/rounded-x-mgenplus-1mn*.ttf $(SRCD)/ ;\ rm -fr rounded-x-mgenplus-20150602 ;\ @@ -24,7 +25,7 @@ dl_rmgen: fi dl_fsm: - @[ -d $(SRCD) ] || mkdir -p $(SRCD) + @[ -d $(SRCD) ] || mkdir -p $(SRCD) @if [ ! -f $(SRCD)/FantasqueSansMono-Regular.ttf ] ; then\ echo "Download Fantasque Sans Mono" ;\ wget https://fontlibrary.org/assets/downloads/fantasque-sans-mono/b0cbb25e73a9f8354e96d89524f613e7/fantasque-sans-mono.zip ;\ @@ -34,31 +35,26 @@ dl_fsm: rm -f fantasque-sans-mono.zip ;\ fi -dl_twemoji: - @[ -d $(SRCD) ] || mkdir -p $(SRCD) - @if [ ! -f $(SRCD)/TwitterColorEmoji-SVGinOT-ThickFallback.ttf ] ; then\ - echo "Download Twitter Color Emoji SVG in OpenType" ;\ - wget https://github.com/eosrei/twemoji-color-font/releases/download/v13.0.1/TwitterColorEmoji-SVGinOT-ThickFallback-13.0.1.zip ;\ - unar TwitterColorEmoji-SVGinOT-ThickFallback-13.0.1.zip ;\ - cp -v TwitterColorEmoji-SVGinOT-ThickFallback-13.0.1/*.ttf $(SRCD)/ ;\ - rm -fr TwitterColorEmoji-SVGinOT-ThickFallback-13.0.1 ;\ - rm -f TwitterColorEmoji-SVGinOT-ThickFallback-13.0.1.zip ;\ +dl_notoemoji: + @[ -d $(SRCD) ] || mkdir -p $(SRCD) + @if [ ! -f $(SRCD)/NotoEmoji-Regular.ttf ] ; then\ + echo "Download Noto Emoji Monchrome" ;\ + wget "https://fonts.google.com/download?family=Noto%20Emoji" -O Emoji.zip;\ + unar Emoji.zip ;\ + cp -v Emoji/static/NotoEmoji-Regular.ttf $(SRCD)/ ;\ + rm -fr Emoji ;\ + rm -f Emoji.zip ;\ fi -dl_symbola: - @[ -d $(SRCD) ] || mkdir -p $(SRCD) - @if [ ! -f $(SRCD)/Symbola.otf ] ; then\ - echo "Download Symbola: Multilingual support and Symbol blocks of The Unicode Standard" ;\ - wget https://dn-works.com/wp-content/uploads/2020/UFAS-Fonts/Symbola.zip ;\ - unar Symbola.zip ;\ - cp -v Symbola/Symbola.otf $(SRCD)/ ;\ - rm -fr Symbola ;\ - rm -f Symbola.zip ;\ - fi - -dl_icons: - @if [ ! -f $(SRCD)/isfit-plus.ttf ] ; then\ - wget https://github.com/uwabami/isfit-plus/raw/master/dists/isfit-plus.ttf -O $(SRCD)/isfit-plus.ttf ;\ +dl_nerdfontsymbolonly: + @[ -d $(SRCD) ] || mkdir -p $(SRCD) + @if [ ! -f $(SRCD)/SymbolsNerdFont-Regular.ttf ] ; then\ + echo "Download NerdFontSymbolOnly" ;\ + wget https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/NerdFontsSymbolsOnly.zip ;\ + unar NerdFontsSymbolsOnly.zip ;\ + cp -v NerdFontsSymbolsOnly/SymbolsNerdFont-Regular.ttf $(SRCD)/ ;\ + rm -fr NerdFontsSymbolsOnly ;\ + rm -f NerdFontsSymbolsOnly.zip ;\ fi clean: diff --git a/README.org b/README.org index 8bc5805..39f2395 100644 --- a/README.org +++ b/README.org @@ -2,22 +2,19 @@ * FSMRMP - Patched Font: 'Fantasque Sans Mono' + 'Rounded Mgen+' ** Overview - [[https://fontlibrary.org/en/font/fantasque-sans-mono][Fantasque Sans Mono]] is a monospace font with a distinct slightly - cursive look. The fonts "FSMRMP" (*wanted! awesome fontname*) is based on - *Fantasque Sans Mono*, and add glpyhs for Japanese from [[http://jikasei.me/font/rounded-mgenplus/][Rounded Mgen plus]], - and patched icon fonts into Private Use Area. + The fonts "FSMRMP" is a font that combines [[https://fontlibrary.org/en/font/fantasque-sans-mono][Fantasque Sans Mono]], [[http://jikasei.me/font/rounded-mgenplus/][Rounded Mgen plus]], [[https://fonts.google.com/noto/specimen/Noto+Emoji][Noto Emoji]] (Monochrome) and [[https://github.com/ryanoasis/nerd-fonts][Nerd fonts]] icons. ** Build *** Requirements - make - python3: - - python3-concurrent: for parallel builds - python3-fontforge - - unar: expand donwload files -*** Ubuntu 19.04, Debian (>= 10.0) + - wget: download sources. + - unar: expand donwload files. +*** Ubuntu 20.04, Debian (>= 12.0) #+begin_src shell -sudo apt install make wget unar python3 python3-concurrent.futures python3-fontforge -make +% sudo apt install make wget unar python3 python3-fontforge +% make #+end_src check =dists= directory. ** Font sources @@ -26,17 +23,16 @@ make only be used to represent the company or product to which they refer. Base fonts: - |---------------------+----------+--------------| - | Name | Version | License | - |---------------------+----------+--------------| - | [[https://fontlibrary.org/en/font/fantasque-sans-mono#Fantasque%2520Sans%2520Mono-Regular][Fantasque Sans Mono]] | 11 | [[https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL][SIL OFL v1.1]] | - | [[http://jikasei.me/font/rounded-mgenplus/][Rounded Mgen plus]] | 20150602 | [[https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL][SIL OFL v1.1]] | - | [[https://github.com/eosrei/twemoji-color-font][twemoji color font]] | v12.0.1 | [[https://github.com/eosrei/twemoji-color-font/blob/master/LICENSE-CC-BY.txt][CC BY-4.0]] | - |---------------------+----------+--------------| - - Icon fontset: @see [[https://github.com/uwabami/isfit-plus][isfit+]] + |-------------------------+----------+--------------| + | Name | Version | License | + |-------------------------+----------+--------------| + | [[https://fontlibrary.org/en/font/fantasque-sans-mono#Fantasque%2520Sans%2520Mono-Regular][Fantasque Sans Mono]] | 1.8.0 | [[https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL][SIL OFL v1.1]] | + | [[http://jikasei.me/font/rounded-mgenplus/][Rounded Mgen plus]] | 20150602 | [[https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL][SIL OFL v1.1]] | + | [[https://fonts.google.com/noto/specimen/Noto+Emoji][Noto Emoji]] | v15.0.0 | [[https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL][SIL OFL v1.1]] | + | [[https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/NerdFontsSymbolsOnly][Nerd Fonts Symbols Only]] | v3.0.2 | [[https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL][SIL OFL v1.1]] | + |-------------------------+----------+--------------| ** References. - Original build scripts provided by [[https://github.com/delphinus/homebrew-sfmono-square][SFMono Square - patched font: SFMono + Migu 1M + Nerd Fonts]]. + Original build scripts inspired by [[https://github.com/delphinus/homebrew-sfmono-square][SFMono Square - patched font: SFMono + Migu 1M + Nerd Fonts]]. Thanks to great scripts! diff --git a/scripts/build.py b/scripts/build.py index 55b6a08..bad6367 100644 --- a/scripts/build.py +++ b/scripts/build.py @@ -1,4 +1,4 @@ -#! /usr/bin/python +#! /usr/bin/python3 import sys from concurrent.futures import ProcessPoolExecutor, as_completed import rounded_x_mgenplus @@ -7,6 +7,7 @@ import emoji import font_patcher + RMGEN = [ ["sourceFonts/rounded-x-mgenplus-1mn-regular.ttf"], ["sourceFonts/rounded-x-mgenplus-1mn-bold.ttf"] @@ -18,21 +19,21 @@ ["sourceFonts/FantasqueSansMono-BoldItalic.ttf"], ] EMOJI = [ - ["sourceFonts/TwitterColorEmoji-SVGinOT-ThickFallback.ttf"] + ["sourceFonts/NotoEmoji-Regular.ttf"] ] FSM_RMGEN = [ ["tmp/modified-FantasqueSansMono-Regular.ttf", "tmp/modified-rounded-x-mgenplus-1mn-regular.ttf", - "tmp/modified-TwitterColorEmoji-SVGinOT-ThickFallback.ttf"], + "tmp/modified-NotoEmoji-Regular.ttf"], ["tmp/modified-FantasqueSansMono-Bold.ttf", "tmp/modified-rounded-x-mgenplus-1mn-bold.ttf", - "tmp/modified-TwitterColorEmoji-SVGinOT-ThickFallback.ttf"], + "tmp/modified-NotoEmoji-Regular.ttf"], ["tmp/modified-FantasqueSansMono-Italic.ttf", "tmp/modified-rounded-x-mgenplus-1mn-oblique.ttf", - "tmp/modified-TwitterColorEmoji-SVGinOT-ThickFallback.ttf"], + "tmp/modified-NotoEmoji-Regular.ttf"], ["tmp/modified-FantasqueSansMono-BoldItalic.ttf", "tmp/modified-rounded-x-mgenplus-1mn-bold-oblique.ttf", - "tmp/modified-TwitterColorEmoji-SVGinOT-ThickFallback.ttf"], + "tmp/modified-NotoEmoji-Regular.ttf"], ] FSM_RMGEN_PLUS = [ ["tmp/FSMRMP-Regular.ttf", "dists"], @@ -42,23 +43,23 @@ ] def build(version): - print("---- modifying rounded-x-mgenplus ----") - if concurrent_execute(rounded_x_mgenplus.modify, RMGEN): - return 1 - print("---- modifying fantasque_sans_mono ----") - if concurrent_execute(fantasque_sans_mono.modify, FSM): - return 1 - print("---- making oblique version of rounded-x-mgenplus ----") - if concurrent_execute(rounded_x_mgenplus.oblique, RMGEN): - return 1 - print("---- modifying Twitter Color Emoji ----") - if concurrent_execute(emoji.modify, EMOJI): - return 1 - print("---- generate Fantasque Sans Mono Rounded Mgen+ ----") - args = [a + [version] for a in FSM_RMGEN] - if concurrent_execute(fsmrmp.generate, args): - return 1 - print("---- adding Icons ----") + # print("---- modifying rounded-x-mgenplus ----") + # if concurrent_execute(rounded_x_mgenplus.modify, RMGEN): + # return 1 + # print("---- modifying fantasque_sans_mono ----") + # if concurrent_execute(fantasque_sans_mono.modify, FSM): + # return 1 + # print("---- making oblique version of rounded-x-mgenplus ----") + # if concurrent_execute(rounded_x_mgenplus.oblique, RMGEN): + # return 1 + # print("---- modifying Noto Emoji ----") + # if concurrent_execute(emoji.modify, EMOJI): + # return 1 + # print("---- generate Fantasque Sans Mono Rounded Mgen+ ----") + # args = [a + [version] for a in FSM_RMGEN] + # if concurrent_execute(fsmrmp.generate, args): + # return 1 + print("---- adding Nerd Icons ----") if concurrent_execute(font_patcher.patch, FSM_RMGEN_PLUS): return 1 return 0 diff --git a/scripts/emoji.py b/scripts/emoji.py index 19f9916..1065654 100644 --- a/scripts/emoji.py +++ b/scripts/emoji.py @@ -1,16 +1,16 @@ # -*- coding:utf-8 -*- -## Twitter Color Emoji or Symbola +## NotoEmoji monochrome from os.path import basename, splitext import fontforge import psMat -ASCENT = 1650 -DESCENT = 398 +ASCENT = 1638 +DESCENT = 410 OLD_EM = 2048 EM = ASCENT + DESCENT -SCALE_DOWN = 0.98 -X_TO_CENTER = EM * (1 - SCALE_DOWN) / 2 +SCALE_DOWN = 0.9 +X_TO_CENTER = - EM * (1 - SCALE_DOWN) / 2 # OBLIQUE_SKEW = 0.2 def modify(in_file): @@ -39,8 +39,8 @@ def _set_new_em(font): """ font.selection.all() font.unlinkReferences() - font.ascent = float(ASCENT) / EM * OLD_EM - font.descent = float(DESCENT) / EM * OLD_EM + font.ascent = round(float(ASCENT) / EM * OLD_EM) + font.descent = round(float(DESCENT) / EM * OLD_EM) font.em = EM def _set_proportion(font): diff --git a/scripts/fantasque_sans_mono.py b/scripts/fantasque_sans_mono.py index b3c230e..1b213ba 100644 --- a/scripts/fantasque_sans_mono.py +++ b/scripts/fantasque_sans_mono.py @@ -1,13 +1,13 @@ # -*- coding:utf-8 -*- ## Fantasque Sans Mono -# Ascent: 1650 -# Descent: 398 +# Ascent: 1638 +# Descent: 410 # Width: 1060 # EM: 2048 from os.path import basename, splitext import fontforge -import psMat +from psMat import scale OLD_WIDTH = 1060 WIDTH = 1024 @@ -25,8 +25,14 @@ def modify(in_file): def _set_proportion(font): - mat = psMat.scale(SCALE_DOWN) + mat = scale(SCALE_DOWN) font.selection.all() + scaled = set() for glyph in list(font.selection.byGlyphs): - glyph.transform(mat) + codepoint = glyph.unicode + if codepoint != -1 and codepoint in scaled: + print(f"this is already scaled: {codepoint:#x}") + else: + glyph.transform(mat) + scaled.add(codepoint) glyph.width = WIDTH diff --git a/scripts/font_patcher.py b/scripts/font_patcher.py index 9a3c418..b9129c8 100644 --- a/scripts/font_patcher.py +++ b/scripts/font_patcher.py @@ -1,4 +1,4 @@ -#! /usr/bin/python +#! /usr/bin/python3 from concurrent.futures import ProcessPoolExecutor, as_completed import errno @@ -6,27 +6,189 @@ import fontforge import psMat -ASCENT = 1650 -DESCENT = 398 -OLD_EM = 1024 +ASCENT = 1638 +DESCENT = 410 +OLD_EM = 2048 EM = ASCENT + DESCENT SCALE_DOWN = 0.96 X_TO_CENTER = EM * (1 - SCALE_DOWN) / 2 PATCH_SET = [ { - "name": "Icon Symbol Font In Terminal Plus", - "filename": "isfit-plus.ttf", - "sym_start": 0xE000, - "sym_end": 0xEEFF, - "src_start": None, + # Seti-UI + Custom + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xE5FA, + "sym_end": 0xE6AC, + "src_start": 0xE5FA, + }, + { + # Devicons + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xE700, + "sym_end": 0xE7C5, + "src_start": 0xE700, }, { - "name": "Icon Symbol Font In Terminal Plus", - "filename": "isfit-plus.ttf", + # Font Awesome + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", "sym_start": 0xF000, - "sym_end": 0xF8FF, - "src_start": None, + "sym_end": 0xF2E0, + "src_start": 0xF000, + }, + { + # Font Awesome Extension + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xE200, + "sym_end": 0xE2A9, + "src_start": 0xE200, + }, + { + # Material Design Icon + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xF0001, + "sym_end": 0xF1AF0, + "src_start": 0xF0001, + }, + { + # Weather + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xE300, + "sym_end": 0xE3E3, + "src_start": 0xE300, + }, + { + # Octicons + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xF400, + "sym_end": 0xF532, + "src_start": 0xF400, + }, + { + # Octicons + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0x2665, + "sym_end": 0x2665, + "src_start": 0x2665, + }, + { + # Octicons + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0x26A1, + "sym_end": 0x26A1, + "src_start": 0x26A1, + }, + { + # Powerline Symbols + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xE0A0, + "sym_end": 0xE0A2, + "src_start": 0xE0A0, + }, + { + # Powerline Symbols + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xE0B0, + "sym_end": 0xE0B3, + "src_start": 0xE0B0, + }, + { + # Powerline Extra Symbols + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xE0A3, + "sym_end": 0xE0A3, + "src_start": 0xE0A3, + }, + { + # Powerline Extra Symbols + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xE0B4, + "sym_end": 0xE0C8, + "src_start": 0xE0B4, + }, + { + # Powerline Extra Symbols + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xE0CA, + "sym_end": 0xE0CA, + "src_start": 0xE0CA, + }, + { + # Powerline Extra Symbols + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xE0CC, + "sym_end": 0xE0D4, + "src_start": 0xE0CC, + }, + { + # IEC Power Symbols + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0x23FB, + "sym_end": 0x23FE, + "src_start": 0x23FB, + }, + { + # IEC Power Symbols + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0x2B58, + "sym_end": 0x2B58, + "src_start": 0x2B58, + }, + { + # Font Logos + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xF300, + "sym_end": 0xF32F, + "src_start": 0xF300, + }, + { + # Pomicons + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xE000, + "sym_end": 0xE00A, + "src_start": 0xE000, + }, + { + # Codicons + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xEA60, + "sym_end": 0xEBEB, + "src_start": 0xEA60, + }, + { + # Additional: Heavy Angle Brackets + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xE276C, + "sym_end": 0xE2771, + "src_start": 0xE276C, + }, + { + # Additional: Box Drawing Char + "name": "SymbolsNerdFont", + "filename": "SymbolsNerdFont-Regular.ttf", + "sym_start": 0xE2500, + "sym_end": 0xE259F, + "src_start": 0xE2500, }, ] @@ -83,8 +245,3 @@ def _copy_glyphs(font, symfont, info): font.selection.select(src_encoding) font.paste() return - -def concurrent_execute(func, args): - executor = ProcessPoolExecutor() - futures = [executor.submit(func, *a) for a in args] - return 1 if any([r.result() for r in as_completed(futures)]) else 0 diff --git a/scripts/rounded_x_mgenplus.py b/scripts/rounded_x_mgenplus.py index 36a5840..3631b9c 100644 --- a/scripts/rounded_x_mgenplus.py +++ b/scripts/rounded_x_mgenplus.py @@ -15,7 +15,7 @@ EM = ASCENT + DESCENT SCALE_DOWN = 0.94 # 1650/(881*2.0) X_TO_CENTER = EM * (1 - SCALE_DOWN) / 2 -HANKAKU_KANA = (0xFF60, 0xFF9F) +HANKAKU_KANA = (0xFF61, 0xFF9F) OBLIQUE_SKEW = 0.2 def modify(in_file): @@ -47,8 +47,8 @@ def _set_new_em(font): """ font.selection.all() font.unlinkReferences() - font.ascent = float(ASCENT) / EM * OLD_EM - font.descent = float(DESCENT) / EM * OLD_EM + font.ascent = round(float(ASCENT) / EM * OLD_EM) + font.descent = round(float(DESCENT) / EM * OLD_EM) font.em = EM @@ -61,7 +61,7 @@ def _set_proportion(font): trans = psMat.translate(x_to_center, 0) mat = psMat.compose(scale, trans) glyph.transform(mat) - glyph.width = EM / 2 if is_hankaku_kana else EM + glyph.width = round(EM / 2) if is_hankaku_kana else EM def _zenkaku_space(font):