[why]
When the file specified to be patched is not a font file the patcher run
errors out with an out of index runtime error:
Traceback (most recent call last):
File "/home/fini/extra/git/nerd-fonts/font-patcher", line 2155, in <module>
main()
File "/home/fini/extra/git/nerd-fonts/font-patcher", line 2147, in main
patcher.generate(sourceFonts)
File "/home/fini/extra/git/nerd-fonts/font-patcher", line 415, in generate
sourceFont = sourceFonts[0]
~~~~~~~~~~~^^^
IndexError: list index out of range
[how]
Do not assume that the specified file will be a font file but rather
check if fontforge detects a font in the file and error out if there is
no font found.
Fixes: #1647
Reported-by: Kristopher James Kent <kris@kjkent.dev>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Some strings have broken format, because the string should contain a
verbatim backslash.
It seems this is a new warning for Python 3.12
[how]
Use raw strings or escape the escape character via '\\'
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The logging to files does not work correctly for the messages given
while the options themselves are parsed.
[how]
As soon as we have enough information (after the first argument parsing)
we set the logger up. When processing the config file arguments we have
a full functioning logger now.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
We now have two places where we can detect if a config file is given.
This should be unified.
Also handling of missing (?) sections in the config file is not always
handled gracefully.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Some Caskaydia Cove glyphs that are used in ligatures (to create endless
arrows for example) show uneven line thickness on some platforms.
The reason is the not-matching hinting of glyphs that are places next
to each other and so minuscule differences are quite visible.
Note that the 'original' hinting is generated by VTT on the static
Cascadia Code instances, which upstream just have ttfautohint hints that
are different from the hints in the variable fonts and people complained
that the look is different.
[how]
Add a new field to the config.cfg file that holds regexes of glyph
names for glyphs that should be re-hinted by fontforge on patching time.
In principle we could also implement that as an additional pre-step that
needs to be manually done after running VTT on the static font files.
I'm not sure which is better.
Note that fontforge generates a lot of debug output because the hinting
is not ideal - the global tables are kept and probably less compatible
to fontforge's own hinting... But the results are good.
Fixes: #1291Fixes: #1609
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The config files are called `config.json` while the contents is
INI-like. The usual extension would be `.cfg`.
[how]
We use `.cfg` already for the shell variable configuration.
Combine both config file variants into one (real) cfg file, that is
directly read by the font-patcher and no shell variables files are used
anymore.
This needs some rewrite in gotta-patch-em to get the quoting right.
To make this simpler we remove the `--debug 1` option from the variable
and insert it directly (as it is applied always anyhow).
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
At the moment we have two different config files:
config.cfg:
Is read by gotta-patch-em and allows to specify some needed
commandline options for a font-patcher run
config.json:
Is read by font-patcher and can contain ligature table removal
instructions
It would be nice to combine/unify them.
[how]
Add the possibility to add commandline options in the config.cfg
file. Of course we need commandline options to specify the config
file first, so the options are parsed in two steps.
The config.file takes precedence (if possible) over directly specified
options.
This is how the new section in the config file can look like:
[Config]
commandline: --powerlineextra --mono
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
We have two ranges of glyphs to examine:
1. `0x0000`-`0x017f` is the Latin Extended-A range
2. `0xfb00`-`0xfb06` are 'fi' and other ligatures
Both ranges are added to the essential glyphs (with their
sub-references, and with other glyphs that are referenced through
possub rules).
That is correct for range 1, but range 2 - the ligature glyphs - should
only become essential if they are indeed used for ligatures by some
rule.
For example with the UbuntuMono font, that does not have any fi ligature
natively, but it DOES have a filled `0xFB01` glyph, we would protect
that glyph and its subreferences (i.e. `0xF001`) - needlessly breaking
the Font Awesome icons in that font.
[how]
Add all glyphs of range 1 to the essential glyphs, but add glyphs of
range 2 only if they have a possub rule attached.
Reported-by: Eli Array Minkoff <eli@planetminkoff.com>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The essential glyphs are partially based on which substitution rules
the font has.
And the config.json configuration is able to remove some substitution
rules.
So we must first possibly remove rules and then examine them, not the
other way around, because now we detect 'essential glyphs' for rules
that we later remove.
[how]
Correct order of operation.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This does not pull in all icons of 6.5.1, but only of
'Region A' and 'Region B', see script `remix` and
PR #1563.
It keeps the codepoints constant for existing icons.
Fixes: #1550
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Very slender and tall icons will be scaled huge compared to their fatter
neighbors. This happens for example to the chess pieces (E25F ff) or
text style icons like italic (EB0D).
[how]
When a monospaced font is created use a slightly less tall cell height
for all icons (except icons that have to match the actual line height).
This can be prevented by the new scale control character `^` that
symbolizes maximized vertical size (height) within the real cell.
The smaller cell (now called icon cell) is less tall than the line
height, but higher than the cap height of the font; to prevent people
complaining that the icons shrunk too much.
It is about 1/3 higher than the cap height compared to the line height.
This is NOT applied to the other Nerd Fonts fonts variants (i.e. Regular
and Propo) because all icons are generally a bit bigger than the cap
height (no scaling down to fit into one advance width) and as the
scaling is far less pronounced the slender-and-tall icons scale
comparably and do not look out off place there.
Suggested-by: Aaron Bell @aaronbell
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
We still fight with the faint lines on the big side of the powerline
glyphs. They come from the LCD antialiasing mode that has problems with
the borders.
Other fonts use far more overlap. We use only a modest amount of overlap
(1% of the width).
[how]
As the other fonts do, increase the overlap (to 6% now).
Add full-hight 'landing platforms' on the outsides of the glyphs,
which are 7% wide.
Related: a8b9e1da06
Related: #1245Fixes: #1547
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
This sets out to circumvent a problem with VisualStudio 2022. That
application seems to have problems with fonts when the ID16 is not a
prefix in ID1.
We have this when --makegroups >= 4, because
ID1 has the short name suffix 'NF'
ID16 has the long suffix 'Nerd Font'
These fonts can be selected in VisualStudio 2022, and the preview works
ok, but once active some replacement default font is used instead.
The problem vanishes if ID16 and ID1 have the same stem, or rather ID1
has someting added on top of ID16; but ID16 is a substring of ID1.
See more discussions in #1442
[how]
Write both forms in ID16 fields, 'NF' and 'Nerd Font' suffixes. This
works as long as the application considers all languages equal.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Forgot to increase with commit 136a84bc03.
Now we also have different original icons, lets have a new number.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The Octicon scaling group has two errors, one is a typo (the first digit
of a number is missing), and the second is off by one for some reason.
Reported-by: @aaronbell
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The format string is invalid and results in a runtime error if that
particular warning is issued (which is only the case for Terminus).
[how]
A verbatim percent sign must be encoded as '%%'.
[note]
This has already been fixed before with commit
f81564fad font-patcher: Fix typo in logger output
but the change has been lost by rebasing :-(
See also #1350
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The D2Coding font has a lot of glyphs shared between multiple unicode
codepoints.
Usually we just want to change the glyph on one particular codepoint
and not on all linked ones; which will affect codepoints not in our
patching ranges.
For example the glyph FULL BLOCK is used by codepoint 2588 and E286. In
the Exxx range they have a lot of icons, and also a full block.
[how]
Remove all links on glyphs that we are about to patch over, so that we
really just patch the codepoint we want to patch (and have no hidden
'links').
[note]
This could in principle break alts or ligs if they rely on another
codepoint that we removed. But breaking ligs is always a possibility
when patching over existing glyphs.
[note]
I checked several (not all) fonts in our repertoire, and only D2coding
is massively affected.
The only other fonts are these with 2 codepoints each:
heavy_data.ttf Removing alternate unicode on F001 (FB01)
heavy_data.ttf Removing alternate unicode on F002 (FB02)
Tinos-Regular.ttf Removing alternate unicode on F001 (FB01)
Tinos-Regular.ttf Removing alternate unicode on F002 (FB02)
Fixes: 1454
Reported-by: @hdd1013
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
When we can not detect the cell width, for example because there are no
glyphs in the range of extrended-roman that we examine, the width will
be zero and that will result in a crash later on (on rescaling).
[how]
Just abort if height or width are zero or negative.
Related: #1460
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
When shortening the rare gases names to the element symbol
Radon is named 'Rd' while it should be 'Rn'.
Atomic number 86 on the periodic table.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The font-logos project has been updated including 67 new icons, in which
are included GNU/Linux distributions, desktop environments, window
managers, desktop applications, some organizations and more.
Now the used range is F300-F372, 115 available logos.
[why]
We still fight with the faint lines on the big side of the powerline
glyphs. They come from the LCD antialiasing mode that has problems with
the borders.
Other fonts use far more overlap. We use only a modest amount of overlap
(2% of the width).
[how]
As the other fonts do, increase the overlap (to 7% now). We could not do
that before, because we had no full-hight 'landing platforms' on the
outsides and so the triangle would look cut off at not 100% hight.
Now with the landing platforms we can increase the overlap and still
have nice looking triangles that visibly reach the top and bottom of the
line.
Implement this only for the filled triangles to see how it goes.
Related: #1245
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
It is better to have a not-abbreviated file name so that one can make
sense out of the name parts, especially when doing a partial patch.
With the previous commit we ended up with all abbreviated names.
The filename length is hopefully not limited, at least not as severe as
the SFNT table entries.
[how]
We need to store the answers somewhere because the naming is only
understood by the FontnameParser object which we throw away soon.
As fallback we still can parse the SFNT table, for example when the old
renaming is used.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
With Martian Mono we have a font that uses aggressive abbreviation for
the weights and styles (two letters mostly) in all name fields. That is
very hard to parse.
[how]
Adding rules that detect these very short abbreviations might trigger in
a lot wrong places. As this is the only font that uses that we do not
want to risk that.
Instead we rewrite the filenames of the source font (Martian Mono) such
that it contains all the necessary information and add a new flag to the
patcher that allows it to use the filename as naming source.
Yes, as in days long past ;-)
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
After a new icon has been added to the core set we want to make that
visible via a new version number.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
It is rather confusing to have so many aliases.
[how]
Remove some long forms and some alternatives, to make the help page
easier to read.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
It can be hard to find the 'usual' options in between all the expert
options.
[how]
Regroup the options and sort them alphabetically (most of the time).
Not sure if this helps, but in my personal view this makes it easier.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
When the original font designer's idea of cell height differs from the
height we deduce the box drawing glyphs come out with the wrong size (if
we do not touch them, for example because the font already has a
complete set).
[how]
Add option that enforces patch-in of the box set.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
If the font has contradicting baseline to baseline metrics the patcher
tries to find a sane value and use that. That automatism gets it right
in most cases, but there might be fonts where the user wants a different
metric to be used.
At the moment the use would need to use `font-line` to adjust the
metrics, which is not very convenient.
[how]
Add option to select one of the metricses.
Use that metrics when setting up the patched font.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
When the font does not have a PSweight string the font-patcher bugs.
[how]
Rewrite the code to be more robust against unexpected weight values.
Also make detected problems non-fatal.
Reported-by: František Hanzlík <frantisek_hanzlik@protonmail.com>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Windows seems to construct the font names including the PS weight.
We have some sourcefonts that are broken (i.e. have in fact different
weights but have the same PS weight and/or OS2 weight.
That raises problems with the fonts on Windows.
[how]
Check and compare all weight metadata (except CID) and issue a warning
if they differ too much. That might fail with unusual weight names,
though.
See Issue #1333 and PR #1358.
Reported-by: LeoniePhiline
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>