1
0
mirror of https://github.com/ryanoasis/nerd-fonts.git synced 2024-12-07 17:06:25 +02:00

casks: Find correct FamilyName base stem

[why]
The code takes the FamilyName out of the first patched font file and
puts that into the cask name field.

This has two problems:

After we joined Mono and non-Mono fonts into one cask the first font
might be a "Nerd Font Complete Mono" and we certainly do not want that
FamilyName in a cask that also contains the non-Mono variants.

We have some fonts with more than one Family, for example
  CaskaydiaCove Nerd Font SemiLight
  CaskaydiaCove Nerd Font Light
  CaskaydiaCove Nerd Font
  CaskaydiaCove Nerd Font ExtraLight

Taking the first encountered Family name is most certainly not want we
want.

[how]
Examine all patched fonts and collect their FamilyName and use the
shortest of them, as that usually is the base stem.

This still fails for somem fonts, like Hasklug
  Hasklig Black
  Hasklig ExtraLight
  Hasklig Light
  Hasklig Medium
  Hasklig Semibold
  Hasklug Nerd Font

But that font's FamilyName is broken anyhow, note that the RFN renaming
does not really work consistently. It would be fixed by using
`font-patcher` with option `--makegroups`, which should become the
default soon.
This will be tackled by the next commit.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2022-11-27 10:22:09 +01:00 committed by Fini
parent c8cb5c78a7
commit d6975ea99b

View File

@ -53,6 +53,14 @@ function write_body {
longest=${#basename}
fi
done
# Find familyname of non Mono variant (well, rather shortest because we can contain multiple families)
familyname=$(fc-query --format='%{family}' "${fonts[0]}")
for i in "${!fonts[@]}"; do
fn=$(fc-query --format='%{family}' "${fonts[$i]}")
if [ "${#fn}" -lt "${#familyname}" ]; then
familyname=${fn}
fi
done
# Process font files
for i in "${!fonts[@]}"; do
individualfont=$(basename "${fonts[$i]}")
@ -61,7 +69,6 @@ function write_body {
printf " %-${longest}s %s\\n" "${individualfont}" "${individualdir}"
if [ "$i" == 0 ]; then
familyname=$(fc-query --format='%{family}' "${fonts[$i]}")
{
printf " name \"%s (%s)\"\\n" "$familyname" "$unpatchedname"
printf " desc \"Developer targeted fonts with a high number of glyphs\"\\n"