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 <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2022-03-03 16:03:10 +01:00 committed by Fini
parent 5ceb1b2395
commit 821ac68173
7 changed files with 24 additions and 12 deletions

View file

@ -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

View file

@ -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']

View file

@ -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

View file

@ -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

View file

@ -0,0 +1 @@
config_patch_flags="--ext ttf"