Commit graph

316 commits

Author SHA1 Message Date
Fini Jastrow
b82bd819aa Remove mentions of master branch [skip ci]
[why]
If we ever switch the default branch the links would break. So just say
'default branch' directly, whichever that may be.

[note]
CI workflows not changed, I do not know if there is an alias for the
default branch available.

Fixes: #971 (partially)

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-10-17 11:50:53 +02:00
Fini Jastrow
3e478f7cf8 font-patcher: Fix empty input font detection
[why]
If we have an empty input font (i.e. for Symbols Only font) and that
font has a gap.. That gap will be redistributed to a gapless font where
the ascenders and descenders are expanded to fill/keep the gap.

If the font has no height (i.e. == ) and a gap, the height will
afterwards be > 0 and the empty font detection breaks.

[how]
Detect empty fonts before gaps.

Fixes: #965

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-10-12 13:46:54 +02:00
Fini Jastrow
6f4af9482d font-patcher: Clarify height code
[why]
Use of abs() looks like we do not know if the descenders are expected
to be positive or negative. But it is well defined.

Furthermore on abnormal fonts (where the descenders are nonexisting)
we can use the wrong value. Well, that is academic I guess.

[how]
In our own `ymin` value we store a value like os2_descender, which means
that it is on the same axis as the ascender (ymax). Typical values where
the baseline is on y-coordinate 0 ymax will be positive and ymin (being
below the baseline) will be negative.

The total height has to be calculated from adding ascender + -descender
(when the descenders are lower than the ascenders, which is guaranteed).

The older descender values have positive values; are on an opposite y
axis... The height with them would be ascender + descender.

Well, WE have in the font_dim os2-like values...

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-10-12 13:46:54 +02:00
Fini Jastrow
ee17073b62 font-patcher: Fix checksum algo
[why]
For some fonts the calculated checksum(s) was wrong.

[how]
Misplaced the multiplier ... the LSB shall not be shifted of course, but
the current code shifts as last action: Also the LSB is shifted.

First shift (old) accumulated content, then add new data.
In that way the last added data (LSB) is not shifted.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-10-10 16:29:20 +02:00
Finii
cdcf7a5a30 [ci] Bump release version 2022-10-07 11:55:35 +00:00
Fini Jastrow
6d30fee4bf font-patcher: Respect gap values in source font
[why]
We just ignore specified gaps in the source fonts (i.e. set them to
zero). This reduces the line spacing in the patched font (because the
gap is missing).

[how]
Distribute the gap INTO the cell, so that we can work with zero gap (we
need that for the powerline glyphs), and still keeping the powerline
glyphs centered about the regular glyphs AND keeping the total line
spacing.

Idea-by: Tushar Singh <tusharvickey1999@gmail.com>

Fixes: #850

Reported-by: Joe Bolts
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-10-07 11:56:12 +02:00
Fini Jastrow
feafa89bb3 font-patcher: Prevent --mono on proportional fonts
[why]
When the source font is proportional we can not really create a
monospaced (patched) font from it. The glyph width is for example very
small for 'i' but wide for 'W'.
The glyphs are all left aligned, leaving very strange separation between
smallish glyphs.
Even if we would center the glyphs, the look would be strange and
completely differenmt from the source font's look.

[how]
For proportional fonts do not allow to patch with `--mono`.

The fact if a source font is monospaced is determined by examining some
(very few) glyphs. But testing all our source fonts in the repo shows
that it is sufficient.
Furthermore the Panose flag is checked and differences between the flag
and what the glyph examination found are reported.

The user can enforce `Nerd Font Mono` generation with double specifying
the command line option `--mono --mono`. Still a warning will be issued.

[note]
Because `gotta-patch-em-all-font-patcher!.sh` does not really count the
variations but calculates them in a separate loop it does not know
anymore how many variations are created per family. The numbers are
wrong.
But probably we should count the result font files in the end anyhow.

Because the information is not needed (in an automated manner) this is
not corrected here.

It seems wrong anyhow:
  total_variation_count=$((total_variation_count+combination_count))
  total_count=$((total_count+complete_variations_per_family+combination_count))

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-24 16:56:30 +02:00
Fini Jastrow
1d21ef9e79 font-patcher: Preserve existing bitmaps
[why]
Bitmaps existing in a font are discarded. The font-patcher script just
cares about outline fonts.

[how]
If the sourcefont has bitmaps, do save them into the patched font. Note
that this does not generate bitmaps for the patched-in glyphs (icons).

[note]
Fonts probably affected in src/unpatched-fonts:
    bitmap (11,) (gohufont-11)
    bitmap (14,) (gohufont-14)
    bitmap (11,) (gohufont-uni-11)
    bitmap (14,) (gohufont-uni-14)
    bitmap (7, 9, 10, 12, 14, 18, 24) (ProFontIIx)
    bitmap (12, 14, 16, 18, 20, 22, 24, 28, 32) (TerminusTTF-Bold Italic-4.40.1)
    bitmap (12, 14, 16, 18, 20, 22, 24, 28, 32) (TerminusTTF-Bold-4.40.1)
    bitmap (12, 14, 16, 18, 20, 22, 24, 28, 32) (TerminusTTF-Italic-4.40.1)
    bitmap (12, 14, 16, 18, 20, 22, 24, 28, 32) (TerminusTTF-4.40.1)

Fixes: #86

Reported-by: DoctorKnowsBetter
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-24 11:40:29 +02:00
Fini Jastrow
501dd29a31 font-patcher: Clean up patch sets
[why]
The patch set table has 'contradicting' or 'complicated' entries.

[how]
When we use exact patching a SrcStart will be ignored and shall be None
to make that clear.

The other two cases patch in only one glyph, make the entries more easy
we could either make them 'exact' (reuse source codepoint) or specify a
SrcStart. At the moment they rely on the (hidden?) rule that non-exact
entries without SrcStart still reuse the SymStart...

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-23 11:42:35 +02:00
Fini Jastrow
92d8a6007e font-patcher: Make symbol codepoints (more) stable
[why]
The Font Logos and Octicons codepoints depend on the parallel existence
of FontAwesome. I.e. Font Logos is shifted of Octicons or FontAwesome is
also present in the patched font; Octicons is shifted if FontAwesome is
present.

This means that people, although using a Nerd Font, can expect the
symbols in different locations. The reason is clear; people that just
want one or some symbols and use a specifically patched font will be
able to use the original symbol font codepoints.

But I guess that these uses are nonexisting. Almost all will use
'complete' patched fonts and that is what we deliver and document.

To make the documentation less complicated we should fix the code point
ranges that a specific symbol set will be patched in at.

[how]
Just drop the associated functions and use a False constant instead.

[note]
The two possible places where Octicons / Font Logos ends up are there
since they have been added back in 2015/6 (commits 9620d47ae, f933b5a2).

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-23 11:42:35 +02:00
Fini Jastrow
7ca44d063f font-patcher: Remove "SrcEnd" option
[why]
In patch set definitions we have for the source ranges SymStart and SymEnd
and for the destination we can specify SrcStart and SrcEnd

The SrcEnd can be automatically generated. For SrcEnd values that differ
from the autogenerated value (are lower) the script would crash, or (are
higher) ignore them anyhow.

There are two modes: 'exact = True' and 'exact = False'.

The SrcStart and SrcEnd values are ignored if exact is True, because the
glyphs are patched into the same codepoint where they originate. This
also means that gaps in the symbols are preserved - all patched in
glyphs have the same codepoint as they have in the source (symbol) font.

When exact is False on the other hand, all (non empty) glyphs are filled
into the codepoints that start at SrcStart. Gaps (empty glyphs) are
ignored and thus are not present as gap in the patched font anymore (*).
The to-be-filled-next codepoint in the patched font just increases by 1
on every filled symbol.

See note for the reason.

This also makes maintining the patch set easier as noone needs to
'calculate' a SrcEnd value anymore.

[how]
Use directly the start value and the counter instead of filling an array
with a range, that is then indexed by the counter.

Before this commit:

  list_of_patched_font_codepoints = list(range(SrcStart, SrcEnd + 1))
  current_codepoint = list_of_patched_font_codepoints[loop_counter]

After this commit:

  current_codepoint = SrcStart + loop_counter

[note]
Maybe related to code removed with c728079b6.

I guess the code uses the list, because it has been believed that glyphs
can only be indexed by strings containing a hex number. The array
supposedly contained that strings.

But in fact the fontforge python module docu is like this:

font.__getitem__(key)

    If key is an integer, then returns the glyph at that encoding.
    If a string then returns the glyph with that name.
    May not be assigned to.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-23 11:42:35 +02:00
Fini Jastrow
7c5c838122 font-patcher: Enable lowestRecPPEM fix in TTCs
[why]
The font flags and PPEM fix does not work with font collection files,
because it does not know how to handle them. It assumes a ttf or otf
font with the specified table structure.

The fix (for single font files) has been introduced with commit
  40138bee9  font-patcher: Handle lowestRecPPEM

[how]
Check if the file is of type 'ttcf', and if so fast forward to the given
single font index into the collection.

This can be rather slow...

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-23 10:52:55 +02:00
Fini Jastrow
e8a17c71bf font-patcher: Increase script version
[why]
With the new TTC feature we might increase the minor number ;-)
This is not just a bugfix.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-22 19:02:47 +02:00
Fini Jastrow
e515cccab9 font-patcher: Allow patching of True Type Collections
[why]
Someone might want to patch a whole lot of fonts that come in a ttc.

[how]
Just open all fonts that the input file contains (1 or more) and create
a single font or collection font file.

The automatic layer detection does not work in all cases for me, so we
need to manually search for the foreground layer (usually '1').

Code inspiration taken from
https://github.com/powerline/fontpatcher/pull/6

[note]
Changed output in the end to the filename (before it was the font name),
so that one can easily copy&paste or open that file.

Reported-by: Lily Ballard <lily@ballards.net>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-22 19:02:47 +02:00
Fini Jastrow
1b8c9e2768 font-patcher: Pull out opening and generating the font
[why]
These operations are also not strictly patching.
When we want to handle more than one font we need to have this outside
the patch() function.

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

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

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

[how]
Put argument checks into setup_arguments().

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

No functional change.

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

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

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

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

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-22 19:02:47 +02:00
Fini Jastrow
5d218b1cd3 font-patcher: Fix ligature removal
[why]
Only one tables is removed, even if we want to remove more.

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

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

Reported-by: Rádler Ákos <akos.radler@gmail.com>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-22 17:46:55 +02:00
Fini Jastrow
92fbcdb143 Rename 'Font Linux' to 'Font Logos'
[why]
The glyphs set's name changed, we should reflect that.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-13 08:05:14 +02:00
Fini Jastrow
983226a70e font-patcher: Fix scaleGlyph related rounding error
[why]
Sometimes the patched-in symbols are slightly too big, which shows up in
Nerd Font Mono fonts where the destination size is specified exactly.

That issues a warning like:
  Warning: Scaled glyph U+F077 wider than one monospace width

[how]
For the scaleGlyph groups we need to combine the bounding boxes of
several symbol glyphs to determine the 'combined' scale we need.
Unfortunately when the concrete glyph is finally copied over its size
can change minimally.

So we need to measure the glyphs in the scaleGroup _after_ they have
been copied to the to-be-patched font. This is a bit complicated,
because we need to know some glyph slot we can use for that.

[note]
See also commit
  e805b879  font-patcher: Resolve rounding error when rescaling

Fixes: #917

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-08 20:08:44 +02:00
Finii
9c950dc385 [ci] Bump release version 2022-09-07 08:05:53 +00:00
Fini Jastrow
a6e6ee26d8 font-patcher: Correct Family for Mono Windows
[why]
Windows Compatible fonts have the same Family name, regardless if they
are "Nerd Font" or "Nerd Font Mono".

This creates problems for appliations that sort and select fonts by
Family name.

[how]
Just like "Nerd Font" is abbreviated as "NF" in the Windows Family names
(to keep it short because of the 31 character length limit), the
"Nerd Font Mono" are now called "NFM" instead of just (also) "NF".

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-07 06:58:21 +02:00
Fini Jastrow
604c41253a Add Kotlin icon to Seti & Custom
[why]
It's not available anywhere else (it seems).

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-07 06:15:30 +02:00
Fini
86c2247ee2
Merge pull request #833 from ashfinal/icon-emacs
Add icons for Emacs and Orgmode
2022-09-07 05:48:55 +02:00
Fini Jastrow
0e45cd66d6 font-patcher: Allow glyphs with altuni for exactEncoding
[why]
Some symbol fonts might come with glyphs that have multiple codepoints.

When we want to patch them with `'Exact': true` (i.e. at their 'original'
codepoints) we want to patch them into the codepoint that has been used
in the selection process. That means between SymStart and SymEnd.

But this is not the case. We patch them in into their 'main' codepoint,
which can be outside the expected range of points.

This came up when patching with FontAwesome V6. It has for example these
glyphs:

Glyph 'music' has a main codepoint 0x1F3B5, but it is present in the
font also on codepoint 0xF001.

Glyph 'heard' has a main codepoint 0x1F9E1, but it is present in the
font also on codepoints 0x2665, 0x2764, 0xF004, 0xF08A, 0x1F499, ...

When doing a `'Exact': true` patch (i.e. exactEncoding = true) the
glyphs is patched into the target font at its (the glyph's) main
codepoint, regardless of our patch-codepoint-range.

[how]
We examine all codepoints that a glyph occupies in the symbol font. From
all these codepoints we take the nearest to the last glyph be patched
in. Nearest means from the possible codepoints the lowest that come
after the previous used codepoint.

For example the 'heard':

Last patched in codepoint was 0xF003.
Main codepoint: 0x1F9E1
Alternate codepoints: 0x2665, 0x2764, 0xF004, 0xF08A, 0x1F499, ...
-=> 0xF004

Later in the patching process we might encounter the same glyph again,
but this time the previous codepoint was 0xF089, so we need to take
0xF08A.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-07 05:42:02 +02:00
Fini Jastrow
f97d729b34 font-patcher: Check if glyph source is available
[why]
When users just download the script (and not the source glyphs) the
script fails with an obscure error message.

[how]
Check if the glyphdir exists at all. If not give a hint to download the
glyphs.

Check if the individual glyph font exists and is readable. Bail out if
not.

[note]
Cherry picked, was part of #741

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-07 05:37:33 +02:00
Fini Jastrow
7cda326515 font-patcher: Allow to specify custom symbolfont with absolute path
[why]
When one wants to use a custom symbol font and specifies it with an
absolute path, the glyphdir is still prepended.

That means that the argument to `--custom` is always used as relative
path (to `--glyphdir`), even when it starts with `/`. That is somehow
unexpected or at least inconvenient.

Example:
fontforge font-patcher --custom ~/Downloads/fa6.otf Inconsolata-Regular.otf

fa6.otf is searched for in ./src/glyphs/home/username/Downloads

[how]
Use Python function that handles joining path fragments. If a component is
an absolute path, all previous components are thrown away.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-07 05:19:17 +02:00
Fini Jastrow
64d53b8247 font-patcher: Fix Python problem
[why]
I'm not sure why, but maybe the CI's Python is another version where the
syntax is not supported.

This has been introduced with commit
  4a61afc83  font-patcher: Do not overwrite glyphs that are needed for basic glyphs

[how]
Use less sophisticated syntax.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-06 16:49:29 +02:00
Fini Jastrow
b2fa537e7f font-patcher: Correct mono scaling of thin glyphs
[why]
Some glyphs that are tall and thin, are too big in the resulting patched
font, i.e. are higher than our 'line'.

At least for --mono fonts. The non-mono fonts do not rescale the
inserted glyphs at all, so there is no definition of 'too tall/wide'.

[how]
We want all glyphs to fit into the box defined by *_dim['height'] and
*_dim['widths'], as it also defines our powerline-glyph scaling and
horizontal and vertical advance widths.

So we need to take that value (instead of EM) for the scaling
calculation. The history of the use of EM here is a bit obscure, more
explanations in the PR.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-06 15:40:25 +02:00
Fini Jastrow
4a61afc83a font-patcher: Do not overwrite glyphs that are needed for basic glyphs
[why]
Sometimes the basic glyphs ([a-zA-Z] etc) are constructed in the font
from other glyphs via references. To keep those basic glyphs intact we
must not touch the referenced glyphs.

[how]
Crate a list of all glyphs referenced by the basic glyphs.
When patching in some new symbol - if that codepoint is in the list do
not overwrite it. Overwriting would break a basic glyph.

The user does not get the glyph that we would have patched in, but that
can not be helped if we want to keep the basic glyphs intact and not
'redesign' the complete font.

Fixes: #400

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-06 15:30:58 +02:00
Fini Jastrow
ac60053b3a font-patcher: Correct python module missing message
[why]
When the fontforge python bindings are not installed we fail while
importing psMat. The message suggests that fontforge itself is not
installed - which is not the real reason. One can use the libfontforfge
with the python-fontforge without having the GUI program fontforge.

Furthermore we link to outdated installation instructions.

[how]
We already check and report correctly what needs to be done with the
fontforge module import. As both modules are often in the same package
we should probably report the same message. That message holds correct
hints for Debian/Ubuntu. It does not have a link to fontforge, though.

[note]
Also update Debian package name.

Fixes: #725

Reported-by: Aniket Teredesai <a@aniketteredesai.com>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-06 15:28:05 +02:00
Fini Jastrow
f67de4d7b0 font-patcher: Fix glyphs with overlap
[why]
For some powerline symbols we add a certain amount of overlap into the
previous or next character to cover up a small gap between the symbols
that otherwise can show up as ugly thin (usually colored) line.

But after we carefully design that glyph with a bit overlap (over-sized
and having negative bearings) we remove all bearings. That breaks of
course the glyph and no actual overlap on the left side happens.

[how]
Just do not remove negative bearings on overlap-enabled glyphs. As they
are rescaled in both directions anyhow all bearings are wanted and must
be kept.

Reported-by: Mihail Ivanchev <@MIvanchev>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-06 14:39:20 +02:00
Fini Jastrow
8f8776cf30 font-patcher: Make patch_set[attributes][params] a dict
[why]
The params are half way handled as dict, but if unset it is an empty
string. That makes accessing it needlessly complicated.

[how]
With no functional change the params becomes now a dict, also when it
does not contain any particular information.

At the moment that seems not nessecary, as it can only contain one key:
'overlap'. We could also rename 'params' to 'overlap' and just store the
value.

But we keep the generic params dictionary as it might come in handy some
time in the far future when more parameters are added.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-06 14:39:20 +02:00
Fini Jastrow
63db683b1a font-patcher: Add possibility to generate proportional font
[why]
Theoretically we can produce 3 types on fonts:
* A: Strictly monospaced font
* B: Allow bigger symbols, but advance width still monospaced
* C: Allow bigger symbols, advance width will vary

All have their uses.

Historically Nerd Fonts produced A and B.
Then we had kind of a breaking change with 2.2.0 that it produces
now A and C.

The commit
  b9b7a5080  Revert "Remove negative bearings on 2048-em glyphs"
restores the old (pre 2.2.0) behavior. But the type C fonts can be
useful, so maybe we can have them as option?

[how]
Add commandline option to be able to create all fonts types:
* A: specify -s or --mono or --use-single-width-glyphs
* B: specify nothing
* C: specify --variable-width-glyphs

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-01 12:36:32 +02:00
Fini Jastrow
1bb174e6bd Revert "Remove negative bearings on 2048-em glyphs"
This reverts commit 59c45ba4ef.

[why]
The commit breaks the non-mono Nerd Fonts for a lot of people.
The issue was not very good documented and investigation can not be
seen.

For the TITLE it should have affected only the 2048-em Symbols only
font, but in fact all patched fonts were changed. Maybe that was
intended, maybe not.

[how]
This will make the advance width again equal for all glyphs.
This enables the use of the non-mono variant in more terminals.
For wider symbols a space is now (again) needed after the symbol.
That is expected by a lot applications.

[note]
See Pull Request 764 for more details.

See next commits for alternative solution for original problem.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-01 12:32:09 +02:00
Fini Jastrow
98b28c8f3d font-patcher: Add possibility to generate normal and Windows font in one go
[why]
The normal and the Windows Compatible fonts differ just in the naming.
The patching is all the same.

For the CI we patch the original font for each output font. That is not
needed if we just want to create two differently named exports.

Skipping the patching where it is possible would save some time. Not
half the time, but the patching process itself is not too quick either.

[how]
Backup the original font names (as we need them again to deduce the new
Windows Compatible names).

Then do the patching once and the export twice, if parameter is given.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-01 12:15:00 +02:00
Fini Jastrow
3c3e2a49a7 font-patcher: Split code into more functions
[why]
The patch() function also does the font generation. This makes it
impossible to generate two fonts from one patch run.
(Will be needed in next commit).

The name setup could be done later.

[note]
This is no functional change, just reordering.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-01 12:15:00 +02:00
Fini Jastrow
35d3cfeff5 font-patcher: Fix generated font name output
[why]
After generating the patched font only a shortened name is displayed.

[how]
Obviously the two output lines were swapped...

If the fullname is None, and then output the fullname? :-}

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-09-01 12:15:00 +02:00
Finii
aff362ab36 [ci] Bump release version 2022-08-26 22:15:32 +00:00
Fini Jastrow
b71a9e474b Fix: Monospaced fonts wrong width
[why]
With commit
  821ac6817  Create symbols only font directly from sfd template

we have a default width for source fonts without a width (i.e. empty
fonts).

Unfortunately the detection for 'empty font' is wrong.

[how]
Reorder the commands such that we have a meaningful calculation.

Maybe this has been broken by too many (manual) rebases.

Fixes: #895

Reported-by: redactedscribe
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-26 19:31:48 +02:00
Finii
572221ec32 [ci] Bump release version 2022-08-26 16:44:55 +00:00
Fini Jastrow
aa48eea360 font-patcher: Show script version on run
[why]
We show only the Release version of the patcher script. Often it is
unclear which particular script people are using.

[how]
Also show the script version. This is a bit frickle, as it needs
developers to change the number manually (as with all other scripts in
the project that have a script version), but so be it.

This could be replaced by the 'current' git hash. But that has the
drawback that one needs to search for the commit to see how old the
script is.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-24 10:50:06 +02:00
Tor Arne Vestbø
6acec45622 font-patcher: Ensure PostScript font name does not contain spaces
When pulling the subfamily out of the sfnt_names SubFamily property,
we will get a subfamily with possible spaces, e.g. 'Bold Italic'.

When constructing the final unique font name (PostScript name), we
need to remove those spaces, to make the font name valid, otherwise
the font will fail validation with a warning when installing.

Fixes #413
2022-08-23 09:27:19 +02:00
Fini Jastrow
c3363c8202 font-patcher: Allow to run without Fontname* modules
[why]
People might want to use the font-patcher with just the one script file.
The error message does not help them to understand the problem.

[how]
Require the modules only if the user wants to use it (i.e. --makegroups).
Give the expected path in the error message.

We could also download the missing files instead, similar to #741
But that PR did not get any feedback yet, so I do not know if this is
something we want.

Anyhow, the fetching of missing parts should then be unified for both
usecases (i.e. Fontname* and src/glyphs).

And then, there is font-patcher.zip (which needs to be adapted), maybe
that is the way to go.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-22 10:53:05 +02:00
Fini Jastrow
49d99fe883 name-parser: Rename font-patcher option
[why]
The option `--parser` instructs `font-patcher` to come up with the font
naming by utilizing the FontnameParser object.

This sounds logical from a programmers perspective, but the option name
is not descriptive for end users of `font-patcher`

[how]
As usual naming is hard. A short but maybe more descriptive name for the
option can be `--makegroups`; as it describes what the option means for
the end user: functioning font grouping.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-22 10:53:05 +02:00
Fini Jastrow
2ccf0d001b Revert "font-patcher: Incorporate FontnameParser"
This reverts commit df42c917128701e9be199fb12d77a3fecad52cb1.

