From 821ac68173a9651cb5ca788996c18273de994f95 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Thu, 3 Mar 2022 16:03:10 +0100 Subject: [PATCH] Create symbols only font directly from sfd template [why] The symbol only fonts Symbols-1000-em Nerd Font Complete.ttf and 2048-em in `NerdFontsSymbolsOnly/` are generated from some 'almost' empty source fonts, that are assumable in turn generated from the sfd font descriptions in `src/glyphs/`? The process is not documented and we have issues in the generated font (for example the glyph for capital `E` is defined (and empty) #581 #765). [how] Use the existing font definitions from `src/glyphs/*.sfd` directly as source font. That needs a change in font-patcher because the empty fonts have no glyphs that can be used to orient the scaling upon. In that case scale on the source font definitions EM. Then we need patch-em-all to also patch *.sfd fonts. And finally we need patch-em-all to take a font specific command line switch for font-patcher (compare 9e2bc9a26 of #723) to instruct it to create a ttf rather than a sfd font file. In the sfd file we additionally set the Panose type. And the UnderlinePosition is adjusted to match the current patched font. [note] Also fix wrong glob pattern in patch-em-all `*.[o,t]tf`. The comma is for sure some leftover from a '{}' shell pattern, that is not used anymore. (This comment is probably outdated, due to rebasing.) Signed-off-by: Fini Jastrow --- bin/scripts/gotta-patch-em-all-font-patcher!.sh | 14 ++++++-------- font-patcher | 11 +++++++++++ ...sSymbols 1000 EM Nerd Font Complete Blank.sfd | 5 +++-- ...sSymbols 2048 EM Nerd Font Complete Blank.sfd | 5 +++-- .../NerdFontsSymbolsOnly Template 1000 em.ttf | Bin 1284 -> 0 bytes .../NerdFontsSymbolsOnly Template 2048 em.ttf | Bin 1284 -> 0 bytes .../NerdFontsSymbolsOnly/config.cfg | 1 + 7 files changed, 24 insertions(+), 12 deletions(-) rename src/{glyphs => unpatched-fonts/NerdFontsSymbolsOnly}/NerdFontsSymbols 1000 EM Nerd Font Complete Blank.sfd (93%) rename src/{glyphs => unpatched-fonts/NerdFontsSymbolsOnly}/NerdFontsSymbols 2048 EM Nerd Font Complete Blank.sfd (93%) delete mode 100644 src/unpatched-fonts/NerdFontsSymbolsOnly/NerdFontsSymbolsOnly Template 1000 em.ttf delete mode 100644 src/unpatched-fonts/NerdFontsSymbolsOnly/NerdFontsSymbolsOnly Template 2048 em.ttf create mode 100755 src/unpatched-fonts/NerdFontsSymbolsOnly/config.cfg diff --git a/bin/scripts/gotta-patch-em-all-font-patcher!.sh b/bin/scripts/gotta-patch-em-all-font-patcher!.sh index e0b71bd6b..4dbc550c3 100755 --- a/bin/scripts/gotta-patch-em-all-font-patcher!.sh +++ b/bin/scripts/gotta-patch-em-all-font-patcher!.sh @@ -6,7 +6,8 @@ # set -x # The optional first argument to this script is a filter for the fonts to patch. -# All font files that start with that filter (and are ttf or otf files) will +# 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" @@ -37,7 +38,6 @@ res1=$(date +%s) parent_dir="${sd}/../../" # Set source and target directories source_fonts_dir="${sd}/../../src/unpatched-fonts" -like_mode='' like_pattern='' complete_variations_per_family=4 font_typefaces_count=0 @@ -54,12 +54,10 @@ if [ $# -eq 1 ] || [ "$1" != "" ] then if [[ "${1:0:1}" == "/" ]] then - like_mode="-ipath" - like_pattern="*$1/*.[o,t]tf" + like_pattern=".*$1/.*\.\(otf\|ttf\|sfd\)" echo "$LINE_PREFIX Parameter given, limiting search and patch to pathname pattern '$1' given" else - like_mode="-iname" - like_pattern="$1*.[o,t]tf" + like_pattern=".*/$1[^/]*\.\(otf\|ttf\|sfd\)" echo "$LINE_PREFIX Parameter given, limiting search and patch to filename pattern '$1' given" fi fi @@ -76,7 +74,7 @@ fi source_fonts=() while IFS= read -d $'\0' -r file ; do source_fonts=("${source_fonts[@]}" "$file") -done < <(find "$source_fonts_dir" ${like_mode} ${like_pattern} -type f -print0) +done < <(find "$source_fonts_dir" -iregex ${like_pattern} -type f -print0) # print total number of source fonts found echo "$LINE_PREFIX Total source fonts found: ${#source_fonts[*]}" @@ -297,7 +295,7 @@ then # to follow font naming changed. We can not do this if we patch only # some of the source font files in that directory. last_source_dir=${current_source_dir} - num_to_patch=$(find "${current_source_dir}" ${like_mode} ${like_pattern} -type f | wc -l) + num_to_patch=$(find "${current_source_dir}" -iregex ${like_pattern} -type f | wc -l) num_existing=$(find "${current_source_dir}" -iname "*.[o,t]tf" -type f | wc -l) if [ ${num_to_patch} -eq ${num_existing} ] then diff --git a/font-patcher b/font-patcher index a982b2835..6897d1302 100755 --- a/font-patcher +++ b/font-patcher @@ -804,6 +804,17 @@ class font_patcher: self.font_dim['xmax'] = xmax # Calculate font height + if self.font_dim['height'] == 0: + # This can only happen if the input font is empty + # Assume we are using our prepared templates + self.font_dim = { + 'xmin' : 0, + 'ymin' : -self.sourceFont.descent, + 'xmax' : self.sourceFont.em, + 'ymax' : self.sourceFont.ascent, + 'width' : self.sourceFont.em, + 'height': 0, + } self.font_dim['height'] = abs(self.font_dim['ymin']) + self.font_dim['ymax'] diff --git a/src/glyphs/NerdFontsSymbols 1000 EM Nerd Font Complete Blank.sfd b/src/unpatched-fonts/NerdFontsSymbolsOnly/NerdFontsSymbols 1000 EM Nerd Font Complete Blank.sfd similarity index 93% rename from src/glyphs/NerdFontsSymbols 1000 EM Nerd Font Complete Blank.sfd rename to src/unpatched-fonts/NerdFontsSymbolsOnly/NerdFontsSymbols 1000 EM Nerd Font Complete Blank.sfd index d49553e80..3e8e0659a 100644 --- a/src/glyphs/NerdFontsSymbols 1000 EM Nerd Font Complete Blank.sfd +++ b/src/unpatched-fonts/NerdFontsSymbolsOnly/NerdFontsSymbols 1000 EM Nerd Font Complete Blank.sfd @@ -6,7 +6,7 @@ Weight: Regular Copyright: Copyright (c) 2016, Ryan McIntyre Version: 001.000 ItalicAngle: 0 -UnderlinePosition: -100 +UnderlinePosition: -150 UnderlineWidth: 50 Ascent: 800 Descent: 200 @@ -20,12 +20,13 @@ OS2Version: 0 OS2_WeightWidthSlopeOnly: 0 OS2_UseTypoMetrics: 1 CreationTime: 1480466430 -ModificationTime: 1480467813 +ModificationTime: 1646316690 PfmFamily: 17 TTFWeight: 400 TTFWidth: 5 LineGap: 90 VLineGap: 0 +Panose: 2 0 5 9 0 0 0 0 0 0 OS2TypoAscent: 0 OS2TypoAOffset: 1 OS2TypoDescent: 0 diff --git a/src/glyphs/NerdFontsSymbols 2048 EM Nerd Font Complete Blank.sfd b/src/unpatched-fonts/NerdFontsSymbolsOnly/NerdFontsSymbols 2048 EM Nerd Font Complete Blank.sfd similarity index 93% rename from src/glyphs/NerdFontsSymbols 2048 EM Nerd Font Complete Blank.sfd rename to src/unpatched-fonts/NerdFontsSymbolsOnly/NerdFontsSymbols 2048 EM Nerd Font Complete Blank.sfd index 4c0601b95..25347bd01 100644 --- a/src/glyphs/NerdFontsSymbols 2048 EM Nerd Font Complete Blank.sfd +++ b/src/unpatched-fonts/NerdFontsSymbolsOnly/NerdFontsSymbols 2048 EM Nerd Font Complete Blank.sfd @@ -6,7 +6,7 @@ Weight: Regular Copyright: Copyright (c) 2016, Ryan McIntyre Version: 001.000 ItalicAngle: 0 -UnderlinePosition: -204 +UnderlinePosition: -306 UnderlineWidth: 102 Ascent: 1638 Descent: 410 @@ -20,12 +20,13 @@ OS2Version: 0 OS2_WeightWidthSlopeOnly: 0 OS2_UseTypoMetrics: 1 CreationTime: 1480466430 -ModificationTime: 1480467841 +ModificationTime: 1646316690 PfmFamily: 17 TTFWeight: 400 TTFWidth: 5 LineGap: 184 VLineGap: 0 +Panose: 2 0 5 9 0 0 0 0 0 0 OS2TypoAscent: 0 OS2TypoAOffset: 1 OS2TypoDescent: 0 diff --git a/src/unpatched-fonts/NerdFontsSymbolsOnly/NerdFontsSymbolsOnly Template 1000 em.ttf b/src/unpatched-fonts/NerdFontsSymbolsOnly/NerdFontsSymbolsOnly Template 1000 em.ttf deleted file mode 100644 index 9d1fbb98f4c8eebed68f2e0e269e92e5e410a30e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1284 zcmd5+OKTHR6#nkaqz|f=l!`8bouFteMoj{xNEf0uP@x)Z70pJ+JS%w&NstCago+Cl zab3Y5Aub9Q?XC-5bkU6RQv$+!8xmS#e|7>QJxI~%xJW=B0oh?yQ6 z>*SvLQtcq2=xrc09C+$_J&a6oHjfSFnl){28d=>*zmE;Y&Y}_{9r|7B44l2p9}(RP zaDkdkAp(n&1O_M-i!(cSO0tSHym#7*1S#&9k{p8NySh`+jF4Thi?nvJ|KDbPt})(w zjowKyF$ko>(eSZU_;6GWcQ!YT)t|+vA(w>DAhI%bOZN91myZ?p`MW{hAYKf36PJ(= zu!Tc-9pDgbYzKIN{12Q*9WL5vU}7$dirdUoL6drdaq`AdAP=Nz5r2^lRw*#c8Ls}g_-}E(Pm=ZHynXSY8@Z!@j{~l; qLW7+w>AJS=C4rMcSN1<-2u`ZE!m58hn@Uc2*YIEu9uv(K+iWCuzfe6)LTM-w%Cb^`LG)EGoU8IXR z6vRFD6#pbiR&&->jqY6so@!h7%Yy#L>K-vtW5UaTR4LM}Hy zyWaX@1Lj9s6PM>srWaeEx`4VyezRD2{jI|XgukR*EZ%B6$XYQVa)^Gj;I3#mf~mDUl6~eOjT*Ho3_PTaq_Why}iOhS@I6~NUc$Hk-`k~ z6Xbj9?uw5*cGEvi?kv0Y^1-|5JMOrq+Eqs5RHDB>ehHza@-IVuxjuK#neXI~*gLpo~5nMtk#3n}Z zEW{QZY=k&U`!}3N13p&K#1ij#6>UbOP{c9nG$wEgQ#ek1g)uIciDv1|6SZ|#nX}9h z)v?G*HMGbjZxYiON11jYM~}pdZn8_6RZdg>%p2d47sRC5e;gS~FpYepf6oK1vO|-T sEa|=ur;&Y}(0YP>|6L)xseJ{H(TcKjDc