Commit graph

1620 commits

Author SHA1 Message Date
Fini Jastrow
ebd381c86b font-patcher: Centralize scaling code
[why]
The glyph rescaling is scattered about two functions and several
branches. It becomes hard to follow what is done when and why.

[how]
Use one function that determines any glyph scaling, that includes all
handling except ScaleGlyph related stuff.

This simplifies the code in copy_glyphs() a lot, and keeps all the scaling
in get_scale_factors().

[note]
No behavioral change introduced with this.

[note]
Well, it fixes the possible problem (it will never happen, but lurks)
that a glyph is in the ScaleGlyph range AND has Y scaling set.

The old code first uses the ScaleGlyph scaling and afterwards violates
it by mindlessly doing the Y stretch. This would not happen anymore with
the new code. If a ScaleGlyph is specified for a certain glyph, that
ScaleGlyph is followed and nothing else.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-11 16:32:27 +01:00
Fini Jastrow
99c2608313 font-patcher: Fix more 'Nerd Font Mono' 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 some fonts that claim to be monospaced still have some
glyphs that are wider than the others.

[how]
Exclude a small group of glyphs from the 'find the widest glyph'.
The list is specifically targetted at the fonts we patch, see PR #1045.

Most of these glyphs are either visually small and it is unclear why
they are too wide (like double-quotes), or they are from the real
extended set, notably all the Eth (D with a slash) and other added-slash
or added-caron glyphs.

In ignoring them we might 'break' these specific glyphs for the people
who use them (like: they extend out of the cell into the next), but that
is the only way to keep the 'monospaced promise' without redesigning the
actual font.
But without these exceptions we have Nerd Font Mono fonts that increase
the cell width so that 'normal text' is rendered almost unreadable.
So this is an improvement for most users; and I see no way so solve
these font issues for all users (without redesigning the font itself ;).

Also add a 'warning' if a (still) problematic font is to be patched.
As reminder for self-patcher or when we add fonts here.

[note]
Related commit
  fbe07b8ab  Fix Noto too wide
  2945cecd1  Fix Overpass Mono too wide

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-11 12:58:27 +01:00
Fini Jastrow
8845e3fb99 font-patcher: Fix Overpass Mono 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 Overpass (Mono) has wide-as-two-letters IJ and ij ligatures.

[how]
Exclude a small sub-range from the 'find the widest glyph' that contain
these ligatures. Yes they will kind of break, but what can we do if we
want to create a strictly monospaced font?

[note]
Related commit
  fbe07b8ab  Fix Noto too wide

Related: #1043

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-11 12:58:27 +01:00
Fini Jastrow
9514cbc509 docker: Fix fontforge problem
[why]
The docker image can not start fontforge:
  Error relocating /usr/bin/fontforge: FindProgRoot: symbol not found

[how]
The problem might be that we base on the 'latest' Alpine container, but
install a edge fontforge.

If I see this correct:
https://hub.docker.com/_/alpine/tags

'latest' is the same as latest-stable. Probably we should use a matching
apk repo.

Fixes: #1042 (maybe, need to push to test)

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-10 12:33:51 +01:00
Fini Jastrow
8bcd7d9033 font-patcher: Fix ScaleRule evaluation (2)
[why]
Forgot to increase the script version with previous commit.

But especially after a bugfix we need a new version to identify
if people use the version before or after
the fix (e.g. docker image).

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-07 10:05:53 +01:00
Fini Jastrow
05a9ec8b6d font-patcher: Fix ScaleRule evaluation
[why]
In some cases only some ScaleRule glyphs are used.

[how]
Store mixture of integers and ranges for ScaleGlyph (as is done for
ScaleGroups).

Correctly evaluate mixture of integers and ranges.

[note]
Came up with PR #773

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-07 09:48:04 +01:00
Fini Jastrow
a56a4fad8e font-patcher: Warn if sourcefont is a VF
[why]
fontforge is not really able to work with OpenType variable fonts, at
least not with all. Some support is available as MM, for older formats.
But anyhow we do not really create a patched variable font but a fixed
font.

People might ignore all the errors Fontforge throws on opening, so an
explicit message might be in order.

