Commit graph

500 commits

Author SHA1 Message Date
Fini Jastrow
3053972f86 font-patcher: Abort if fontforge did not generate patched font
[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>
2023-09-23 11:25:11 +02:00
Fini Jastrow
f81564fadf font-patcher: Fix typo in logger output
Fixes: #1350

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-09-18 11:12:35 +02:00
Dennis Prazak
5d85a45a93 Add Intel One Mono 2023-07-26 15:02:27 +02:00
Fini Jastrow
12b51f51e2 font-patcher: Allow blanks in '--name'
[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>
2023-07-19 11:41:03 +02:00
Fini Jastrow
64cf3e9d93 font-patcher: Add option to select postscript name as name source
[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>
2023-07-17 11:58:21 +02:00
Fini Jastrow
2f5c6ab6c6 font-patcher: Correct --makegroups help
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-07-17 11:58:21 +02:00
Fini Jastrow
98c14701b0 font-patcher: Fix command line argument specs
[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>
2023-07-17 11:58:21 +02:00
Fini Jastrow
12bf79d5fe font-patcher: Fix unify logging calls [skip ci]
[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>
2023-06-14 08:39:14 +02:00
Fini Jastrow
df626d3440 font-patcher: Unify logging calls [skip ci]
[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>
2023-06-06 08:31:57 +02:00
lolicon0930
d3856031c8 Fix typo in font-patcher. 2023-06-06 08:31:57 +02:00
Finii
ef6fe05754 [ci] Bump release version 2023-06-04 20:32:30 +00:00
Fini Jastrow
8fc3a7c15a font-patcher: Add option to suppress renaming
[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>
2023-06-04 13:24:52 +02:00
Fini Jastrow
decb6d0e3d font-patcher: Fix crash when no xavgwidth data available
[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>
2023-06-04 13:24:52 +02:00
Fini Jastrow
7a31c67670 font-patcher: Fix wrong data source
[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>
2023-06-04 13:24:52 +02:00
Fini Jastrow
3ecf7f1ef8 font-patcher: Fix incomplete separation of naming and patching
[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>
2023-06-04 13:24:52 +02:00
Fini Jastrow
f3f8da13b7 Revert "font-patcher: Add ScaleGroupVert"
This reverts commit fcf5c84200.

[why]
There is no current usecase for the ScaleGroupVert.
2023-05-30 22:02:06 +02:00
Fini Jastrow
c8dd880154 Codicons: Revert to no Scale grouping
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>
2023-05-30 22:00:19 +02:00
Fini Jastrow
fcf5c84200 font-patcher: Add ScaleGroupVert
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>
2023-05-30 21:35:07 +02:00
Fini Jastrow
b0e5a35477 name-parser: Remove filename parsing code
[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>
2023-05-26 13:01:58 +02:00
Fini Jastrow
1050729d6b font-patcher: Improve some debug messages [skip ci]
[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>
2023-05-24 13:02:38 +02:00
Fini Jastrow
438843d57a FontnameParser: Fix fsSelection for --has-no-italic
[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>
2023-05-22 13:32:11 +02:00
Fini Jastrow
6903e2f393 font-patcher: Fix DaddyTimeMono NFM
[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>
2023-05-22 13:30:06 +02:00
Fini Jastrow
d812d153ab Start release v3.0.1
Edit ./package.json
Run version-bump.sh 3.0.1

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-05-13 07:49:58 +02:00
Fini Jastrow
43b9ae15d2 Codicons: Preserve smaller icons
[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>
2023-05-12 16:23:10 +02:00
Fini Jastrow
3dfa80eaa1 font-patcher: Do not maximize heavy brackets in Mono
[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>
2023-05-12 13:21:20 +02:00
Fini Jastrow
e5c880c2c4 font-patcher: Allow ScaleRules with a non 'pa' stretch
[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.
2023-05-12 13:21:20 +02:00
Fini Jastrow
a3ec4bb22b font-patcher: Fix vanishing fi ligature
[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>
2023-05-10 13:01:37 +02:00
Fini Jastrow
1820d4e341 Octicons: Create missing file-symlink-directory (1/2)
[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>
2023-05-10 12:49:14 +02:00
Fini Jastrow
af2573aac2 Fix: font-patcher: Allow to specify custom symbolfont with absolute path [skip ci]
[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>
2023-05-10 12:05:13 +02:00
Fini Jastrow
de78d08077 font-patcher: Be not needlessly careful
[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>
2023-05-10 12:01:07 +02:00
Fini Jastrow
b8a5f5b7e8 font-patcher: Do scale icons added via --custom
[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>
2023-05-10 12:01:07 +02:00
Fini Jastrow
7e0c17c294 font-patcher: Drop box-drawing from SymbolsOnly
[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>
2023-05-07 10:19:41 +02:00
Fini Jastrow
80664a90fe font-patcher: Do not log to file always
[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>
2023-05-06 10:54:05 +02:00
Fini Jastrow
5c968b80ae font-patcher: Do not fail on ro filesystem
[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>
2023-05-06 10:29:06 +02:00
Fini Jastrow
c8bd6d7b68 font-patcher: Modernize and expand Octicons scale table
[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>
2023-05-03 09:58:23 +02:00
Fini Jastrow
db39f37f8d font-patcher: Fix some Octicons scales
[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>
2023-05-03 09:58:23 +02:00
Fini Jastrow
50a5489424 font-patcher: Fix logging related warning
[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>
2023-05-03 07:41:27 +02:00
Fini Jastrow
d9f7dbe238 Prepatched fonts: Revive some ligature removal
[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>
2023-05-02 17:23:11 +02:00
Fini Jastrow
3432ad667b Revert "font-patcher: Use WIN metrics in all conflicting cases"
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
2023-04-30 23:36:35 +02:00
Fini Jastrow
334238d030 Start release v3.0.0
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-27 21:57:22 +02:00
Fini Jastrow
8cd3ae0c80 Fix: Rename Bitstream Vera
[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>
2023-04-27 20:35:36 +02:00
Fini Jastrow
4642ab095c Rename Bitstream Vera (due to RFN)
[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>
2023-04-27 18:59:32 +02:00
Fini Jastrow
1bb681473b Drop obsolete MDI, update Octicons
[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>
2023-04-24 21:32:13 +02:00
Fini Jastrow
91953e2de7 Create new octicons.ttf (1/2)
[why]
The octicons got a lot updates.
But they do not have a font anymore.

[how]
Keep our old codepoints constant, but add the new icons thereafter.

This commit just moves all the mechanics in and moves the (old) font.
No actual update here.

The mapping file has been created with the analyze_octicons script.

Fixes: #490

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-24 21:32:13 +02:00
Fini Jastrow
ab18a8135a font-patcher: Raise loglevel of VF message
[why]
When we expect the result to be trash we should say it's critical
(fatal).

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-24 19:52:27 +02:00
Fini Jastrow
a96006a681 font-patcher: Add option to allow italic-less fonts with oblique
[why]
Because we do not know if a complete family of fonts has an italic face
we must always assume it does. To get clean RIBBI families in ID1/2 we
create a different family for the oblique slant.
But that is not needed if the font does not have an italic slant, but
just an oblique one (like Bitstream Vera and descendants).

[how]
Add new command line option for font-patcher that specifies if the
family of fonts should be patched under the assumption that there might
be an italic face (default), or if we are sure there is none (and we can
leave oblique in the RIBBI group).

This is then applied to the config.cfg files.

Note that this does not take into account any other of the known_slants.
But they are not encountered in any of our prepatched fonts.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-24 19:52:27 +02:00
Fini Jastrow
e27f39593e font-patcher: Add debug mode
[why]
Some messages are not useful in all cases, and we want to hide them.
On the other hand there are messages that we want to only hide in
--shutup mode. Hmm.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-21 19:55:57 +02:00
Fini Jastrow
54da3a5860 font-patcher: Add dry run mode
[why]
To check just the naming and other stuff it is good to not patch (and
not store) the resultant font.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-21 19:55:57 +02:00
Fini Jastrow
b290dbf612 font-patcher: Fix logging messages while startup
[why]
When we still process the arguments we do not have a real logger object.

[how]
Use the default (root) logger in these cases.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-21 19:55:57 +02:00
Fini Jastrow
5c3bfbc2e0 font-patcher: Fix creation of Propo font with old naming
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-21 19:55:57 +02:00
Fini Jastrow
7c62c71267 font-patcher: Drop "Windows Compatible"
[why]
The fonts generated with --makegroups work on all platforms, so there is
no need for options --windows and --also-windows anymore.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-21 19:55:57 +02:00
Fini Jastrow
e2abaaf53f font-patcher: Correct usage hint
[why]
As we introduces a default --makegroups value of 1 the solution to a
problem can not be omitting the option but the user needs to
specifically call it with value 0 instead.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-21 19:55:57 +02:00
Fini Jastrow
bd5c74b5c9 font-patcher: Use makegroups per default
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-21 19:55:57 +02:00
Fini Jastrow
9be4835c29 font-patcher: Introduce less severe family name shortening
[why]
We want to keep "Nerd Font" in the font name if possible and instead
shorten the weight part with accepted abbreviations. But these abbrevs
are hard to read and sometimes a more mild abbreviating might be
sufficient to get the desired name length.

[how]
Introduce a new shortening method for the weight parts of a family name.
It takes a longer word (often un-shortened) when a weight stands on its
own, but when a modifier is used together with the weight the more
aggressive two-letter abbreviations are used.

That new shortening method becomes the default and all the functions get
a new parameter to enforce completely aggressive shortening, i.e. always
use the shortest possible form.

The new way to shorten is exposed all the way out to the font-patcher
user who can select the shortening method as parameter to the
--makegroups option. That option is undocumented because I expect some
changes later on, still.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-19 15:57:50 +02:00
Fini Jastrow
ff2be6af81 font-patcher: Fix "FontName Nerd Fonts" plural 's'
[why]
The patched font is named 'OriginalName Nerd Font' and not
'OriginalName Nerd Fonts'. This is a bug.

[how]
Take the correct singular string form when assembling the names.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-19 15:50:36 +02:00
Fini Jastrow
40f2f74e87 font-patcher: Use Python logging module
[why]
The outputs while patching are very ad-hoc and not grouped
systematically.
If run via gotta-patch-em the output is hard to process afterwards
automatically.

[how]
Use the logging module which outputs the messages and also writes a
run-log with all vital information.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-15 20:57:08 +02:00
Fini Jastrow
e54b5046b6 font-patcher: Make name shortening optional
[why]
The option --makegroups shortens the name suffix and the styles
rigorously. That is needed for fonts with long names and/or long style
descriptions.
But some simple font would not need that. With the option we can adjust
the amount of shortening to fit the specific font (family).

Unfortunately we can not automatically detect that, because the
font-patcher script can not assume anything about a complete family as
every font file is patched individually.

[how]
Add optional numeric parameter to option '--makegroups'.
The values can be:
  0 - turned off, use old naming scheme
  1 - turned on, shortening                         'Bold' to 'Bd'
  2 - turned on, shortening 'Nerd Font' to 'NF'
  3 - turned on, shortening 'Nerd Font' to 'NF' and 'Bold' to 'Bd'
  4 - turned on, no shortening

If --makegroups is not specified this is the same as '--makegroups 0'.
If --makegroups is specified without number that means '--makegroups 3'.

[note]
The argparser module takes the last specified parameter as the one to
use: If you specify --makegroups multiple times only the last one will
be used.

This can be used for gotta-patch-em-all. Per default it (will) specify
--makegroups 3. But via config.cfg we can specify a font centric other
number for individual fonts. The config.cfg values are added later in
the command line, so they take precedence.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-15 20:57:08 +02:00
Fini Jastrow
b40995275e name-parser: Rename parameters
[why]
The variables' names are not really fitting (anymore).

[how]
No functional change.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-15 20:57:08 +02:00
Fini Jastrow
037ab03f16 name-parser: Drop special handling for 'Windows Compatible'
[why]
This just drops the 'windows compatibility' options in association with
the name parser (i.e. --makegroups') as we want to always create fonts
that work on any platform.

Note that the fonts prodused right now are NOT windows compat anymore
and you can not specify the flag. Violating 'git rules' this commit is
not working correctly. But it is easier to do this in smaller steps.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-15 20:57:07 +02:00
Fini Jastrow
179dae01e0 font-patcher: Use standard filenames
[why]
The filenames of the patched fonts are rather ... unique:
- they contain blanks to separate name parts
- they do not separate name and style/weight

This is in part due to history reasons, because the names were not
parsed at all and just some suffix added.

Example (contrived):
  Victor Mono Nerd Font Propo Bold.ttf

Normally font file names would be:
  VictorMonoNerdFontPropo-Bold.ttf

We ourselves relied in part on that naming scheme, but do not follow it.
There are a lot powerline fonts out there that all add blanks to the
filename.

Some filename recommendation can be found in [1].

[how]
The filename is now always constructed directly from name ID 16
and name ID 17. If one of them is empty ID 1 and ID 2 are used as
fallback, as customary.
ID 16 (ID 1) and ID 17 (ID 2) are separated by a hyphen.

The result is that in can differ from the fontname (ID 6) and uses
always the longest most readable name parts.

[1] https://forum.fontlab.com/fontlab-studio-tips-and-tricks/font-family-naming-in-fontlab-studio-5/

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-14 08:01:12 +02:00
Fini Jastrow
45f9551d73 font-patcher: Unify naming variants
[why]
The short form of 'Nerd Font Mono' is 'NFM'.

The PS names have a mixture 'NerdFontM'.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-14 08:01:12 +02:00
Fini Jastrow
784bd422d6 name-parser: Set UniqueID
[why]
When we rename a font we should always also change the unique ID.

[how]
Take the fullname and the Nerd Font version number. In general we do not
have the version number in the NameParser object; but we have the
'Version' name and we loot the last word (which we have set to the Nerd
Font version already in the patcher) as version descriptor.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-14 08:01:12 +02:00
Fini Jastrow
95cae8fd81 Drop "Complete" from font names
[why]
Nowadays the Complete font is the normal font. We already dropped the
partially patched fonts long ago. If someone is self patching they will
know if it is a basic font or a complete font.

And already now one can not see if the patched font is bare minimum
(i.e. Seti, Custom, and Devi) or includes Powerline and/or
PowerlineExtra.

[how]
Just drop "Complete" from the naming.

[note]
As the name changes and thus the file name a lot of the other scripts
will break. But they might break anyhow because other naming changes, so
fix that as last commit.

See also commit
  557fc004c  Attempt to fix duplicate fonts in fontbook on osx

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-14 08:01:12 +02:00
Fini Jastrow
a7ecf075d2 font-patcher: Special rule for SymbolsOnly font
[why]
When patching the SymbolsOnly font via gotta-patch-em-all we create a
'Nerd Font Propo'. With the previous change that will be reflected by a
changed name.

The name change can come unexpected for users.

And in fact a 'Nerd Font' version would be ridiculous as there are no
preexsiting glyphs in the font.

So we should keep the previous naming:
* `Symbols Only Nerd Font` (which is in fact a Nerd Font Propo)
* `Symbols Only Nerd Font Mono` (for the monospaced version)

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-14 08:01:12 +02:00
Fini Jastrow
0b6f63e4df font-patcher: Invent name base "Nerd Font Propo"
[why]
We have three ways to create a patched font
- 'normal' (i.e. monospaced oversized symbols): Nerd Font
- 'mono' (i.e. strictly monospaced small symbols): Nerd Font Mono
- 'proportional' (i.e. proportional symbols): Nerd Font Propo

The first two variants have a name, the third one has no name, it is
also called 'Nerd Font' (and it was THE font, for v2.1.0 (only)).

[how]
Invent and set new name, so that all variants have different names.
Makes refering to them explicit.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-14 08:01:12 +02:00
Fini Jastrow
80f602e805 font-patcher: Pull 'Mono' to front in names
[why]
When we crate a font we take the OriginalName, add "Nerd Font" and which
patches we applied, and add "Mono" if --mono has been specified:

OriginalName Nerd Font Complete Mono
OriginalName Nerd Font plus Weather Mono

But the 'Mono' part is quite important, but this scheme will put it in a
place where it is easily out of view or has been removed (to keep the
name short).

This truncation is especially bad on Windows Compatiple and when the
user installs both the 'Nerd Font' and the 'Nerd Font Mono':

    SomeVeryLongFontName Nerd Font Complete
    SomeVeryLongFontName Nerd Font Complete Mono

become after truncation
    SomeVeryLongFontName Nerd Font Comp.ttf
    SomeVeryLongFontName Nerd Font Comp.ttf

[how]
Always put the "Mono" directly after "Nerd Font" and all the other name
components come later.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-14 08:01:12 +02:00
Fini Jastrow
5823665f1f font-patcher: Fix patching non-monospaced fonts
[why]
Any non-monospaced font will not be be patched, the patcher crashes.

[how]
This must have happened when the box drawing characters rescaling
feature has been disabled. The default value (False) is not always set.

The box drawing patch has the ability to rescale existing box glyphs.
That used to be done when all box glyphs are already existing in the
source font. We do not patch in a new glyph set then, but we rescale the
existing glyphs to match the possibly new cell size.
But that feature is disabled and the attribute 'dont-copy' is never
utilized. It is disabled because some existing box sets are rather ...
sspecial in their overlap and can not be scaled as we would scale them.

Fixes: #1170

Reported-by: Henrique Monteiro <hrqmonteiro@protonmail.com>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-14 07:08:39 +02:00
Fini Jastrow
9defc59b9d font-patcher: Fix --xavgcharwidth with --quiet
[why]
--xavgcharwidth does not work when --quiet is given.

[how]
Correct indent level ....

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-12 18:19:36 +02:00
Fini Jastrow
156f9bf694 font-patcher: Add option to manipulate xAvgCharWidth
[why]
Some old applications seem to depend on obsolete xAvgCharWidth values to
show two-cell glyphs correctly. Fontforge can only generate OS/2 tables
version 4, but these applications need 2 or less. In fact they seem to
not look up the version number, but rely on the value being like it
always has been ;-)

One example is Windows notepad, that takes the xAvgCharWidth as base for
the cell size and draws the two-cell chars in a cell twice that size -
without any regard to glyph width.

[how]
These issue seems to be encountered rather seldom and only with some
obscure (grin) applications. There is also no good way to handle this
automatically. So we add a command line option that allows the user to
tweak the value after patched-font generation.

The option is called `--xavgcharwidth`:
* If not specified the behavior of the patcher does not change
* If just given the xAvgCharWidth is copied over from the source
* If a number is added that number is used as xAvgCharWidth
* If the number added is zero we will calculate the old style xAvgCharWidth

Fixes: #522

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-12 16:29:05 +02:00
Fini Jastrow
cf59464e52 font-patcher: Optimize font tweaking for ttc
[why]
When we have a ttc and tweak the contained fonts we recalculate the
total checksum after each tweak while we only need to tweak it after all
changes (included fonts) have been tweaked.

[how]
Pull the total checksum recalculation out of the subfonts loop.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-04-12 16:29:05 +02:00
Fini Jastrow
9834207159 font-patcher: Do not add Box drawing glyphs on propo fonts
[why]
It does probably not make too much sense to add the box drawing glyphs
to proportional fonts. The boxes that are drawn need to be filled with
some text, and if that does not have monospaced property the box will
always look ugly and not fit and change when the font is changed.

[how]
Make the fact if we detect a source font as monospaced or not a property
of the patcher object.

Always determine that property (before we just determined it when the
target font should have monospaced behavior).

Use that new property to enable/disable the box drawing glyphs.

In a way it is now also prepared to add that as command line parameter
should the need for that arise.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:32:05 +01:00
Fini Jastrow
7b4d83c2f3 font-patcher: Disable exising box glyph rescaling
[why]
Normally the 'cell' size should not change on patching. If the 'cell'
size does not change we do not need to rescale the box glyphs. They
probably worked before, they work the same afterwards.

Another reason to disable this is Cascadia Code. It has box drawing
glyphs that extend for more up then the normal cell. If we rescale that
to fit a probably new cell size we get a 'midline' that is too low
(because the upper stems are longer).

[how]
Leave the code in, but disable 'just scale do not copy' mode.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:32:05 +01:00
Fini Jastrow
2d316225fb font-patcher: Improve warnings
[why]
We have 2 different types of metrics warnings. When one warning has been
issued the other is not displayed (if it would trigger). The reason was
that I thought normally there would be no warnings and if someone would
have to inventigate the sourcefont anyhow.

[how]
But the warnings are quite common, so differentiate a bit more when
generating.
Also improve one warning message to make clear what the warning is
about.

And fix the assignment of advance width to width; which has no
consequence because it is never used (at the moment). But it was
obviously wrong.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:32:05 +01:00
Fini Jastrow
e31bdaa071 font-patcher: Fix block scaling
[why]
The greys seem to be too small.

[how]
Separate the blocks into real block, greys and quads. They all have
different scales in Hack which we use to patch in.

If we do not patch in and just scale existing glyphs these three groups
should always be sufficient.

Note that in Hack the quad block 2597 is too small; we could have scaled
it together with the blocks group, but that would raise issues with well
behaved fonts that we just scale and not patch in.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:32:05 +01:00
Fini Jastrow
964a0c8eb3 font-patcher: Fix alignment with overlap
[why]
Some few glyphs get a wrong left side bearing in `Nerd Font`:
    E0C2: -1230
    E0C5: -857
    E0C7: -667
    E0CA: -1230

These are the powerline glyphs which are right aligned and have overlap
and a target width of 2 cells wide.

[how]
To simplify the code add a new function that decides if a symbol shall
be one or two cells wide.
That function is then used where we had explicit tests already.

Use the function also in the overlap correction code, such that the
overlap is corrected for the right cell occupancy of the concrete glyph.

[note]
I guess that the overlap correction for 'c' alignment for 2 cell wide
glyphs is also broken. But we do not have such glyphs, so we ignore it
for now :-}

This fixes the previous commit 'font-patcher: Fix overlap for align c and r'.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:32:05 +01:00
Fini Jastrow
acd49cc33c font-patcher: Fix overlap for align c and r
[why]
The box drawing glyphs (center aligned) and some Powerline glyphs (that
are right aligned and have a limited xy-ratio) are positioned wrong.

Affected are all box drawing glyphs (e.g. 2548) and some Powerline
glyphs (i.e. E0B2, E0B6, E0C5, E0C7, and E0D4).

[how]
The box drawing glyphs are center aligned and have overlap. The code
does not correct the overlap (left bearing) but uses the default case of
'make the left bearing zero'. The code does just check left aligned
glyphs and not center aligned ones.
Add the correct overlap for center aligned glyphs (i.e. half the
overlap).

The Powerline glyphs are right aligned. Usually that works, because the
glyphs are created with the right size, so that no additional
manipulation is needed.
But if the glyph has a ratio limit the resulting size will be different.
We could in fact fix the size code, somehow, but that is rather
complicated, formula-wise. Instead we just scale these glyphs (which are
the 5 listed above) and shift them to the right position such that the
correct overlap results.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:32:05 +01:00
Fini Jastrow
cf253a2b9c font-patcher: Fix align formula
[why]
This is more an academic fix. If we calculate widths from with bounding
boxes we always need to take xmin and xmax into account. Usually xmin is
zero and so it does not make any difference.

But maybe one can see better what is calculated, especially as we use
xmin in other cases.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:32:05 +01:00
Fini Jastrow
ac3cb23929 font-patcher: Add glyph at unicode 2630
[why]
The unicode 2630 (Trigraph Heaven) is often used in vim powerlines (at
least).

[how]
Draw nice 3 rectangles.
Insert 'pa1', always scaling also in non mono fonts. That needs a new
attribute: '!'.

The scaling is in fact an issue. Using 'pa' is the way of least
resistance.
Without the new attribute the glyph would look different in mono and
nonmono, which is not nice.

Fixes: #589

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:32:05 +01:00
Fini Jastrow
03943cf754 font-patcher: Attribute tables cleanup
[why]
Defaults should come first.
Unify empty lines or no empty lines.
Add some docu.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:32:05 +01:00
Fini Jastrow
0c43738914 font-patcher: Remove debug output
[why]
Comes from a23e33ca87, should not have been included in commit.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:32:05 +01:00
Fini Jastrow
7f1b120fca font-patcher: Keep box drawing glyphs if we have all
[why]
If the to-be-patched font already has all box drawing glyphs we could
use them instead of our extra set from Hack.

But we need to scale them in case the 'cell' size has changed.

[how]
All the mechanics have been already added, we just need to enable it now
in the right cases.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:32:05 +01:00
Fini Jastrow
ff57585e51 font-patcher: Add box drawing glyphs
Fixes: #1108

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:32:05 +01:00
Fini Jastrow
d07f7253b9 font-patcher: Add possibility to just rescale existing glyphs
[why]
When the destination font has box drawing glyphs and we change the
'cell' size, we need to rescale the existing glyphs (so that they fill
the new 'cell'.

[how]
Add a new parameter attribute that skips the copying und just works on
the scaling of glyphs that have this.

For a correct message only the default attribute is checked.

[note]
This just add the possibility, it is not yet used.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:32:03 +01:00
Fini Jastrow
702e31716c font-patcher: Access the symbol fonts via unicode
[why]
The whole patching process addresses the glyphs via their unicode
number / codepoint. We ensure the adressability for the to be patched
font, but the symbol fonts can differ.

[how]
Just set the way we want to address the symbol font glyphs.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:31:30 +01:00
Fini Jastrow
80e818bf55 font-patcher: Allow xy scaling for ScaleGroups
[why]
All the box drawing glyphs should be scaled and shifted as one (i.e.
equally). For such glyph sets we have the ScaleGroups that handle it
nicely, determining a combined bounding box and calculation scale and
shift from that bounding box instead of the actual glyph's bounding box.

But unfortunately it is hard-wired to do just 'pa' scaling. For the box
drawing glyphs we need 'xy' scaling.

[how]
The preparatory stage calculates the 'pa' factor for ScaleGroups for us.
That is mainly so because the old system worked that way and has no
notion of combinded-bounding-box. The data needed to be stored in one
number, the scale. Later came the correct shifting, which needed the
bounding box. But the scaling still relied on the one scale factor that
is used for x and y.

Instead, if we have a combinded bounding box, we ignore the
precalculated scale factor and calculate a new set of x- and y-scales
based on the requested scaling algorithm. In this way we can get 'xy' or
'pa' or even 'xy2' scaling, or whatever we like, based on the combined
bounding box.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:31:30 +01:00
Fini Jastrow
1d7c4f7791 font-patcher: Issue warning on width irregularities
[why]
For some reason we determine the bounding box xmax value of the 'normal'
extended glyphs. For the cell size we use the advance width of those
glyphs - the xmax values is not utilized at all.

But if we would ever use it, it might be good to see that something
unexpected(?) happened.

This commit is not really necessary. Maybe it is good, maybe it just
adds noise. We can always remove it later.

No functional change.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:31:30 +01:00
Fini Jastrow
bb8a59df50 font-patcher: Whitespace cleanup
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 12:31:30 +01:00
Fini Jastrow
4a3ca9069d font-patcher: Fix crash with older fontforge
[why]
If a font has references in glyphs that we want to add to the essential
set of glyphs, and fontforge is old (i.e. 2020*) the patcher crashes.

[how]
The fontforge function glyph.references returns a three element tuple in
current fontforge (i.e. 20230101). But older versions skip the selection
bit and return only tuples of two.

As we use only the first tuple element we do not care about the 2nd and
possible 3rd element(s) and just thrash them.

Fixes: #1142

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-10 10:43:55 +01:00
Fini Jastrow
f84a4a46d2 font-patcher: Add Codicons scale list
[why]
All glyphs of the codicons set are individually maximised in size.
That leads to the curious condition that 'circle small' looks bigger
than 'cicrle' (because the line width is scaled up more -> looks bold).

Also some other 'subsets' look ugly and can not be used together.

[how]
Add appropriate ScaleGroups.

For the circles we also include one full-size circle as reference. To
get less than maximal scale for the small circles.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-03-02 15:04:48 +01:00
Fini Jastrow
90be3f4264 font-patcher: Scale all Material Design Icons individually
[why]
The Material Design Icons have for sure pairs of glyphs that people
would like to have scaled identically. Because the sheer number of
glyphs and because they are already very nicely and uniformly scaled
within their design space the MDI at the new codepoints where all scaled
the same with taking the theoretical design space as ScaleGlyph.

But that means all icons get scaled a bit smaller than before, where we
individually scaled each Material Design Icon to fill the cell.
This lead to numerous complaints.

[how]
We take a different approach now, more conventional maybe. Especially in
the light that the older bigger icons will get dropped; and people love
them.
So the uniform scaling is ditched and the individual scaling is used.

Fixes: #1061
Note: https://github.com/greshake/i3status-rust/pull/1728

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-02-23 18:14:09 +01:00
Fini Jastrow
a23e33ca87 font-patcher: Allow anonymous fonts
[why]
When the font has no name the patching fails.

When there is no name we fall back to filename parsing, so it should not
fail.

[how]
Check if we have a name. If not do not try to set it.

[note]
Also change type checks to isinstance() calls.

Fixes: #514

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-02-21 15:22:44 +01:00
Fini Jastrow
0b04391b77 font-patcher: Fix center alignment of ScaleGroup
[why]
When a ScaleGroup's combinded bounding box is wider than the target font
cell the actual X position of a glyph in the group depends on it's own
bonding box and not of the combinded bounding box. When doing center
or right alignment.

[how]
'Overwide' ScaleGroup glyphs are correctly placed and shifted in
position, but that would mean a negative left side bearing (i.e. glyph
extends to the left into previous 'cell').
We do not want that and it is later corrected for all glyphs. But that
is done on an individual glyph level and it is just left aligned for its
concrete bounding box (i.e. left side bearing is set to zero).

The dilemma here is that you can not really center a (combinded) glyph
within a cell, when
* the cell is smaller than the glyph
* a left bearing is not allowd

So we change the algorithm here that 'center' and 'right' alignment
mean:
* Center the glyph in the target font cell
* But if that would create a left side 'overhang' (bearing) just left
  align (move it as far left as possible without creating a negative
  bearing)

The only glyphs affected by this change are the very wide weather icons,
and here escpecially the moon phases F096 and following (target
codepoints E38E ..).

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-02-15 21:39:16 +01:00
Fini Jastrow
68b381eac5 Fix weather icons cloud scaling
[why]
The scaling of the clouds is not identical but depends on the actual
glyph bounding box. But the clouds should all have the same scaling to
be 'interchangeable'

[how]
Put all clouds in a ScaleGroup.

Also add missing Celsius degrees glyph to other degree glyphs group.

Fixes: #1107

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-02-15 21:39:16 +01:00
Fini Jastrow
dfffc615ad font-patcher: Reform PowerlineExtra sizing
[why]
The Powerline extra glyph sizing is not really clear.

[how]
Make the triangulars 1 cell wide, as for example Iosevka also does.
Make the Legos 2 cell wide with pa scaling to make them look nicer.
Make the Hexagons 2 cells wide and keep their aspect ratio if possible.
Make small and big Squares also 2 cell wide and keep their aspect ratio
of possible.

For the small and big Squares add a tiny bit of border (negative
overlap), because they have no smooth border line over their open and
closed squares, and that might look strange if some touch and some dont.

Fixes: #1106

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-02-15 21:18:11 +01:00
Fini Jastrow
3e38c60f52 font-patcher: Fix BTB warning for SymbolsOnly font
[why]
When patching the Symbols Only font we derive the baseline to baseline
distance through abnormal means, so the check fails.

[how]
Set expected baseline to baseline value explicitely for the Symbols Only
font.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-02-15 21:18:11 +01:00
Fini Jastrow
869d6f9351 Allow for growing original icon set
[why]
We have an automation for adding glyphs to the original set.
If someone throws in the svg file and adds the glyph to the icons.tsv a
new original-source font is generated.

But the added glyphs are not patched in, because that would need a
change at font-patcher (adjust the end codepoint).

This can be forgotten easily.

[how]
The maximum codepoint of our own (original + seti) set is 0xE6FF. At
0xE700 the Devicons start.

The original-source generation script now checks the offset, they may
not be negative and on the positive end we may not leave our set-range.
If that happens the script fails thus the workflow fails.

Also increate the patch range in font-patcher. If there are no icons to
patch in the symbol font the codepoints are just ignored.

[note]
See also PR #1119

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-02-13 12:19:52 +01:00
Fini Jastrow
de659388e9 font-patcher: Remove leftover code
[why]
There is a bit of code that is not needed anymore (or was never needed).
This makes things look more complicated than they are.

[how]
1. It is plain wrong to write that we add one (1) glyph if we do not add
   any glyph.
2. One (1) is added to index later anyhow, so we do not need to distort
   the counting in the beginning (the code will run with index=1 for
   both the first and the second patched in glyph).

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-02-13 12:19:52 +01:00
Fini Jastrow
62b972b431 font-patcher: Fix: Use WIN metrics in all conflicting cases
[why]
With commit
  621008773  font-patcher: Use WIN metrics in all conflicting cases
we intended to use the WIN metrics for the baseline to baseline
calculations for fonts that have contradicting (i.e. broken) metrices.

But we use the TYPO metrics instead.

[how]
This is obviously a typo in the code. To prevent such errors and improve
the readability we use Enums now. I believe we silently dropped support
for Python 2 some time back. And if not we drop it today :-}

[note]
Many thanks to Nathaniel Evan for again finding this bug!

Mentioned in: #1116

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-02-12 17:06:18 +01:00
Fini Jastrow
b112fe12de font-patcher: Fix: Fix line gap redistribution
[why]
With commit
  e69a025a8  font-patcher: Fix line gap redistribution
we fixed the wrong adding instead of subtraction of the bottom gap part
from the descenders.

At least this was done for HHEA and TYPO values.

With WIN values the descenders have positive (!) numbers, so the sign
was not changed for the WIN case.

But that is wrong, as we are already in the ymin xmax coordinate system
(and took the negative of the WIN descenders). So of course here also we
need to subtract and not add.

Mentioned in: #1116

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-02-12 17:06:02 +01:00
teatimeguest
773cafb7cc font-patcher: Make sure nf-custom-asm and nf-custom-v_lang icons are included 2023-02-12 15:59:59 +01:00