[why]
Having all the code in one big file is probably a maintenance nightmare.
We should develop other solutions to make the usage for end-users easy.
Future commits might do that.
2022-08-22 10:53:05 +02:00
Fini Jastrow
6be4335a59 name-parser: Create more usable short (Windows) names
[why]
The fontname for Windows can be quite unusable, for example
  `CaskaydiaCoveNerdFontCompleteM-`
for several different fonts, as this is the maximum allowed length of 31
characters that is enforced.

The style/weight is completely lost.

[how]
Split the name into base and style (at a dash `-`) and just shrink the
base name. Result for example:
  `CaskaydiaCoveN-ExtraLightItalic`

Use equal approach for the PostScriptName (although it is less likely
that length limit is ever met).

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-22 10:53:05 +02:00
Fini Jastrow
74eca532f2 font-patcher: Incorporate FontnameParser
[why]
A lot people expect the font-patcher to be a stand alone script. They
even think that the source glyphs (symbols) to be added to be somehow
magically there and one PR makes sure that they are fetched if missing.

The same problem arises when we have a script distributed over multiple
files. For maintenance reasons and code quality this is what one wants.
But that might hinder easy use of the font-patcher.

[how]
Put all the code in the main script.

That has an additional drawback: For the nameparser_test* scripts to
work we need stand alone files for that classes. Now the code is
duplicated and will get out of sync.

I have no solution for that, and it all boils down what Nerd Font wants
to do.

One solution would be to have font-patcher properly set up / divided in
many .py files, and to create one monolithic font-patcher from all the
sources on demand (via github actions or manually when someone pushes
changes to any of the constituends). That approach is taken by a lot of
C++ 'header only libraries' that originally consist of a lot files but
create one big 'all in one' file automatically from all the small files.

For now I guess we can live with the duplication, but we need to think
about a solution, as this will bite us sooner or later.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-22 10:53:05 +02:00
Fini Jastrow
abf3016dcf font-patcher: Allow to patch fonts without Fullname
[why]
Some CJK fonts seem to have no Fullname.

[how]
But they have a Postscript name. Use that for parsing the names.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-22 10:53:05 +02:00
Fini Jastrow
6d86114a38 Draft: Introduce a file name parser
DO NOT MERGE

[why]
A lot of the fonts have incorrect naming after patching. A completely
different approach can help to come up with a consistent naming scheme.

[how]
See bin/scripts/name-parser/README.md

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-22 10:53:05 +02:00
Fini Jastrow
821ac68173 Create symbols only font directly from sfd template
[why]
The symbol only fonts Symbols-1000-em Nerd Font Complete.ttf
and 2048-em in `NerdFontsSymbolsOnly/` are generated from
some 'almost' empty source fonts, that are assumable in turn generated
from the sfd font descriptions in `src/glyphs/`?

