Commit graph

285 commits

Author SHA1 Message Date
Fini Jastrow
5b36e8ec16 font-patcher: Keep overlap in proportional font
[why]
The previous commit is somewhat incomplete in some cases and plain wrong
in others (with proportional fonts). Examples:

The Heard 0x2665 gets a positive right side bearing, which is
unexpected. The commits prevents negative right side bearings but not
positive ones.

The glyphs with overlap (which are the Powerline ones) like 0xE0B0 and
0xE0B2 end up in wrong sizes.

This can especially be seen with the Symbols-Only (non-Mono) font,
because that is (secretly) a 'Nerd Font Propo' (--variable-width-glyphs)
font.

[how]
This is kind of a design choice: As with the other patched font variants
we ignore existing borders (positive bearings) around the glyph. The
previous commit tried to keep them, which seems to be impossible and
is inconsistent). Also negative bearings would be ignored (but there are
none).

The only place where bearings come into play is now when we have
overlap. All non-overlap glyphs render without any bearing.

If we have overlap we need to
a) reduce the width by the overlap
b) introduce a negative bearing on the appropriate side

First we remove any left side bearing by transforming the glyph to the
side, such that the bearing becomes zero.

For left-side overlap we additionally transform the glyph by the overlap
amount to the left (as usual). This creates the neg. left bearing.

For right-side overlap we keep the left bearing to be zero.

After correcting the left-side bearing (by transforming) we set the
corrected width. That is the width subtracted by the overlap.
In the left-aligned case this makes the right-side bearing zero.
In the right-aligned case this results in a negative right-side bearing.

Note how fontforge handles size and bearing changes:
  Fontforge handles the width change like this:
  - Keep existing left_side_bearing
  - Set width
  - Calculate and set new right_side_bearing

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
946c1d09dd font-patcher: Preserve symbol advance with variable width font
[why]
Very slender symbols added to a proportional patch end up being at least
one mono-width wide, which mixes proportional and monospaces metrics.

[how]
When we create a proportional font we should
a) not try to align them in a (non existing) monocpace cell
b) insert the symbols with their own (advance) width

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
417395c1a0 font-patcher: Fix vertical alignment for non-Mono with ScaleGlyph
[why]
When creating a non-Mono font the vertical alignment does not observe a
possible ScaleGlyph group. Icons that should be far up (like the
degree-icon, which is ScaleGlyph-grouped together with a full height
symbol) end up centered vertically.

[how]
When the glyph is not scaled we just do not use the ScaleGlyph.
But that data is also needed for just shifting the glyph.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
f72104ed9b font-patcher: Fix another weather icon scale
[why]
The weather icons have a glyph for degress, a small cirle for up.
That gets completely destroyed on scaling to fit.

[how]
Just add a scaleGlyph set.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
b3f1165906 font-patcher: Fix unequal weather icon scale
[why]
The weather icons have some symbols that have a different bounding box
but should nevertheless be scaled alike, because for example one is the
outer line of a thermometer and one is the matching stem.

[how]
Just add a scaleGlyph set.

Fixes: #915

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
106270c76b font-patcher: Add more entries to ScaleGlyph of Font Awesome
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
c5879c90e2 font-patcher: Fix wrong ScaleGlyph in Font Awesome
[why]
This is obviously a complete mess.
Firstly it seems the author (me) used the array elements as ranges,
which is of course not possible. And them the end has a typo.
Sigh.

[how]
Not consecutive codes must all be given one by one (unfortunately).

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
dec9168c24 font-patcher: Whitespace cleanup
[why]
Man do I hate these indented tables in code. Specifically because they
break conciseness of commits if one needs to re-indent unrelated
entries.

[how]
Do it in this separate commit that does not change functionality.

[note]
Smuggled in unrelated code shift by some lines.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
90bde735f7 font-patcher: Use ScaleGlyph BB to align glyph
[why]
If we define glyph groups in ScaleGlyph we want them to be scaled alike,
but they are aligned individually, which makes previously matching pairs
looking odd.

[how]
If we have a combined bounding box stored in a ScaleGlyph range, that
box is used to align all symbols in the range identically.

If the symbol font is proportinal only the v alignment is synced.
If the symbol font is monospaced v and h alignemnts are synced.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
847aeba420 font-patcher: Store if symbol font is monospaced in ScaleGlyph
[why]
We might want to handle monospaced symbol fonts differently then
proportional symbol fonts. Proportional symbol fonts usually have
no uniform symbol scaling, while monospaced symbol fonts usually have a
well designed placement of the symbols within the cell.

[how]
Add new member to the dimensions dict.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
e4780ad65d font-patcher: Store combined BB in ScaleGlyph
[why]
If we use a ScaleGlyph range (i.e. use the same scaling on a range of
glyphs; the scaling is determined by the combined bounding box of all
that glyphs), we probably want to shift the glyphs identically as well
to preserve relative positions not only sizes of the glyphs within the
range.
But the data is stored nowhere.

[how]
Store the 'virtual' bounding box along with the scale.

[note]
With combined (virtual) bounding box we mean the bounding box that a
glyph would have where all the individual glyphs would be stamped over
each other without shifting/scaling beforehand.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
cd026579c5 font-patcher: Fix empty glyph handling in get_multiglyph_boundingBox()
[why]
When the combinded bounding box of a range of glyphs is to be determined
and the range contains an empty glyph the resulting bounding box will
always include the [0, 0] point (that is the point-ish bounding box of
the empty glyph).

[how]
If more than one codepoint is to be considered empty glyphs are ignored.
But if only one (concrete) codepoint is queried do return the empty
(i.e. [0, 0, 0, 0]) bounding box.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
2b9a41f871 font-patcher: Add message when redistributing linegap
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
4cce1d8716 font-patcher: Fix new ScaleGlyph (for codepoint F000)
[why]
First the new ScaleGlyph has been introduced with commit
  e5768e925 font-patcher: Redesign ScaleGlyph parameter

and afterwards it has been enhanced to avoid rounding errors
with commit
  983226a70 font-patcher: Fix scaleGlyph related rounding error

The later commit uses a function that explicitely says it will destroy
the glyph at a specific location, AFTER we already patched in one glyph
(namely F000).

It does not look too bad, bad that glyph is not correctly rescaled or
translated. Only that glyph is affected because only Font Awesome uses
the new ScaleGlyph capabilities, and only the first glyph of a set is
affected.

[how]
The ScaleGlyph calculations need to be done before the final glyph is
patched in. It is shifted some lines up. Usually that glyph is not
existing in the to-be-patched font, so we create a dummy first.

Also need to correct distinction between 'unicode in symbol font' and
'unicode in to-be-patched font', as this would bite us in cases where we
move the symbol's codepoint.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
5c5c51e7b1 font-patcher: Sanitize output filenames
[why]
The filename is determined by the font (family) name. The font name
might include characters that are forbidden to use in filenames.

[how]
Filter output filesnames and prevent any character that is likely
forbidden under Windows.
Also prevent control characters.

Translate Windows path separators to posix.

Fixes: #632

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-12-22 10:00:19 +01:00
Fini Jastrow
dd143be24a font-patcher: Fix crash on some custom sets
[why]
When a custom set is to be patched and that set contains the .notdef
glyph the script crashes.

[how]
The glyphs has an unicode codepoint of -1, a code that we explicitely
not patch. That leads to confusion when we try to determine the
codepoint to be used for that glyph, because it has none.

Exclude negative codepoint glyphs when we determine the selection of
to-be-patched glyphs.

As last resort for broken custom sets skip over glyphs that come out of
order (which should be impossible).

Fixes: #1005

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-11-26 15:38:12 +01:00
Fini
c156c4d37d
Merge pull request #978 from ryanoasis/feature/update-seti
Update seti to current version
2022-10-21 14:43:06 +02:00
Fini Jastrow
677aa3ced9 Activate new Seti icons
The end codepoint needs to be shifted, now all new icons are patched in.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-10-21 13:03:53 +02:00
Fini Jastrow
148b0c4455 Sunset ligature removal
[why]
Keeping the ligature removal tables up to date with source font updates
is quite a maintenance burden.

Usually if a terminal supports ligatures at all it has an option to
disable them.

Present ligatures do not prevent monospaced fonts and monospaced
detection.

It was only present in v2.0.0, and the code has been broken with v2.1.0.

[note]
Updated example ligature removal table to the one for Iosevka.
Left stubs in relevant code passages to facilitate finding this commit.

Fixes: #976
Fixes: #975
Fixes: #973

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-10-20 08:44:55 +02:00
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