[how]
It is not possible to detect a VF input font with current fontforge
reliably. Instead we search for the existence of one of the tables that
are  needed for a variable font. We can not rely on STAT, because that
might be also used in fixed fonts.

Some fontforges might crash on VFs, so we give a warning before we even
open the font and one after the patched font has been created.

Fixes: #512

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-06 16:42:01 +01:00
Fini Jastrow
0154fe23a2 CI: Update release to Fontforge January 2023 Release'
[why]
Fontforge had a new release. There is no particular error it fixes that
we suffer on, but keeping up to date?

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-06 11:32:15 +01:00
Fini
68af5c3ac5
Merge pull request #1036 from ryanoasis/feature/testability
Feature/testability
2023-01-06 11:15:18 +01:00
Fini Jastrow
7f03f6c750 CI: Update actions
[why]
The actions have several warnings.

[how]
Update them all.

For example action-gh-release 0.1.14 runs on node12 which is deprecated.

upload-artifacts 3 also switches to node16 and 3.1.1 removes obsolete
set-output.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-06 10:48:31 +01:00
Fini Jastrow
48a0ff8e63 CI: Fix release run 2/2
[why]
For some reason setting of some variables broke.

[how]
Did not spent any time to find the reason, just rewrote it in a more
readable and debuggable manner and now it works (??!)

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-06 10:09:18 +01:00
Fini Jastrow
f7e5858d71 CI: Fix release run 1/2
[why]
The release run does not work with the fontforge AppImage anymore.

Obviously Github's 'ubuntu-latest' changed :-}

[how]
Install missing fuse.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-06 10:09:18 +01:00
Fini Jastrow
95a8f87910 CI: Enable parallel processing of patching
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-06 10:09:18 +01:00
Fini Jastrow
785089c66c CI: Unify release timestamp
[why]
Although all font files of one font (directory) have the same timestamp
the different fonts (e.g. Agave vs Roboto) have still slightly different
timestamps.

[how]
Note the time when the release workflow has started.
Use that as timestamp for all fonts.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-06 10:09:18 +01:00
Fini Jastrow
49e98b64d7 CI: Add FontForge January 2023 Release to tests
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-06 08:32:48 +01:00
Fini Jastrow
129e114ddf gotta-patch-em-all: Reactivate parallel processing
[why]
The messages from parallel font-patcher runs can be very confusing, so
it has been disabled some time ago (without a comment in that commit?!).

However, if someone wants to repatch multiple fonts on a local machine
it might be beneficial to run more than one process to have work on all
cores.

[how]
Add option to select multiple processes in parallel.
Limit the amout to 8, which might be a good value for typical end-user
machines with 4 cores and 8 threads.

Patching Cascadia Code (12 fonts) took these times on my machine:
  1 job:  21m 55s
  4 jobs:  6m 24s
  8 jobs:  5m 14s  (this runs 8 and then the remaining 4)
 16 jobs:  4m 48s  (this runs 12 in parallel)

Adding a proper `-j` that takes a numeric argument is rather too much
work for my taste, so we stick with 8 for now.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-06 08:32:48 +01:00
Fini Jastrow
257d6882fa Make output less verbose (with option)
[why]
Running gotta-patch-em-all creates a lot of output that is most likely
not wanted.

[how]
Add --verbose option to gotta-patch-em-all.
Hide debugging information unless it is wanted by specifying this option.

Also change font-patcher to produce less verbose output and respect
--quite in more places.

This includes a change that we try to tweak the font flags only if
source and destination font are ttf or otf, because we can not read the
other raw font files anyhow.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-06 08:32:48 +01:00
Fini Jastrow
3c4fa008c1 gotta-patch-em-all: Add options to simplify patcher testing
[why]
When working on the font-patcher the developer needs to test the changes
on a number of fonts. This is usually a manual call of `font-patcher`
and afterwards a 'diff' of the newly created font with the 'old' font in
the patched-fonts/ directory with fontforge (which has a font-compare
option).