The process is not documented and we have issues in the generated font
(for example the glyph for capital `E` is defined (and empty) #581 #765).

[how]
Use the existing font definitions from `src/glyphs/*.sfd` directly as
source font. That needs a change in font-patcher because the empty
fonts have no glyphs that can be used to orient the scaling upon. In
that case scale on the source font definitions EM.

Then we need patch-em-all to also patch *.sfd fonts.

And finally we need patch-em-all to take a font specific command line
switch for font-patcher (compare 9e2bc9a26 of #723) to instruct it to
create a ttf rather than a sfd font file.

In the sfd file we additionally set the Panose type.
And the UnderlinePosition is adjusted to match the current patched font.

[note]
Also fix wrong glob pattern in patch-em-all `*.[o,t]tf`. The comma is
for sure some leftover from a '{}' shell pattern, that is not used
anymore. (This comment is probably outdated, due to rebasing.)

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-20 19:33:29 +02:00
Fini Jastrow
c5878d44db font-patcher: Ignore PPEM for non ttf/otf fonts
[why]
When the source font does not have a HEAD table (i.e. is not a ttf/otf
font but for example a sfd) we can not copy the PPEM and flag values.
The patcher crashes.

[how]
Just put the code into a try block. We could check the signature
instead, but this would add more and complex code.

Reported-by: Jakub Jirutka <jakub@jirutka.cz>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-20 18:29:13 +02:00
Fini Jastrow
40138bee9f font-patcher: Handle lowestRecPPEM
[why]
Some fonts set specific lower resolutions and handle the small rendering
very nicely. But fontforge does not copy that information when it opens
a font; rather some default values are always written. That can destroy
the small font rendering.

The responsible settings are the 'ppem_to_int' flag and the
'lowestRecPPEM' setting, both in the HEAD table.

[how]
After successfully patching and generating the new font we copy that
settings over from the source font.

Instead of using fontTools (and thereby requiring all users to pull that
dependency) we handle the raw font file changes ourselves.

Fixes: 612

Reported-by: nojus297
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-20 18:29:13 +02:00
Fini Jastrow
85324cc59a font-patcher: Fix wrong argument for postprocess
[why]
When the patched font does not have a fullname (which can never happen)
the postprocess is called with a wrong filename.

[note]
Also output the file name of the patched font, for easier access by the user.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-20 18:29:13 +02:00
Fini Jastrow
fbe07b8abb Fix Noto too wide
[why]
The 'monospace' width is determined by examining all the 'normal' glyphs
and taking the widest one.

'Normal' means 0x00-0x17f: the Latin Extended-A range.

Unfortunately Noto has the '1/2', '1/4', '3/4' that are all wider then the
normal (i.e. letter) glyphs.

[how]
Exclude a small sub-range from the 'find the widest glyph' that contain
no glyphs one would call 'letter'.

Fixes: #610

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-18 11:20:19 +02:00
Fini Jastrow
f9f3612e80 Update Font Logos to 1.0.0
[why]
Before Font Logos 1.0.0 there was no stable-codepoint guarantee, and the
later revisions (0.18) reassigned the codepoints. That makes updating
for us very hard, because we would have to resort the icons or follow
the codepoint changes.

With 1.0.0 this changed. That new major release introduced not only a
codepoint guarantee, but it also shifted the codepoints from the F100
region to the F300 region, where we put them anyhow (in most cases).
That is one subset less with 'dynamic base codepoint'.

The reassignment of codepoints in Font Logos kept the codepoints stable
for the icons we already have in release 2.1.0. But at the moment the
2.2.0 Release Candidate (which updated Font Logos with commit 557b8da)
have added glyphs, which are on different points as compared with the
Font Logos 1.0.0 release.

What I want to say, we need to get this straight, before our 2.2.0 RC
turns into a Release 2.2.0.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-18 11:16:44 +02:00
Fini Jastrow
3234fe0caf patcher: Fix grave (backtick) zero width
[why]
In ligature-enabled environments the accent grave will be rendered as
zero width, thus overlapping with the next character (in some source
fonts).

The problem is, that the glyph type in the sourcefonts is set to 'auto',
and fontforge exports these as 'mark' - the patched font will be broken.

[how]
There is no way we can get that glyph to be 'auto', but we can force it
to be an ordinary 'baseglyph' instead, and that will be respected on
export.

Maybe I should raise an Issue at fontforge... maybe later.

Fixes: #858
Fixes: #582

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-18 11:09:25 +02:00
ashfinal
7f04248439 Add icons for Emacs and Orgmode 2022-05-21 17:17:44 +08:00
Ryan L McIntyre
2ca9c163e2
Merge pull request #732 from ryanoasis/bugfix/monospaced-glyph-scaling
Bugfix monospaced glyph scaling
2022-02-05 09:44:12 -08:00
Fini Jastrow
702e4be813 font-patcher: Handle TTCs gracefully
[why]
When a True Type Collection file (.ttc) is used as font source this is
not handled and just the first file in the collection is processed and
saved. But the user is not informed.

When the target file format is True Type Collection, no file at all is
written.

These are two distinct cases, because you can in fact open a .ttc and
save the first font (patched) when specifying a different extension via
`-ext`. Or open a normal font and specify `ttc` as extension i.e. target
file format.

[how]
Check if a collection is to be opened. As we currently have no code to
loop through all fonts (and just the first font is processed) a message
is issued and we exit. Typically a user would want all the fonts and
would have to 'explode' the collection into multiple single font files
beforehand.

Prevent the target to be ttc, as that is not handled in fontforge at
all. To save TTCs a different API function is to be used. Unfortunately
fontforge does not care and just does nothing.

font.generateTtc() would have to be used with ttc extensions...

Anyhow. As the looping through all fonts is missing anyhow, and I feel
the usefulness is very slim, we just prevent silent failures with this
commit.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-01-05 16:55:52 +01:00
Fini Jastrow
e805b87997 font-patcher: Resolve rounding error when rescaling
[why]
The symbol glyphs are rescaled (when --mono is specified) so that they
have a predefined width after insertion in the source font (to be
patched font, called 'target font' below).

Sometimes the width of the glyph after insertion is off a bit, like
0.2% or so. This seems strange, as we calculate the target width
exactly.

[how]
As expected this are rounding errors. In the old code we take the
original width of the glyph when it is in the symbol font and
rescale it when it is in the target font. The width of the glyph
should be the same in the source and the target font, right?

It fact it is not, because the coordinate systems of the two fonts can
(and usually are) different. fontforge's magic scales the glyph
into the new coordinate system on insertion, such that it is approx
the same as before. But when the coordinate system is integer based
we get some small rounding errors just from copy and paste.

To solve this, we
- first copy the glyph from the source into the target font
- then determine the glyphs width
- then rescale the glyph to the target width

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-01-01 01:52:22 +01:00
Fini Jastrow
d887391ca0 font-patcher: Add docu for ScaleGlyphs
[why]
The ScaleGlyph just gives a lot of anonymous numbers.

[how]
Write down which glyphs are rescaled and group them to related
groups.

They are not changed to 'new' ScaleGlyph method.

[note]
Checked the current Devicons, and they are completely different to ours.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-01-01 01:50:47 +01:00
Fini Jastrow
d8579b1b11 font-patcher: Use new ScaleGlyph for problematic Font Awesome
[why]
While patching for --mono with Font Awesome we get glyphs that are
too wide, for example '_520' (0xF22B). In the symbol font original
it is about 1918 wide. According to ScaleGlyph FONTA_SCALE_LIST
it shall be scaled as 0xF17A - which is only 1664 wide.

[how]
Fill the ScaleGlyph of Font Awesome with groups of glyphs that shall be
kept same-sized after scaling.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-01-01 01:50:47 +01:00
Fini Jastrow
e5768e925c font-patcher: Redesign ScaleGlyph parameter
[why]
While patching for --mono with Font Awesome we get glyphs that are
too wide, for example '_520' (0xF22B). In the symbol font original
it is about 1918 wide. According to ScaleGlyph FONTA_SCALE_LIST
it shall be scaled as 0xF17A - which is only 1664 wide.

This results in too wide symbols in the patched font.

[how]
The ScaleGlyph dict works like this:
- 'ScaleGlyph' Lead glyph, which scaling factor is taken
- 'GlyphsToScale': List of (glyph code) or (list of two glyph codes
      that form a closed range)) that shall be scaled

Note that this allows only one group for the whole symbol font, and
that the scaling factor is defined by a specific character, which
needs to be manually selected (on each symbol font update).

The redesign drops 'ScaleGlyph' and changes the glyph list to:
- 'GlyphsToScale': List of ((lists of glyph codes) or (ranges of glyph codes)) that shall be scaled

Each item in 'GlyphsToScale' (a range or an explicit list) forms a group of glyphs that shall be
as rescaled all with the same and maximum possible (for the included glyphs) factor.

The old data structure is automatically rewritten to new entries.

[note]
This commit just changes the algorithm. As the new ScaleGlyph is not
used for any font, there is no change in the patched fonts.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-01-01 01:50:47 +01:00
Fini Jastrow
cfcd15aa25 font-patcher: Issue warning if symbol scaling fails monospace goal
[why]
Sometimes fonts patched with --mono are not recognized as monospaced
fonts.

One reason can be that the inserted glyphs are too wide. This will show
in the end in the font's advanceWidthMax property which is not congruent
to the normal font width.

[how]
After all the scaling and jiggling we double check if the new glyph
already in the to-be-patched is not wider than our design goal for the
width. Normally one would expect that this always holds.

An exemption could be if we insert ligatures, that are two spaces wide.
But at the moment we can not anyhow (because there is no way to add
information to the ligature tables right now).

If a glyph is wider a warning is issued.

No warning is issued if the glyph shall have some overlap. That overlap
is taken into account of this check.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-01-01 01:43:28 +01:00
Ryan L McIntyre
a5b43f63bb
Merge pull request #736 from ryanoasis/feature/remove-selection-todo
font-patcher: Copy selection instead of continuously regenerating
2021-12-24 14:39:36 -08:00
Fini Jastrow
c728079b61 font-patcher: Simplify output code
[why]
The code around `currentSourceFontGlyph` and `copiedToSlot` is
needlessly complex and checks for conditions that are impossible to
occur (possibly because the algorithm was different in the past).

It becomes rather hard to follow which variable holds what kind of value
and when.

[how]
Drop all the string-that-contain-hex-numbers stuff and use a regular
integer list/variable.

Format the string when it is output.

Drop obsolete checks.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-12-22 21:32:14 +01:00
Fini Jastrow
7e92302c12 font-patcher: Be explicit what shall be transformed
[why]
In the patch loop we use two methods to do something with the glyphs
- the glyph object directly (i.e. font[codepoint])
- a selection of glyphs in the font

Using the selection is a bit anonymous and depends on lines far away
(where the selection is set); direct glyph access seems to be easier
understood and is used almost everywhere.

Direct glyph access can not be used for copy() and paste(), but for
everything else.

[how]
The direct glyph addressing is already in use almost for everything, but
not for the transform() calls. This is changed.
Now we transform a specific glyph and not 'all selected glyphs' (with
selection = that specific glyph).

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-12-22 15:00:39 +01:00
Fini Jastrow
355a7c55a8 font-patcher: Remove unneeded code
[why]
The selection is never used.

Later in the code we use a sourceFont selection to paste the glyphs into
it, but that is selected just there, before, and locally not totally.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-12-22 14:59:03 +01:00
Fini Jastrow
a19800195a font-patcher: Copy selection instead of continuously regenerating
[why]
This is a TODO item. Well, two in fact.

The symbolFont's selection is used for two things
- the main loop to iterate over all glyphs to insert
- to select the one glyph that is actually copied over

Because the main loop uses iterators on the selection.
The iterator is not 'stable' but invalidates if the selection
is changed.
The current code therefor restores the old selection before the loop
jumps to the head again.

This design is not very robust.

[how]
We need the selection to copy the symbol glyph.

But we can rewrite the loop that it does not need the selection at every
iteration, but that the selection is copied into a list, and we loop
over that list - which is independent on a later selection state.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-12-22 14:50:08 +01:00
Ryan L McIntyre
725c9df524 Follow up changes for new Codicons glyph set 2021-12-22 05:47:28 -08:00
Ryan L McIntyre
611f9279f9
Merge branch 'master' into codicon 2021-12-22 13:28:52 -08:00
Ryan L McIntyre
66adcfe7c9
Merge pull request #695 from ryanoasis/feature/panose-monospaced
font-patcher: Improve 'Mono' compatibility with Windows
2021-12-22 13:17:48 -08:00
Ryan L McIntyre
6c41bf7dfa Fixes a few issues brought up in #724 2021-12-19 11:12:08 -08:00
Fini Jastrow
5170911e3b font-patcher: Improve 'Mono' compatibility with Windows
[why]
Some of the patched Mono fonts do not turn up in the font chooser
of Windows CMD and PowerShell (and probably more).

[how]
For some reasons Windows does not identify the fonts as being strictly
monospaced, so they are hidden in that font choosers.

For the monospaced fonts we set now the Panose proportion 'monospaced'.
Windows seems to honor the Panose properties.

It is not clear why we need to set the old Panose props, especially as
Cascadia Code does not (!) set them and is still detected as monospaced.

Anyhow, the way Windows detects if a font is monospaced is a mystery (at
least for me), and this works, so ;-)

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-12-17 22:59:24 +01:00
Ryan L McIntyre
7eb5ce5926
Merge pull request #720 from ryanoasis/bugfix/cant-detect-extension
font-parser: Allow patching without --ext
2021-12-16 19:14:02 -08:00
Fini Jastrow
f6b6174680 font-parser: Allow patching without --ext
[why]
Sometimes fontforge returns None for font.path. That should not be the
case according to specs:

