[why]
When so svg files could be optimized we still try to commit the
'changes'. There are no changes - so nothing is committed (empty commits
are avoided).
But the workflow run still shows the 'commit back to repo' step,
although we know beforehand that it will not commit anything.
[how]
Technically that is no problem and the behavior is unchanged, but we can
just skip the commit step if we know there can not be anything to
commit...
It just looks nicer :-}
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
This is so big, it will shrink 2 times with a
optimize-original-source.sh run, and we want to have 'optimal' glyphs
after the next (automated) CI run
[how]
Use optimize-original-source.sh once and just commit the php.svg.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Despite commit
cc2b54770 generate-original-source: Remove FFTM table
we still get unneeded font rebuilds.
The reason is that the font creation time is not only encoded in FFTM but
also in HEAD.
[how]
We could simply diable timestamps also in HEAD, but that would leave us
with a strange font; strange because no one knows when it has been
created.
Instead we take the more laberous route here: Do detect changes and not
rely on the git history:
* Find out current font's creation date
* Create the font anew with that date as creation date
* If the 'real' font content is unchanged we would now have a 100%
identical new font file; we can detect that with `git diff`
* If it is not identical, something apart from the timestamp has
changed and we create the font again, this time with the real current
time as timestamp and commit that file back to the repo
This only works if creation and modification time are always the same on
all font creations; we need to ensure this by always using the
SOURCE_DATE_EPOCH method, even for 'normal' font creation.
This is a bit more involved than what I would have hoped for, but there
seems to be no easy solution.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
When the CI triggers a rebuild of the original-source and the font
contents is unchanged we do not want to commit the new version back to
the repo.
But because fontforge puts the creation date into the font file it will
always differ on every run, and we would needlessly create commits.
[how]
We could use the SOURCE_DATE_EPOCH approach and set the dates to the
relevant change (commit) times like so:
cd src/svgs
export SOURCE_DATE_EPOCH="$(git log -1 --format=%ct -- *.svg)"
and only afterwards call the generator script / fontforge.
But that would need a complete git repo checkout and not just a shallow
one (which is faster and thus is used by github action/checkout).
Instead we can instruct fontforge to not put any timestamp into the
file. The timestamps are anyhow a fontforge proprietary extension.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Often the SVGs are rather detailed and result in a big
original-source.otf, which then again results in bigger than needed
patched fonts.
[how]
Typically people suggest using svgo to make SVGs smaller, but that just
tackles the representation of the icon, i.e. the actual svg file. That
does not help us at all. We do not need small svg files, we need simple
icons with few points and lines. svgo does not have that capability.
Instead Inkscape's 'Simplify' is used. Repeated use can destroy a glyph,
so we need a scale down margin to stop 'over-simplification'.
The values given for the margin at the moment are purely empirical, the
current glyphs survive repeated use of the new simplification script and
still look good.
The resultant original-source.otf file size is approximately similar to
the previously achieved by Ryan's manual work.
[note]
We need a newer Inkscape, thus update to Ubuntu 22.04
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
When we add a custom glyph (or want to update Seti) the process is
rather laborious and we are needed to change the font and the
accompanying `i_seti.sh` in sync.
[how]
We use a data file to map icon (svg) filenames to codepoints and
readable names.
That file is parsed and the font and info file is created (overwritten
in the repo); and could then be easily committed. This can be a CI
workflow.
Having a dedicated mapping file (`icons.tsv`) enables us to have stable
codepoints for the same symbol over time. Changes in codepoint
allocation can be checked in git.
Having the font autogenerated help guarantee that the icons are all
likely scaled. We rescale them all to the same size and mid-position.
That is not needed for font-patcher, because it rescales and shifts
again based on to-be-patched font metrics. But it certainly is better
for a view into the original-source font.
Sizes and position are still roughly equivalent to the hand positioned
glyphs.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
With commits
ef8c12e28 Document and update cheat sheet data
bcef53dad Update cheat sheet
the README has not been updated, and i_cod.sh is still
listed as 'not existing'.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Maybe people would like to uninstall the fonts installed with the
script.
In fact the uninstall could already be acieved by giving the --clean
option and installing no new font. Well, apart from the fact that the
scripts prevents runs with no installed font. And then the user must
specify the same installpath that has been used for the install, which
is a bit tedious.
[how]
Add new command '--remove' (with no short option).
Make -L / --list option a dry-run option for --remove.
Uninstall both possible installpaths.
Fixes: #407
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
We have only 'Complete' in the repo anymore, so it does not make sense
to provide commands to select un-complete patched fonts.
[how]
Leave stub/comment in so that - if there ever is a need to resurrect the
feature - one can find this commit and the deleted code.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The script is not running with current (i.e. year 2022) release versions
of Inkscape.
The script does not warn if a font is not installed (and creates a
garbage preview instead).
[how]
Rewrite the script that is uses Inkscape actions instead of verbs. Verbs
are already removed in Inkscape HEAD.
Check if needed font is indeed installed.
Do not generate useless Symbols Only font preview (it needs a specific
different one, I suppose).
Disable `svgo`. Maybe we should generate PNGs instead?
Change path for created images, so that it is already correct for the
gh-pages and we could use the github-pages-deploy-action to publish them.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Some icons where added to Seti (number change).
Some numbers numbers where wrong.
Add new Codicons section.
Also add new instructions how to create.
Fixes: #846
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The script just creates the 'database' or the cheat sheet, but the
surrounding elements have to be added manually.
We do not like 'manually'.
[how]
Take the current cheat sheet code and rip top and bottom off, to glue it
to the generated 'database'.
Also change the filename like the final file would be named.
Well this is still not automated, but at least this is the first step in
that direction.
On the GH pages, there release and everyting is manual at the moment.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
We already have 2 data files to assemble the css file, and that clutters
the scripts/ directory; and there will come more for the cheat sheet.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The add-and-commit steps are so unbelievable slow.
[how]
We do not need the other tags, so we do not need a fetch before adding.
See comments on the action's homepage.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The generated file `nerd-fonts-generated.css` is made smaller with an
external service as manual step...
# [Nerd Fonts] The following is generated from the build script, then through https://www.minifier.org/
We do not want any manual steps.
[how]
Luckily the difference is just to remove whitespaces and unneeded
semicoli. We can do the same while generating.
[note]
At first I tried to postprocess the generated file with sed, but of
course the strings that have blanks in them made that rather
complicated.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The file that would be created in temp/ is probably not needed
There is a lot out noise
[how]
Create the txt file only if we already have a temp/ dir.
Make that clear in the final output message.
Remove debugging outputs.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Codicons is completely missing...
[how]
After creating a stub file for Codicons, use _their_ definition file:
curl -O https://raw.githubusercontent.com/microsoft/vscode-codicons/main/dist/codicon.csv
cat codicon.csv | tail -n +2 | sort -k 3 -t ',' | sed -E "s/([^,]*),([^,]*),(.*)/i='\2' i_cod_\1=\$i/" | tr '-' '_' >> i_cod.sh
Because they have new additional icons remove some lines in the bottom.
And add the final `unset i`.
I still have not figured out how the cheat sheet works and how we get
the data into that... There is a `generate-css.sh`. Hmm.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Sometimes the patched-in symbols are slightly too big, which shows up in
Nerd Font Mono fonts where the destination size is specified exactly.
That issues a warning like:
Warning: Scaled glyph U+F077 wider than one monospace width
[how]
For the scaleGlyph groups we need to combine the bounding boxes of
several symbol glyphs to determine the 'combined' scale we need.
Unfortunately when the concrete glyph is finally copied over its size
can change minimally.
So we need to measure the glyphs in the scaleGroup _after_ they have
been copied to the to-be-patched font. This is a bit complicated,
because we need to know some glyph slot we can use for that.
[note]
See also commit
e805b879 font-patcher: Resolve rounding error when rescaling
Fixes: #917
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Despite the fact that the workflow generates a new fontconfig, it is
never committed back to the repo.
[how]
As usual people rely on $PWD, which is not set in CI runs.
Use the subshell call $(pwd) instead, as that works always.
Reported-by: Sefa Eyeoglu <contact@scrumplex.net>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Some (the most basic) Families are not added.
[how]
The used shell array search is string based and can/will fail when we
search for a short string that is present in a array entry as substring.
Use explicit search instead.
[note]
Also remove some debugging output.
Fixes: #918
Reported-by: Sefa Eyeoglu <contact@scrumplex.net>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Table is still unsorted.
[how]
First we ran on '.', which includes all fonts, and then the font
directories one by one, but we have traversed them already ...
Do not run on '.' :-}
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Does not calculate the number of files:
find: ‘/home/runner/work/nerd-fonts/nerd-fonts/../../patched-fonts/*’: No such file or directory
[how]
Use $sd instead of $PWD
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
All error stream outputs of `font-patcher` are suppressed, because they
are very noisy and usually are ignored.
But when the patching fails for some reason we do not know why.
Especially if that happens during CI runs.
[how]
Instead of dropping the stderr we store it in an envvar; and output it
to stdout if patching failed.
`printf` is needed because `echo` is lousy with multiple lines.
Redirection magic:
https://stackoverflow.com/questions/962255/how-to-store-standard-error-in-a-variablehttps://stackoverflow.com/a/56577569
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Windows Compatible fonts have the same Family name, regardless if they
are "Nerd Font" or "Nerd Font Mono".
This creates problems for appliations that sort and select fonts by
Family name.
[how]
Just like "Nerd Font" is abbreviated as "NF" in the Windows Family names
(to keep it short because of the 31 character length limit), the
"Nerd Font Mono" are now called "NFM" instead of just (also) "NF".
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Another bugfix release to fix the regression introduced with 2.2.0
that is fixed by #764. Also note #900.
Some other smaller PRs also pulled.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Some symbol fonts might come with glyphs that have multiple codepoints.
When we want to patch them with `'Exact': true` (i.e. at their 'original'
codepoints) we want to patch them into the codepoint that has been used
in the selection process. That means between SymStart and SymEnd.
But this is not the case. We patch them in into their 'main' codepoint,
which can be outside the expected range of points.
This came up when patching with FontAwesome V6. It has for example these
glyphs:
Glyph 'music' has a main codepoint 0x1F3B5, but it is present in the
font also on codepoint 0xF001.
Glyph 'heard' has a main codepoint 0x1F9E1, but it is present in the
font also on codepoints 0x2665, 0x2764, 0xF004, 0xF08A, 0x1F499, ...
When doing a `'Exact': true` patch (i.e. exactEncoding = true) the
glyphs is patched into the target font at its (the glyph's) main
codepoint, regardless of our patch-codepoint-range.
[how]
We examine all codepoints that a glyph occupies in the symbol font. From
all these codepoints we take the nearest to the last glyph be patched
in. Nearest means from the possible codepoints the lowest that come
after the previous used codepoint.
For example the 'heard':
Last patched in codepoint was 0xF003.
Main codepoint: 0x1F9E1
Alternate codepoints: 0x2665, 0x2764, 0xF004, 0xF08A, 0x1F499, ...
-=> 0xF004
Later in the patching process we might encounter the same glyph again,
but this time the previous codepoint was 0xF089, so we need to take
0xF08A.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
When users just download the script (and not the source glyphs) the
script fails with an obscure error message.
[how]
Check if the glyphdir exists at all. If not give a hint to download the
glyphs.
Check if the individual glyph font exists and is readable. Bail out if
not.
[note]
Cherry picked, was part of #741
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
When one wants to use a custom symbol font and specifies it with an
absolute path, the glyphdir is still prepended.
That means that the argument to `--custom` is always used as relative
path (to `--glyphdir`), even when it starts with `/`. That is somehow
unexpected or at least inconvenient.
Example:
fontforge font-patcher --custom ~/Downloads/fa6.otf Inconsolata-Regular.otf
fa6.otf is searched for in ./src/glyphs/home/username/Downloads
[how]
Use Python function that handles joining path fragments. If a component is
an absolute path, all previous components are thrown away.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
I'm not sure why, but maybe the CI's Python is another version where the
syntax is not supported.
This has been introduced with commit
4a61afc83 font-patcher: Do not overwrite glyphs that are needed for basic glyphs
[how]
Use less sophisticated syntax.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Some glyphs that are tall and thin, are too big in the resulting patched
font, i.e. are higher than our 'line'.
At least for --mono fonts. The non-mono fonts do not rescale the
inserted glyphs at all, so there is no definition of 'too tall/wide'.
[how]
We want all glyphs to fit into the box defined by *_dim['height'] and
*_dim['widths'], as it also defines our powerline-glyph scaling and
horizontal and vertical advance widths.
So we need to take that value (instead of EM) for the scaling
calculation. The history of the use of EM here is a bit obscure, more
explanations in the PR.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Sometimes the basic glyphs ([a-zA-Z] etc) are constructed in the font
from other glyphs via references. To keep those basic glyphs intact we
must not touch the referenced glyphs.
[how]
Crate a list of all glyphs referenced by the basic glyphs.
When patching in some new symbol - if that codepoint is in the list do
not overwrite it. Overwriting would break a basic glyph.
The user does not get the glyph that we would have patched in, but that
can not be helped if we want to keep the basic glyphs intact and not
'redesign' the complete font.
Fixes: #400
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>