Skip to content

Commit

Permalink
Create symbols only font directly from sfd template
Browse files Browse the repository at this point in the history
[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) ryanoasis#581 ryanoasis#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 9e2bc9a of ryanoasis#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 <[email protected]>
  • Loading branch information
Finii committed Aug 20, 2022
1 parent bec0181 commit 01097fb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 126 deletions.
14 changes: 6 additions & 8 deletions bin/scripts/gotta-patch-em-all-font-patcher!.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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[*]}"
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions font-patcher
Original file line number Diff line number Diff line change
Expand Up @@ -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']


Expand Down
59 changes: 0 additions & 59 deletions src/glyphs/NerdFontsSymbols 1000 EM Nerd Font Complete Blank.sfd

This file was deleted.

59 changes: 0 additions & 59 deletions src/glyphs/NerdFontsSymbols 2048 EM Nerd Font Complete Blank.sfd

This file was deleted.

0 comments on commit 01097fb

Please sign in to comment.