1
0
mirror of https://github.com/ryanoasis/nerd-fonts.git synced 2025-01-06 21:49:40 +02:00

generate-font-image-previews: Generate Symbols Only preview

[why]
We do not have a preview for the Symbols Only font.
The Symbols Only font appears two times (with 1000 and with 2048 EM).

[how]
Remove one of the occurences of NerdFontSymbolsOnly in the fonts.json.
The font matrix (for CI) still works, and we get only one entry in the
fonts list on the gh-pages.

Change the entry details accordingly.

Create special svg template that includes lots of symbols.

Change the destination filename to be imagePreviewFont instead of the
patchedName + "Nerd Font". The website (gh-pages) expects the former
file names.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2022-12-19 17:10:38 +01:00
parent 7aa717a05e
commit 2597b4ef3f
3 changed files with 84 additions and 20 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Nerd Fonts Version: 2.3.0-RC
# Script Version: 1.0.1
# Script Version: 1.1.0
# Create font previews.
# All fonts need to be installed (or no preview is generated)
# Files should end up in the gh-pages branch
@ -11,6 +11,7 @@ echo "Check generator version: $ver"
output_dir="../../assets/img/previews/"
template_svg="lib/template-font-preview.svg"
template2_svg="lib/template-font-preview2.svg"
main() {
mkdir -p "$output_dir"
@ -18,14 +19,21 @@ main() {
for i in $(jq '.fonts | keys | .[]' lib/fonts.json); do
patchedName=$(jq -r ".fonts[$i].patchedName" lib/fonts.json);
imagePreviewFont=$(jq -r ".fonts[$i].imagePreviewFont" lib/fonts.json);
# if [ "$imagePreviewFont" != "$patchedName Nerd Font" ]; then
# echo "[mismatch] $imagePreviewFont != $patchedName Nerd Font"
# fi
if [ -z "$imagePreviewFont" ]; then
echo "[Skipping] $patchedName"
continue
fi
fc-list -q "$imagePreviewFont" \
&& generate_preview "$imagePreviewFont" "$patchedName Nerd Font" \
|| echo "[Missing] $imagePreviewFont"
if $( fc-list -q "${imagePreviewFont}:charset=41" ); then
generate_preview "$imagePreviewFont" "$patchedName Nerd Font"
elif $( fc-list -q "${imagePreviewFont}" ); then
generate_preview_symbols "$imagePreviewFont" "$patchedName Nerd Font"
else
echo "[Missing] $imagePreviewFont"
fi
done
}
@ -34,9 +42,18 @@ generate_preview() {
font=$1
fontText=$2
echo "[Generating] $font"
sed -e "s/000000/ffffff/" -e "s/sans-serif/${font}/" -e "s/Font Name/${fontText}/" <"$template_svg" >"${output_dir}${fontText}.svg"
inkscape "${output_dir}${fontText}.svg" "--actions=select-all;object-to-path;export-filename:${output_dir}${fontText}.svg;export-do;quit-inkscape" 2>/dev/null
# svgo "${output_dir}${fontText}.svg"
sed -e "s/000000/ffffff/" -e "s/sans-serif/${font}/" -e "s/Font Name/${fontText}/" <"$template_svg" >"${output_dir}${font}.svg"
inkscape "${output_dir}${font}.svg" "--actions=select-all;object-to-path;export-filename:${output_dir}${font}.svg;export-do;quit-inkscape" 2>/dev/null
# svgo "${output_dir}${font}.svg"
}
generate_preview_symbols() {
font=$1
fontText=$2
echo "[Gen. Symb.] $font"
sed -e "s/000000/ffffff/" -e "40,80s/sans-serif/${font}/" -e "s/Font Name/${fontText}/" <"$template2_svg" >"${output_dir}${font}.svg"
inkscape "${output_dir}${font}.svg" "--actions=select-all;object-to-path;export-filename:${output_dir}${font}.svg;export-do;quit-inkscape" 2>/dev/null
# svgo "${output_dir}${font}.svg"
}
main "$@"; exit

View File

@ -463,22 +463,12 @@
{
"unpatchedName": "Symbols Only",
"RFN": false,
"patchedName": "Symbols-1000-em Nerd Font Complete",
"patchedName": "Symbols",
"folderName": "NerdFontsSymbolsOnly",
"imagePreviewFont": "",
"imagePreviewFont": "Symbols Nerd Font Mono",
"linkPreviewFont": false,
"caskName": "symbols-only",
"description": "Just the Nerd Font Icons. I.e Symbol font only. 1000 EM size"
},
{
"unpatchedName": "Symbols Only",
"RFN": false,
"patchedName": "Symbols-2048-em Nerd Font Complete",
"folderName": "NerdFontsSymbolsOnly",
"imagePreviewFont": "",
"linkPreviewFont": false,
"caskName": "symbols-only",
"description": "Just the Nerd Font Icons. I.e Symbol font only. 2048 EM size"
"description": "Just the Nerd Font Icons. I.e Symbol font only"
},
{
"unpatchedName": "Terminus",

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
id="svg2"
viewBox="0 0 744.09448819 1052.3622047"
height="297mm"
width="210mm">
<defs
id="defs4" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1">
<text
id="text4136"
y="100.93363"
x="62.857143"
style="font-style:normal;font-weight:normal;font-size:27.5px;line-height:125%;font-family:sans-serif;text-decoration: underline;text-decoration-line: underline;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
y="100.93363"
x="62.857143"
id="tspan4138">Font Name</tspan></text>
<text
id="text4140"
y="140.93362"
x="65.419403"
style="font-style:normal;font-weight:normal;font-size:27.5px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
style="font-size:17.5px"
y="140.93362"
x="65.419403"
id="tspan4142">             </tspan><tspan
style="font-size:17.5px"
id="tspan4144"
y="162.80862"
x="65.419403">             </tspan><tspan
style="font-size:17.5px"
id="tspan4148"
y="184.68362"
x="65.419403">             </tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB