[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>
[why]
Under certain circumjstances Fontforge can not create a font. As the API
does not give any feedback we trudge along afterwards giving confusing
messages.
One example is when the patched font contains too many glyphs.
[how]
Check if the patched font has indeed been generated and is not empty.
Fixes: #1342
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
If a user specified a name we should probably not camel-casify it.
Fixes (idea mentioned in): #1319
Suggested-by: HUMORCE
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
In the post we used these information sources to determine the name and
weights/styles of the to-be-patched font:
* The filename
* The fullname (ID 4)
* The postscriptname (ID 6)
Usually it is best to use the Fullname of a font to determine its real
name and styles/weights:
The Postscript name has the advantage to have a hyphen between name and
styles/weight; but as it can not contain blanks the correct name can not
be determined by this. To get the styles/weights back we use a list of
all possible (?!) weights and styles and sort all the string parts.
This works reasonably well and the fullname is usually best.
Not so with Input Mono Condensed. Here are its names:
ID4: "InputMonoCondensed LightIta"
IF6: "InputMonoConsensed-LightItalic"
[how]
Add option to select between fullname and postscriptname as font naming
source.
For special purposes, also allow a custom (arbitrary) name input.
If that is given the specified name will be used to name the patched
font without adding any suffix - the user has full control on the name.
Fixes: #1314
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
A lot arguments need one user supplied value, but that is not enforced.
For example
font-patcher src/unpatched-fonts/Agave/Agave-Regular.ttf --out
results in a crash, because the needed output directory has not been
passed, but the default is also not used.
The problem is that the option is defined to take any amount of values,
includeing zero values (and more than one value).
That all does not make sense. The switch does need exactly one value.
[how]
Remove the wrong nargs specification. Instead use the default, which is
'expect one value' for the default action 'store'.
Instead of a crash the user is now presented with this output:
font-patcher: error: argument -out/--outputdir: expected one argument
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The debug messages appear two times.
[how]
Do not use the root logger as we can not get rid of it afterwards.
Instead set up a normal logger just for the startup and forget it after
we have a proper logger.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Usually the variable `logger` holds the logger object and all logging
calls got through that.
But because we use the font filename as loggername that logger object
can only be set up after the arguments have been parsed. If some
messages are to be logged before the call needs to go to the root logger
called as `logging` class.
This means one needs to take `logger` or `logging` based on the time
when someting is to be logged. That can be confusing and is easily
wrong, especially if code is shifted.
[how]
Always use the `logger` variable and just let that point to the root
logger until we set up a concrete logger.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Sometimes a user might want to keep the original name.
This is escpecially true as Visual Studio seems to look at the font
names directly and enables special handling for 'Cascadia Code'.
Users might want to self-patch without renaming.
[how]
Add additional value to makegroups option.
That option should probably be renamed into 'naming scheme' or
something, as it is not really a fitting description of what it does.
Fixes: #1242 (some aspect of it)
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
When we did not collect xavgwidth data for some font and want to tweak
it the font-patcher crashes.
[how]
Check if we have a number before accessing it in the array.
[note]
This happens when font_patcher.patch() has not been called.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
For tweaking we use the self.sourceFont, but in the loop the real
correct value is the local sourceFont. Usually it's the same, but from a
logical standpoint this is wrong.
The name is a bit unfortunate and C++ would have generated a warning.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The font_patcher object should be self contained, and code outside of it
should not depend on stuff done within it that does not have to do
anything with patching.
In fact the code should run even if font_patcher.patch() has not been
called.
[how]
Pull name backup out of the patching process.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
See PR #1261 for details on the reasons.
This mostly reverts commit
f84a4a46d font-patcher: Add Codicons scale list
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Codicons: Maximise all circles
[why]
The scaling works okay for `Nerd Font Mono` fonts, but not for `Nerd Font`
fonts. The later have 'unexpected' left side bearing, which looks even
more out of place because the width is unrelated to the advance width
and might place the majority of the glyph into the next cell.
[how]
In fact we do not want scaling and shifting to be uniform for all glyphs
but the intend was to get the scaling from the biggest (full size)
circle and all the smaller ones would be proportionally smaller.
So we add a new Scale grouping that just takes the scale and the
vertical shift of the combined boundingbox, but individually calculates
the horizontal shift.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Patching CartographCF-Bold.ttf creates this naming:
Family (ID 1) : CartographF Nerd Font Condensed
SubFamily (ID 2) : Bold
Fullname (ID 4) : CartographF Nerd Font Condensed Bold
PSN (ID 6) : CartographFNF-CondensedBold
PrefFamily (ID 16) : CartographF Nerd Font
PrefStyles (ID 17) : Condensed Bold
CartographF Nerd Font Condensed Bold
\===> 'CartographFNerdFont-CondensedBold.ttf'
[how]
The font-patcher historically used the file name of the to-be-patched
font to come up with the new name. When the FontnameParser has been
developed that mechanics has been copied at least for fallback. The
earliest tests compared old and new naming with all the filenames.
Later, when the FontnameParser has been used to really apply name
changes it has always based the parsing on the Fullname or the PSname,
because they really hold the information (or at least should hold);
while the filename might be completely random.
Still code the dealt with specific problems in FILEnames prevailed. The
Ubuntu font for example has a file name like 'Ubuntu-C.ttf', and we
needed to convert the C to Condensed.
As that requirement vanished we can drop all the code that has been
added specifically only for parsing the Ubuntu font filenames.
Side note: USUALLY font filenames should be roughly equal to the PSname.
Fixes: #1258
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The order in which the advance widths are reported is rather misleading.
It also does not differentiate properly between basic and extended latin
range.
[how]
Reorder advance width details in output.
Change log entries to one-liners.
Also report monospaced and final cell size result.
[note]
No functional change.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
For fonts that have no Italic but an Oblique - i.e. when Oblique shall
replace the Italic role in RIBBI font grouping (classic group of 4) -
that grouping fails.
This affects DejaVu on Putty.
[how]
For RIBBI grouping only the classic bits are considered. That means that
for fonts that have Oblique instead of Italic (and not additionally) we
need to set the ITALIC bit and the OBLIQUE bit. This has been
overlooked.
Cite from the specs:
> This bit, unlike the ITALIC bit (bit 0), is not related to style-linking
> in applications that assume a four-member font-family model comprised
> of regular, italic, bold and bold italic. It may be set or unset
> independently of the ITALIC bit. In most cases, if OBLIQUE is set, then
> ITALIC will also be set, though this is not required.
[note]
Also increase font-patcher version.
Fixes: #1249
Reported-by: Huifeng Shen <liaoya@gmail.com>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Although DaddyTimeMono is monospaced it has one glyph (napostrophe at
0x149) that is in fact two spaces wide. This breaks the created Nerd
Font Mono font.
[how]
Add that glyph to the list of non-standard glyphs that are ignored.
Fixes: #1243
Reported-by: fabestah
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The codicons have 3 obvious (from the name) pairs of regular and small
icons. The size difference is slight but visible.
When we maximize all individual icons the differences are mostly lost.
[how]
Put each pair into one ScaleGroup to keep their individual scaling.
Fixes: #1214
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The added heavy brackets are maximized within the cell size as all
normal other symbols. But in fact they should not be maximized but
rather be the size of 'normal brackets'.
Furthermore they are all scaled individually, making the size
differences less.
With some proportional fonts the brackets look tiny.
[how]
Introduce new y-padding parameter (because a negative overlap also acts
in x direction, what we do not want (and it distorts)).
Pad the brackets with 30% (15% top and 15% bottom).
This is used for all fonts (monospaced or not) so that the new glyphs
fit nicely with the existing ones. For some definitions of 'nicely', but
that is as good as we can get with automatism. It's not worse than
font-fallback.
Fixes: #1229
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
When the Heavy Brackets are scaled we want them to be scaled according
to 'pa1!' (i.a. preserve-aspect, only-one-cell, scale-always).
This is not possible because the glyphs have a ScaleRule and that
always assumes pure 'pa' and nothing else.
[how]
When the first glyph of the group is encountered the group scaling is
determined. This now takes the stretch rule of THAT glyph (instead of
just 'pa') to prepare the scale of the complete group.
[why]
With Ubuntu-Regular the fi and fl ligatures are replaced by some font
awesome icons.
The problem is that the font uses the non-standard F001 and F002
codepoints as intermediate referencve to create the actual ligatures
that are at codepoints FB01 to FB04.
[how]
All the normal ligature codepoints (FB00-FB06) are added to the glyph
reference checker and codepoints that are referenced by these are not
patched.
This means that F001 and F002 stay on the original ligatures and the
Font Awesome icons are missing, but this can not be fixed automatically
and would need to 'rewrite' the references inside the font.
Fixes: #1221
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Some people, for example the `lsd` project, need an icon with a symlink
directory. That has been dropped by Octicons. Our repacking put some
unrelated bookmark icon on that codepoint; but even an empty glyph would
be not ideal.
[how]
Design a file-symlink-directory from file-symlink-file and
file-directory. In this way it fits nicely into the current design of
Octicons.
Sneak that into the unpacked Octicons archive.
Adapt mapping manually to keep as much as possible constant.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
While the commit
7cda32651 font-patcher: Allow to specify custom symbolfont with absolute path
would have allowed to specify the custom glyph font with an absolute
path, it is in fact still not possible.
[how]
The file-exists checks also need to observe the absolute path.
[note]
Normally (with a relative path) the custom font is search for in the
ordinary glyphs directory - but that would mean people need to copy it
there.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
When a user want to patch some glyph in, and at that position is already
a glyph, there is no way to overwrite it.
The reason is that --custom glyphs are always patched in --careful, and
there is no --not-careful option to override that.
[how]
Add glyphs via --custom always, except --careful has also been given.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
If you add a custom icon it probably has to fit with the rest of the
font. So why should we patch it in completely unscaled?
[how]
Just scale the custom icon like all other icons at least.
If someone wants to add just a symbol or two and keep the glyphs exactly
(more or less) unscaled there are simpler ways than this patcher
script. I believe persons that are able to pre-scale the custom font are
also able to just patch it in. So this option is more for the generic
patching of extra glyphs but they need to be scaled somehow.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The Box Drawing glyphs need to be carefully scaled. This can not be done
if the glyphs are pulled in via font-fallback I guess.
As people may have the fontconfig set up in a way to prefer the Symbols
Only font these glyphs could overrule other box drawing glyphs that
might fit better.
I'm not really sure about this one, but the glyphs look rather bad
anyhow, because they end up in the 1:1 ascpect ratio cell of the Symbols
Only font.
[how]
Just turn the set off if we patch the Symbols Only font.
Need to swap around two subroutine calls for that; first detect if we
are patching the Symbols Only font (through the font metrics) and then
set the patch sets up.
Fixes: #1210
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Maybe it is not a good idea to always create the log file, as most
people will never look into it. The main reason for it was the
gotta-patch-em script so that one can check after lots of runs what the
details were.
[how]
Introduce parameter to --debug option.
0 = no debug output
1 = log to file only (previously always selected)
2 = log to stdout only
3 = log to file and stdout (previous default for --debug)
Just specifying --default equals now --debug 2.
The gotta-patch-em runs now with --debug 1.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
When font-patcher is on a read only filesystem the pacher can not run.
This is for example the case when fontforge is a AppImage.
[how]
Try if the logfile can be written, and if not disable logging into a
file.
Reported-by: Bliss X. Xu <blissLove8@gmail.com>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The scale glyph is not the biggest glyph; the bell-slash is a little bit
wider than the design cell...
[how]
Switch to modern ScaleGroups. These determine the virtual combined
bounding box of all glyphs in the group and scale them 'as one'.
Also add some more groups.
Also correct wrong code of one small stuff.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
With the Octicons update some codepoint contents changed.
Also some symbols scale still wrong.
[how]
Check fonts and add / drop entries.
Use GlyphsToScale+ to correct position of Github text icon.
Fixes: #1198
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
On some fonts the patcher tries to raise a warning, but it can not.
[how]
The 'overlap' variable can hold a floating point number or be None (if
there shall be no overlap processing. Formerly we output that value
using the {} format, but the logging module does not have that. To
accomodate to different types use repr() instead.
[note]
Also improve some other logging related calls.
Reported-by: Jim Myhrberg <contact@jimeh.me>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Some sourcefonts, even that are monospaced, have a `fi` and/or `fl`
ligature that maps into one cell. That looks very strange.
[how]
Partially revert commit
148b0c445 Sunset ligature removal
for the cases that have a one-cell `fi`, `fl`, etc ligature, or a `ldot`
related ligature - that is active by default. Discretionary ligatures or
Stylistic Sets are not changed.
Do the removal on all patched fonts for consistency, not just `Nerd Font Mono`.
[note]
On Noto different subtables are needed for Sans, Serif and Sans-Mono. We
can not set up different configs for each, so all are tried in all fonts
and might fail (this is normal).
Same holds for OpenDyslexic Alta, Regular, Mono, Bold...
Fixes: #1187
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This reverts commit 621008773c,
and adapts the code to more recent changes (logging, enums).
[why]
Lekton has a too wide line spacing.
Lekton was the only font that selected TYPO but we forced it to WIN,
because not all glyphs fit into the values from TYPO.
But that seems to be wrong. Examining the glyphs that are really bigger
than the TYPO line spaces, these are only graphical glyphs that shall
span multiple lines. So I guess we should revert that change and render
Lekton with the TYPO values.
[note]
https://github.com/ryanoasis/nerd-fonts/issues/1056#issuecomment-1529141863
[why]
The intend was to drop 'Sans Mono' in the renaming process, because the
name is just too long.
ERROR: VeraMono-Italic.ttf ====-< Shortening too long PS family name: BitstromWeraSansM Nerd Font Mono -> BitstromWeraSansM Nerd Font Mon
ERROR: VeraMono-Italic.ttf ====-< Family (ID 1) too long (32 > 31): BitstromWeraSansM Nerd Font Mono
[how]
Include the whole name in the replacement pattern.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The license of Bitstream Vera requires patched fonts to contain neither
"Bitstream" nor "Vera" in the name. It explicitly requires that also
for fonts that (only) add some glyphs.
Yes, we are rather late to notice this :-( Sorry.
[how]
Rename Bitstream Vera to BitstromWera, and also drop the Sans Mono part
of the name. The new name looks and sounds similar enough to get the
reference, while being shorter and somewhat logical.
Fixes: #1173
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The old MDI are kept, just disabled. Maybe we need them or someone else,
for backward compatibility. Can be dropped sometime in the future.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>