If you run gotta-patch-em-all normally the newly generated font will
replace the existing font and git will ALWAYS show it as different. The
reason is that at least the timestamp in the generated font has changed.
Far more easy would be if the new gotta-patch-em-all run could keep the
previous timestamps, in that way one can immediately see that the old
and new fonts are bitwise equal (via git).

Furthermore if you expect a change and want to show the differences of
old and new font in fontforge you need both fonts in the filesystem.
But a normal gotta-patch-em-all run replaces the font. A different
destination folder would help here.

[how]
Introduce two new (independent) options to
a) keep the timestamp equal to previous patch run
b) generate the fonts in a different directory

While b) is straight forward, a) is a bit more complicated, esp because
filenames can change and so on. So the script examines just one (1)
random font in the specific font directory and uses its timestamp. In
most cases this is correct enough if the developer uses gotta-patch-em-all
consequently.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-06 08:32:48 +01:00
Fini Jastrow
40ded7c2f0 gotta-patch-em-all: Create all fonts with unified release timestamp
[why]
All the fonts will have different timestamps, and within each font the
creation and modification date might also differ. That is quite
confusing and makes automated testing very complicated.

[how]
Use one date-time for ALL fonts and for creation and modification date
in the font file.
But do not change the date-time if we already set that somewhere before :-}

Also remove the 'special' properitary fontforge timestamp tables FFTM from
the patched fonts. This is only possible since FontForge 20th Anniversary
Edition.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-06 08:32:48 +01:00
Fini Jastrow
a577d7261a gotta-patch-em-all: Switch to proper parameter handling
[why]
Oh boy do I hate the boilerplate code needed with optargs, but without
it every parameter becomes a burden.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-05 20:02:18 +01:00
Fini Jastrow
f448eba396 gotta-patch-em-all: Fix unfiltered (all) patch run
[why]
When we want to patch all fonts by calling the script without any
options it fails.

[how]
Give the correct regex to find all directories.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-05 20:02:18 +01:00
Fini
33d6ee3b4f
Merge pull request #916 from ryanoasis/bugfix/weather-scales
Fix unequal weather icon scale

Tests will come in extra PR.
2023-01-05 19:54:38 +01:00
Fini Jastrow
1e134ca8ff font-patcher: Add ratio limit to xy scale
[why]
The powerline glyphs (and only them) undergo a xy scaling, where both
dimensions are maximized into the 'cell'.

Normally cells are taller than wide, and everyting looks fine. But we
have square cells (e.g. 2048 * 2048) with the SymbolsOnly font, and
there might be some self patched font that has similar very-wide (in
comparison to hight) cells.

In these fonts some powerline glyphs look rather ugly. For example the
'half cicles' become very wide and un-round, the triangulars become very
pointy.

[how]
Add a new patch-set attribute 'xy-ratio'. When that is set the vertical
(y) scaling is done as usual but the horizontal (x) scaling is limited
such that the width/height ratio is maximally the attributes value.

For example setting it to 0.75 the height is maximized (as usual) but
the width is maximized to be less then 0.75 times the hight (or as wide
as the cell is, whatever is smaller).

It will work with both, 'xy' and 'pa' scaling, at least theoretically.
It has been only checked where it is used now, i.e. with 'xy'.

A possible overlap is not taken into account.

[note]
The values are taken for this reasons:
- 0.59: This is the original half-circle ratio, higher values make them
        loose the (half) circular appearance
- 0.5:  The half circle lines are more shallow
- 0.7:  The triangulars should not be too pointy (random number)

Fixes: #658

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 17:40:25 +01:00
Fini Jastrow
676e60af71 font-patcher: Add documentation on ScaleGroups
[why]
The old doc was a bit unclear and I always had to read the code when
changes / additions to ScaleRules were needed.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:28:05 +01:00
Fini Jastrow
69ccea2ff5 font-patcher: Allow ScaleGroups and ScaleGlyph in one ScaleRules
[why]
If a ScaleGlyph is defined that ScaleRules will just be that one rule,
even if in parallel the user specified some ScaleGroups.

So it is either ScaleGroups or ScaleGlyph but not both.
If someone specifies both there is no warning or check.

[how]
Just allow both. Rewrite the ScaleGlyph to an additional (last) entry in
the ScaleGroups.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
122672b56b font-patcher: Simplify some ifs
[why]
There are several instances of
  if x is True:

