Commit graph

1494 commits

Author SHA1 Message Date
Fini Jastrow
1b8c9e2768 font-patcher: Pull out opening and generating the font
[why]
These operations are also not strictly patching.
When we want to handle more than one font we need to have this outside
the patch() function.

[how]
Put opening and exporting (previously in __init__() and patch() into
main() outside the patcher object.

No functional change (except the sourceFont is now closed :->)

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-22 19:02:47 +02:00
Fini Jastrow
2432a5700a font-patcher: Handle argument checks with arguments
[why]
The extension handling is a bit out-of-place and could be handled by the
arguments handling, which simplifies the code.
Somes goes for other argument validity checks.

[how]
Put argument checks into setup_arguments().

Dropping self.extensions in favour of self.args.extensions.

No functional change.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-22 19:02:47 +02:00
Fini Jastrow
ec4cb0a8c5 font-patcher: Pull argument parser out of patcher object
[why]
Parsing the command line arguments has nothing to do with the actual
patching.
If we want to patch more than one font we need to separate the partching
from unrelated work.

[how]
Just do the argument processing in main() and hand the information over
to the patcher object.

[note]
No functional change. Lines copied over (almost *) 1:1.

(*) Exceptions:
self.sym_font_args is now only a local variable, as it is only used in
this one function.
The startup message is shown on ... startup (i.e. main()).

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-22 19:02:47 +02:00
Finii
0197629d4b [ci] Rebuild original-source font 2022-09-22 18:24:58 +02:00
Fini Jastrow
bcc80b4077 Update orgmode glyph
[why]
The glyph is needlessly detailed (for a font).
There is another, more simple glyph, which is also used by fileicons.

More details see PR #833.

Reported-by: tecosaur <contact@tecosaur.net>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-22 18:24:58 +02:00
Fini Jastrow
12cd703e39 Fix Hasklug ligature removal
[why]
Entering two consecutive vertical-bars (i.e. `||`) results in the
display of just one - the right - bar glyph.

[how]
The ligature removal is only partially implemented. The rule at work
here is not removed. There are two parts at work:

One rule to replace the first bar with nothing.

One rule to replace the second bar with a ligarture glyph with negative
left bearing, that shows two bars.

The second rule has been removed, but the first is still there.
This commit also removes the first rule.

[note]
The whole design here is broken. We remove only some rules and leave
others intact, for reasons unknown to me. Other ligartures will also be
only partially removed and leave the user with unreadable output.

We should either remove all (!) tables and not just some, or leave the
ligatures in the font.

As the ligature removal has been broken at large anyhow (see previous
commit), I would suggest to not remove any ligatures (anymore).

Fixes: #934

Reported-by: Rádler Ákos <akos.radler@gmail.com>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-22 17:46:55 +02:00
Fini Jastrow
5d218b1cd3 font-patcher: Fix ligature removal
[why]
Only one tables is removed, even if we want to remove more.

With 0a480bb the indentation of the code has changed, and now the loop
is (apart from printing) empty. See also #934

[how]
Re-indent the lines to restore functionality as originally forseen with
commit 557fc00.

Reported-by: Rádler Ákos <akos.radler@gmail.com>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-22 17:46:55 +02:00
Fini
46a7c03ced
Merge pull request #931 from ryanoasis/feature/autogenerate-original
Autogenerate original-source glyph font
2022-09-21 14:09:00 +02:00
Finii
99f65e19b0 [ci] Rebuild original-source font 2022-09-21 12:00:37 +00:00
Finii
2c7fb2fd2d [ci] Simplify original-source source glyphs 2022-09-21 12:00:35 +00:00
Fini Jastrow
b255bc1d71 Update documentation 2022-09-21 13:54:42 +02:00
Fini Jastrow
3fd15de2a3 CI: Try to commit changes only if we optimized some svgs
[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>
2022-09-21 13:47:41 +02:00
Fini Jastrow
eca92e3bd9 Simplify PHP glyph
[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>
2022-09-21 10:31:41 +02:00
Fini Jastrow
725344def5 CI: Fix unneeded font rebuild commits
[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>
2022-09-21 10:29:15 +02:00
Fini Jastrow
cc2b547703 generate-original-source: Remove FFTM table
[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>
2022-09-20 10:23:05 +02:00
Fini Jastrow
73ae4a96b4 CI: Optimize original glyph svgs
[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>
2022-09-19 16:08:22 +02:00
Fini Jastrow
acafd63619 CI: Add workflow for source font generator
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-19 15:55:01 +02:00
Fini Jastrow
328b8a2d22 Add original-source.otf generator script
[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>
2022-09-19 12:02:24 +02:00
Fini Jastrow
5a9b44749f Add documentation to bin/scripts/ directory
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-16 11:18:48 +02:00
Fini Jastrow
993730682a Fix i_cod.sh docu
[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>
2022-09-16 10:57:58 +02:00
Fini Jastrow
a07648b1ee install.sh: Add uninstall command
[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>
2022-09-14 12:33:07 +02:00
Fini Jastrow
533e1a2df4 install.sh: Remove patch-selecting options
[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>
2022-09-14 12:33:07 +02:00
Fini Jastrow
3444b5755f generate-font-image-previews: Fix and Refactor [skip-ci]
[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>
2022-09-13 12:13:16 +02:00
Fini Jastrow
fae0b4cb16 Update all readmes to 2.2.2
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-13 08:35:20 +02:00
Fini Jastrow
92fbcdb143 Rename 'Font Linux' to 'Font Logos'
[why]
The glyphs set's name changed, we should reflect that.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-13 08:05:14 +02:00
Fini
d45a9b29c2
Correct sankey instructions formatting 2022-09-12 17:43:00 +02:00
Fini Jastrow
6a8dc7d50a Update sankey diagram
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>
2022-09-12 17:06:02 +02:00
Fini Jastrow
a67edd47dd generate-css: Generate full cheat sheet file [skip ci]
[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>
2022-09-11 19:56:37 +02:00
Fini Jastrow
018f006a6d generate-css: Move data files into subdir
[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>
2022-09-11 18:23:02 +02:00
Fini Jastrow
eef02c07b6 [ci] Regenerate CSS files [skip ci] 2022-09-11 17:47:06 +02:00
Fini Jastrow
27225ac14a generate-css: Fix font name
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-11 17:46:18 +02:00
Finii
3a1d3ee5b3 [ci] Regenerate CSS files 2022-09-11 16:41:12 +02:00
Fini Jastrow
50657caa63 CI: Do not fetch on add-and-commit
[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>
2022-09-11 16:41:12 +02:00
Fini Jastrow
134c518892 CI: Generate CSS and push to repo and gh-pages
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-11 16:41:12 +02:00
Fini Jastrow
41e0b16a4d generate-css: Do not rely on external minimalizer
[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>
2022-09-11 16:41:12 +02:00
Fini Jastrow
61f59453f6 generate-css: Prepare for CI usage
[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>
2022-09-11 16:41:12 +02:00
Fini Jastrow
ef8c12e285 Document and update cheat sheet data
[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>
2022-09-11 16:41:12 +02:00
Fini Jastrow
76cb86f66f Add query_mono debugging script
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-11 16:41:12 +02:00
Fini Jastrow
983226a70e font-patcher: Fix scaleGlyph related rounding error
[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>
2022-09-08 20:08:44 +02:00
Fini Jastrow
67aa453436 Update fontconfig
[why]
Has not been updated in the last release CI run.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-08 15:44:32 +02:00
Fini Jastrow
487fc793bc CI: Fix fontconfig creation
[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>
2022-09-08 15:44:32 +02:00
Fini Jastrow
bdc28aa88f generate-fontconfig: Create entries for all encountered families
[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>
2022-09-08 15:44:32 +02:00
Fini Jastrow
629b29507d generate-fontconfig: Fix sorted config
[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>
2022-09-08 15:44:32 +02:00
Finii
5454877c01 [ci] Rebuilds patched fonts 2022-09-07 15:57:31 +00:00
Fini Jastrow
d58fa371fe patch-em-all: Fix counting font files
[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>
2022-09-07 13:39:10 +02:00
Fini Jastrow
26d656fcaa patch-em-all: Fix postprocess with AppImage-fontforge
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-07 13:27:18 +02:00
Fini Jastrow
ef1f35368e patch-em-all: Display error messages if patching fails
[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-variable
https://stackoverflow.com/a/56577569

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-07 13:08:07 +02:00
Finii
aaf2dafda4 [ci] Rebuilds patched fonts 2022-09-07 08:09:42 +00:00
Finii
9c950dc385 [ci] Bump release version 2022-09-07 08:05:53 +00:00
Fini Jastrow
a6e6ee26d8 font-patcher: Correct Family for Mono Windows
[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>
2022-09-07 06:58:21 +02:00