[why]
Cognitive burden of shorten_style_name() is 13 (allowed 9).
Duplicate code
if self.use_short_families[1]:
weights = FontnameTools.short_styles(weights)
styles = FontnameTools.short_styles(styles)
[how]
I do not really buy the duplicate code issue (but circumvent it anyway).
shorten_style_name() was really hard to grasp, maybe use of a helper
function makes it more readable.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
We created two fonts, one 'normal' and one 'Windows Compatible'. The
later one used shorter names because there are some Microsoft
applications that can not work with long (family-) names.
But it would be better to have universally usable fonts, like all our
sourcefonts. It would reduce confusion and also reduce the size of
installation packages.
[how]
ID 1 (Family) family()
Unchanged
Take the short form font name. Appends depending on mode short or long
weight.
ID 2 (SubFamily) subfamily()
Unchanged
Transmogifies Oblique to Italic.
Returns long form styles (i.e. RIBBI)
ID 4 (Fullname) CFF.Fullname fullname()
Take the short form font name (instead of long).
Depending on mode take short or long styles.
This is now in line with ID 4 = ID 1 + ID 2
ID 6 (PS Fullname) CFF.FontName psname()
We limited the length to 31 characters, which is sometimes too short
to have different names for fonts of one same family.
Now we take the short forms of name suffix and styles, for example
VictorMonoNFM-BdIt
ID 16 (Typogr. Family) preferred_family()
The name itself is unchanged (short form name plus verbose suffix),
but the suppression check has been fixed to really compare the
resulting name with the ID 1 name.
ID 17 (Typogr. Subfamily) preferred_styles()
This is unchanged (long form styles) but the suppression check has been
fixed to really compare the resulting string with ID 2.
CFF.Familyname ps_familyname()
Uses ID 16 now and ID 1 as fallback. Was always ID 1 before, which is
wrong.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Specifying an empty string as prefix unexpectedly does not enable short
family names for all fonts - but for no font at all.
Usually an empty prefix matches all strings (font names).
This makes it hard to enable short families for all fonts no matter
what.
[how]
Fix detection if the prefix is False or a string.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
This just drops the 'windows compatibility' options in association with
the name parser (i.e. --makegroups') as we want to always create fonts
that work on any platform.
Note that the fonts prodused right now are NOT windows compat anymore
and you can not specify the flag. Violating 'git rules' this commit is
not working correctly. But it is easier to do this in smaller steps.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The postscript font name length limit of 31 is only present in very old
post script printers. And even then it depends on the printing method.
Some of our well knows source fonts have longer PS names (Noto etc).
And the limit exists regardless of windows or not.
[how]
Let limit depend on PS name part (font name or family name).
Remove reference to windows compat mode.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Some styles can not take modifiers. We handle the shortening as if they
can. That is not a problem but mighht be unexpected.
Do detect weights we have a fixed list, but that is missing a lot
weights that we would be able to shorten.
The shortening does not work for 'Retina', which is imho a more recent
'invention' (after the paper of the previous commit has been written).
[how]
Separate known weights and make them accessible from other functions.
Use these data tables also for weight detection.
Introduce 'Retina' in the weights table.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
We really struggle to keep the font names below the length limits. To
achieve this some styles are abbreviated. The abbreviations have been
taken from Noto and were initially used to mimic Noto's naming scheme.
But a bit shorter names would help in some instances to produce short
enough name entries. Also some styles that are used by fonts other than
Noto are not abbreviated at all.
[how]
In document [1] Adobe gives examples of very short style abbreviations.
We just implement all these.
Example: 'ExtraCondensed' now becomes 'XCn' instead of the more readable
but longer 'ExtCond' that Noto uses.
[1] https://adobe-type-tools.github.io/font-tech-notes/pdfs/5088.FontNames.pdf
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
There are some more name entries that we should rename or remove.
None of the fonts in the src/unpatched-fonts/ has these set; but in
principle a font could have it set and then we would need to handle
that.
[how]
Just remove the entries if they are existing.
Note that we do not handle NameID 25.
Also add some more comments.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
When we rename a font we should always also change the unique ID.
[how]
Take the fullname and the Nerd Font version number. In general we do not
have the version number in the NameParser object; but we have the
'Version' name and we loot the last word (which we have set to the Nerd
Font version already in the patcher) as version descriptor.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The font was always called 3270.
Having a big company's name in the fontname is scary 😬
See
https://github.com/rbanffy/3270font/issues/60
[how]
Add renaming rule.
Fixes: #1012
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Somehow the `IBM 3270 SemiCondensed` font turn out as
`IBM3270Semi Nerd Font Condensed`.
The 3270 font always had the quirk to have a non-standard style with a
dash. We have specific code to circumvent that.
[how]
After updating 3270 the 'Narrow' had been renamed to 'Condensed' and so
our specific patch did not work anymore.
Adapt the regex to find the new style that needs correction.
[note]
https://github.com/ryanoasis/nerd-fonts/issues/1012#issuecomment-1385497230
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Sometimes we set an empty string as SubFamily name. That ends up as
'Book' which is unexpected.
[how]
The translation from empty to "Book" is done by Fontforge, at least
with version 20220308.
Make sure we always have a SubFamily, and if we don't that must be a
'Regular'.
[note]
This was only a problem with the old naming engine. --makegroups got
this right always.
Fixes: #1046
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[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>
[why]
For some fonts with long names the fields are not long enough and for
example a 'Mono' can not be seen.
[how]
Use same field widths as `name_parser_test2`.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The naming has bizarre blanks strewn in sometimes,
or is all caps. For example
`C a s k a y d i a C o v e` or
`CASKAYDIACOVE-Regular`
[how]
When run under Python2 all strings are unicode strings because
`unicode_literals` is imported by `font-patcher`.
Unfortunately the code checks for type str; but that will all become
type unicode with the import.
One check is suboptimal anyhow and can be dropped, while the other is
turned around.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Sometimes scripts can not be run.
[how]
Depending on installed python versions and 'alternatives' setup the
script's shebang needs to point to python3 of course.
Also the files need the executable bit set.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[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>
[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>
fontforge has an undocumented call to set the fsSelection bits.
Never rely on documentation :-(
Found this here:
https://github.com/fontforge/fontforge/issues/3174
And the readback values are actually not read from the source font, so
we do not use them.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Under certain circumstances the WWS names (Family and Subfamily) are
used to identify a font. We do not touch these SFNT table entries, so
when the font is renamed these are wrong (have the original name).
Font-grouping will go wrong then.
[how]
The typographic ('Preferred') Family and Styles are set correctly
already and they follow the WWS pattern, so the WWS fields can be (and
should) be empty. They exist to allow font grouping in the case where
the typographic names do not follow that pattern.
Remove preexisting WWS entries (because they are not needed anymore,
otherwise we would need to write the corrected new names there).
We already set the WWS bit in fsSelection that is needed:
def fs_selection(self, fs):
"""Modify a given fsSelection value for current name, bits 0, 5, 6, 8, 9 touched"""
[...]
b |= WWS # We assert this by our naming process
return b
Unfortunately we have no way (jet) to set fsSelection.
This is only the case for Iosevka for all fonts in src/unpatched-fonts.
Reported-by: Rui Ming (Max) Xiong <xsrvmy>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
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>