font.path
    (readonly) Returns a string containing the name of the file from
    which the font was originally read (in this session), or if this
    is a new font, returns a made up filename in the current directory
    named something like “Untitled1.sfd”. See also font.sfd_path.

This seems to be the case for fonts that do not have a fullname set.
I did not search for nor file any issue at Fontforge.

[how]
In fact we already have the original font file name, and we want to
retain its extension anyhow (if nothing is specified), so we use the
filename that we opened to determine the extension.

[note]
Related: #412
Related: #641

[note]
This was the sole usage of font.path.
Has been introduced with commit d8b760aee which looks uncritical.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-12-15 18:24:13 +01:00
Fini Jastrow
ef38ad6324 font-patcher: Remove obsolete metadata on glyph exchange
[why]
When we overwrite a glyph that originally had some special handling, be
it a substitution or position table entry (GPOS/GSUB), that special
handling is usually not appropriate anymore and has to be removed.

If we need special lookup table entries for the new glyph we would have
to add them later anyhow, because we can not rely on their existance.

In Issue #509 it was a ligature entry, that replaced 'f' followed by 'i'
with the 'fi' ligature. The ligature glyph is overwritten by us with a
telephone symbol and the substitution table entry makes no sense
anymore.

[how]
If we overwrite a preexisting codepoint we remove it from all lookup
tables.

Thanks to all other reporters with details.

Fixes: #509 #254