This should be written as
  if x:

instead. See PEP 8:
https://peps.python.org/pep-0008/#programming-recommendations

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
70c4d034a9 font-patcher: Improve Nerd Font Propo with ScaleGroups
[why]
Assume a set of monospaced icons in a ScaleGroup that scatter all about
(like Braille).

With --variable-width-glyphs we forcefully remove all left side
bearings and set the width to the width of the combined bounding box.

This is not correct, usually with monospaced ScaleGroup icons we should
preserve the original advance width.

[how]
Do not remove left side bearings on ScaleGroup glyphs in
--variable-width-glyphs mode.

Set the width of any glyph in --variable-width-glyphs to the 'monoscaped
advance width' if that particular glyph has one (from a ScaleGroup).

The effect is that all positive bearings will be 'added' and put on the
right hand side of the glyph, while the glyph itself, or rather the
combined bounding box, is still strictly left aligned.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
e4e6887d9e font-patcher: Rename ScaleGlyph to ScaleRules
[why]
We have still a confusing naming. There are two different things that
are called 'ScaleGlyph':
- The setting in the patch set
- The reference glyph for old style scaling

[how]
Rename the patch set member to ScaleRules, as this is what in contained.
Also rename variable names accordingly.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
6bfad7872e font-patcher: Rename new GlyphsToScale
[why]
We now have the 'old' and the 'new' GlyphsToScale things, which behave
differently, but they have the same name. That can lead to confusion. At
least I am always confused when I look at the code after a month or so.

[how]
Call the 'new' method 'ScaleGroup' instead.

The 'new' feature (which includes creating a combined bounding box and
synchronized shifting) 'ScaleGroup'.

The 'old' feature (which scales all glyphs as if they would have the
size of one reference glyph; shifting is individual) still consists of
'ScaleGlyph' and 'GlyphsToScale'.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
2ba5dec363 font-patcher: Simplify bounding box scaling
[why]
The code looks so compliacted while in fact it is not (so much).
Rounding sometimes and sometimes not is hard to reaon about. The
un-rounded values should in principle be better, but there is some
rounding hidden in the font that we can not really simulate, so simulate
what we can.

[how]
Always scale (even if factor is one) and round to integer the BB.

[note]
Also use 'is not None' ideom.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
dc3b2183b4 font-patcher: Fix wrong advance width after group scale
[why]
The advance width in the bounding box data is sometimes wrong (usually
to small). Turned out only AFTER the glyph scaling.

[how]
The wrong scaling factor has been used *duh*.
Advance width is of course X axis.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
3cfe4a1a06 font-patcher: Fix monospaced glyph collection detection
[why]
When only one symbol glyph is examined we conclude that it comes from a
monospaced glyph set.

This might be correct or not, but when we can not positively say it is
monospaced we should not handle it as monospaced.

[how]
We require at least TWO glyphs with the same width (and no glyph
with a different width) until we set the 'advance' bounding box
property. Which says that this particular glyph subset is monospaced.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
Fini Jastrow
46eb6e451c font-patcher: Fix GlyphToScale for 'xy' scales
[why]
The scale-glyph-data is used only for 'pa' scales, but thereafter used
for all shifts, even if the scaling has been 'x' or 'y' or both.

As we do not use GlyphToScale for anything but 'pa' scaled glyphs that
should not make any difference right now. But it will be an obscure bug
if we ever want to handle the Powerline symbols with a scale group.

I do not know if that will ever happen, but I tried it whilst
experimenting spending hours on finding this bug.

[how]
Access the GlyphToScale data and use it even for 'x' and 'y' scaling, if
we have it for the particular glyph.

[note]
Also change 'invalid' flag from False to None.
Also use 'is None' or 'is not None' for comparisons with None.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-01-04 16:27:03 +01:00
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
allcontributors[bot]
52cf6f9b6e docs: update .all-contributorsrc [skip ci] 2022-12-21 17:18:59 +01:00
allcontributors[bot]
333785141e docs: update CONTRIBUTORS.md [skip ci] 2022-12-21 17:18:59 +01:00