mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-19 09:51:48 +02:00
casks: Improve cask names
[why] Sometimes the shortest Family is not a meaningful name, for example iMWritingDuo iMWritingDuospace iMWritingMono iMWritingQuattro Obviously the shortest name is not adequate. [how] Instead we find the shortest word stem of the name. The common beginning of all names. In the example above that is `iMWriting`. If we have such a case we show in the name that there are multiple families in the cask, by adding "families" to the name. [note] Also always capitalize the font name. Some fonts have a all-small-letters name, but that seems a bit out of place and has been changed with the manual naming (previously) already to Capitalized Name. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
dd75219729
commit
5cda467ce3
1 changed files with 19 additions and 6 deletions
|
@ -61,6 +61,19 @@ function find_nerdish_family {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Return the longest common starting part of two strings
|
||||||
|
# This is the stem, the basic base name of the fonts
|
||||||
|
function find_common_stem {
|
||||||
|
local first=$1
|
||||||
|
local second=$2
|
||||||
|
for i in $(seq ${#first} -1 1); do
|
||||||
|
if [ "${first:0:$i}" == "${second:0:$i}" ]; then
|
||||||
|
echo "${first:0:$i}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
function write_body {
|
function write_body {
|
||||||
local unpatchedname=$1
|
local unpatchedname=$1
|
||||||
local outputfile=$2
|
local outputfile=$2
|
||||||
|
@ -80,17 +93,17 @@ function write_body {
|
||||||
familyname=$(find_nerdish_family "${fonts[0]}")
|
familyname=$(find_nerdish_family "${fonts[0]}")
|
||||||
for i in "${!fonts[@]}"; do
|
for i in "${!fonts[@]}"; do
|
||||||
fn=$(find_nerdish_family "${fonts[$i]}")
|
fn=$(find_nerdish_family "${fonts[$i]}")
|
||||||
if [ -z "${fn}" ]; then
|
familyname=$(find_common_stem "${fn}" "${familyname}")
|
||||||
break
|
|
||||||
fi
|
|
||||||
if [ "${#fn}" -lt "${#familyname}" ]; then
|
|
||||||
familyname=${fn}
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
if [ -z "${familyname}" ]; then
|
if [ -z "${familyname}" ]; then
|
||||||
echo >&2 "${LINE_PREFIX} Can not determine family name"
|
echo >&2 "${LINE_PREFIX} Can not determine family name"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
# Family names differ in front of "Nerd Font" (stem is short)
|
||||||
|
if [[ "${familyname}" != *Nerd* ]]; then
|
||||||
|
familyname="${familyname} Nerd Font families"
|
||||||
|
fi
|
||||||
|
familyname="$(tr [:lower:] [:upper:] <<< ${familyname:0:1})${familyname:1}"
|
||||||
# Process font files
|
# Process font files
|
||||||
for i in "${!fonts[@]}"; do
|
for i in "${!fonts[@]}"; do
|
||||||
individualfont=$(basename "${fonts[$i]}")
|
individualfont=$(basename "${fonts[$i]}")
|
||||||
|
|
Loading…
Reference in a new issue