Reported-by: mangelozzi <mangelozzi@gmail.com>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-12-13 16:55:48 +01:00
Ryan L McIntyre
e323f2991a
Merge pull request #693 from ryanoasis/feature/set-sfnt-version
font-patcher: Set SFNT Version
2021-12-11 17:42:42 -08:00
Ryan L McIntyre
9633b4d362 License audit work to fix some licensing issues in #266 2021-12-11 08:10:08 -08:00
Ryan L McIntyre
f33b0298fd
Merge pull request #692 from ryanoasis/bugfix/fstype-font-does-not-open
font-patcher: Reintroduce fsType fix
2021-12-11 11:16:39 -08:00
Ryan L McIntyre
f943e8ec81
Merge pull request #593 from Finii/bugfix/use-correct-source-font-metrics
font-patcher: Use correct source font metrics
2021-12-11 10:32:34 -08:00
Charles Strahan
96ab7f6ef7 add support for codicons
Closes #620
2021-12-04 16:44:01 -06:00
Fini Jastrow
3384fc302c font-patcher: Give meaningful error messages on trivial open fails
[why]
When the font file is not existing the message we get is either
unreadable or missleading (at least for normal users).

[how]
Explicitely state why we can not open a font file, at least in the cases
where we can.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-11-30 07:58:12 +01:00
Fini Jastrow
0d905e2293 font-patcher: Set SFNT Version
[why]
The Nerd Font Version is not added to the SFNT Version.
This is also a TODO item in `font-patcher`.
The SFNT-Revision is not updated at all.

[how]
Set the SFNT Version and Revision.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-11-29 10:11:04 +01:00
Fini Jastrow
f554ed50c6 font-patcher: Reintroduce fsType fix
[why]
With commit
  f7d6fcb5 font-patcher: Allow processing of fonts with fsType set
we added support for fonts with the fsType set. This came up in
issue #686 with font 'Bicubik'.

The solution in that commit uses (modern) textual flags in the
`fontforge` open() method. But they have been only introduced in 2020,
so people using older `fontforge` could not patch anything anymore.
This has been reported in issue #691.

As a quick fix the fsType support has been removed with commit
  ab6fa3c5 Reverts part of #687 * the patcher refuses to patch all/most fonts with this flag in the open options

[how]
Revert f7d6fcb5 but use the old fashioned numerical open flags
interface instead.

[note]
The textual open() flags have been introduced into `fontforge`s python
interface with their commit

4a76712f0c

  Font Open flag improvements
  * Document more Open flags
  * Add string tuple interface to python FontOpen API

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-11-28 11:06:17 +01:00
Ryan L McIntyre
ab6fa3c562 Reverts part of #687
* the patcher refuses to patch all/most fonts with this flag in the open options
2021-11-27 11:33:18 -08:00
Fini Jastrow
204a43aafb font-patcher: Fail with meaningful message if font can not be opened
[why]
When fontforge is not able to open the font we fail with a meaninless
exception. Users might think that the font-patcher script itself is
broken.

[how]
Exit the script with a hint how to get more information if fontforge was
not able to open the font.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-11-24 08:28:53 +01:00
Fini Jastrow
f7d6fcb59c font-patcher: Allow processing of fonts with fsType set
[why]
Through fsType certain restrictions can be set on a font. When fontforge
is used in interactive mode the user can override the restrictions with
a popup dialogue. The font-patcher script dies instead, without any
meaningful message.

[how]
Allow the script to ignore fsType settings when opening.
The restrictions will still persist into the generated patched font.

[note]
This came up with Bicubik by Anton Kudin, that has fsType = 2
(modification restriction) set.

Fixes: #686

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-11-24 08:28:53 +01:00
Ryan L McIntyre
fc8a4fb74e Workflow for building release candidate
* debug font patcher version
2021-11-21 13:11:25 -08:00
Ryan L McIntyre
be0069cf91 Merge branch 'puppet_icon' of https://github.com/dhollinger/nerd-fonts into dhollinger-puppet_icon 2021-11-17 12:40:23 -08:00
Ryan L McIntyre
b9c0e2f139
Merge pull request #681 from BiscuitTin/master
Add Caskyadia Mono to RFN replacements
2021-11-17 20:36:47 -08:00
Kexy Biscuit
2c104d287c
Fix typo. 2021-11-12 12:16:12 +08:00
Kexy Biscuit
1454141c95
Add Caskyadia Mono to RFN replacements. 2021-11-12 12:01:18 +08:00
David Hollinger III
c01e5f62f8
Add the official Puppet icon as a custom icon 2021-08-13 12:51:35 -05:00
fracsinus
c72b0d98c1 fix over-indentation 2021-07-26 06:24:27 +09:00
Aisha Tammy
c920b5b26b
allow setting custom glyph storage directory
Useful for allowing installation in system wide
locations as a package from the package manager.
This way the script can be installed in /usr/bin
and glyphs can be in /usr/share/nerd-fonts/glyphs.

Signed-off-by: Aisha Tammy <floss@bsd.ac>
2021-04-24 14:24:21 -04:00
Ryan L McIntyre
3deb6166be
Merge pull request #551 from daniruiz/master
Update font-logos with new linux icons
2021-04-10 20:56:06 -07:00
Ryan L McIntyre
9f24ccf1a7
Merge pull request #545 from andys8/icon-purescript
Adds PureScript glyph/icon
2021-04-10 20:32:17 -07:00
Fini Jastrow
ca26382644 font-patcher: Use correct source font metrics
[why]
With a source font where Win Ascent/Descent differs from Typo
Ascend/Descent newly added symbols that are intended to be centered
_within the visual space_ can end up too far up or down.

The happens for example when patching CascadiaCode. Added glyphs like
the Ubuntu logo (unicode 0xF31B) is not centered between the square
brackets or on a line with the less then and other centered glyphs.

[how]
The calculation takes the Win Ascent/Descent to calculate the visual
hight. That information is a mix of hight and line spacing and can be
misleading.

Therefore, if use_typo_metrics is set in a font, we obey that flag
and use the typo metrics values instead.

[note]
Some websites with further information follow.

https://github.com/googlefonts/gf-docs/tree/main/VerticalMetrics
  > Hhea metrics are used in Mac OS X, whilst Microsoft uses
  > Typo when Use_Typo_Metrics is enabled

https://docs.microsoft.com/en-us/typography/opentype/otspec160/os2#fsselection
https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6hhea.html

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-03-17 09:14:27 +01:00