Skip to content

Commit

Permalink
name-parser: Rename font-patcher option
Browse files Browse the repository at this point in the history
[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>
  • Loading branch information
Finii committed Feb 6, 2022
1 parent d9e197e commit 251de5a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions bin/scripts/name_parser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Typographically aware applications, on the other hand, get all styles grouped un
First experiments showed that the full information can usually be restored already from the file
names that our source fonts have.

This new naming is complete optional (but recommended). Give the option `--parser to` font-patcher
This new naming is complete optional (but recommended). Give the option `--makegroups` to `font-patcher`
and it will try to come up with reasonable grouping and naming. Leave the option out and it will
work as it always did.

Expand All @@ -60,7 +60,7 @@ In this directory there are two tests.
`src/unpatched-fonts/`, then it calculates the naming and compares it to the original
naming in the font files. Ideally they would be equal.
2. The second test does a 'production run'. It patches each font in `src/unpatched-fonts/`
and patches it two times: Once without `--parser` and once with. Then it compares the
and patches it two times: Once without `--makegroups` and once with. Then it compares the
naming, and it also shows the original font naming (for comparison).

All tests base on these assumptions
Expand Down Expand Up @@ -99,7 +99,7 @@ way changes of the algorithm can be tested with a wide base of inputs.

This test compares actually patched fonts. Every font in `src/unpatched-fonts/` is patched two
times: First with the 'old/classic' `font-patcher` naming, and second with the new naming
algorithm in action (by specifying `--parser`). Again the name parts are compared with some
algorithm in action (by specifying `--makegroups`). Again the name parts are compared with some
lenience and an output generated like test 1 does.

Also again a file with known differences (with explanations) is read, and any new or vanished
Expand All @@ -112,7 +112,7 @@ _Note: Fonts `iosevka-heavyoblique`, `iosevka-term-heavyoblique`, `iosevka-mediu

### Differences

The naming of the patched fonts, if `--parse` is applied, will be different. Of course, that is the goal.
The naming of the patched fonts, if `--makegroups` is applied, will be different. Of course, that is the goal.
What are the differences in particular:

* `Nerd Font` is not added in the end, but after the extended base name before the style
Expand Down Expand Up @@ -148,7 +148,7 @@ From the count we see that almost all fonts are affected by incorrect Family nam
### Further steps

One can examine all the (current) naming differences in the `name_parser_test2.known_issues`
file. The Explanation is followed by three lines of names: source-file, patched-with-parser,
file. The Explanation is followed by three lines of names: source-file, patched-with-makegroups,
and patched-classic.

The Explanation sorts most differences into common groups. This helps to weed out
Expand Down Expand Up @@ -176,7 +176,7 @@ The files consist of entries that spans 3 (for test 1) or 4 (for test 2) lines.
|------------------|----------|
| # | Reson for the difference (or `AUTOGENERATED`) |
| > | Naming fo the original/source font (only test 2) |
| + | Naming with `--parser` (new naming) |
| + | Naming with `--makegroups` (new naming) |
| - | Naming classically generated by font-patcher |

After any test run a `known_issues.new` file is generated. It contains all the issues
Expand Down
2 changes: 1 addition & 1 deletion bin/scripts/name_parser/name_parser_test2
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ for filename in sys.argv[1:]:
log.write(filename)
log.close()

for option in ['--parser', '']:
for option in ['--makegroups', '']:
cmd = ['fontforge', '--script', font_patcher, '--powerline', option, filename ]
cmd = [ c for c in cmd if len(c) ]
ff = subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, encoding='utf8')
Expand Down
10 changes: 5 additions & 5 deletions font-patcher
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class font_patcher:
parser.add_argument('-ext', '--extension', dest='extension', default="", type=str, nargs='?', help='Change font file type to create (e.g., ttf, otf)')
parser.add_argument('-out', '--outputdir', dest='outputdir', default=".", type=str, nargs='?', help='The directory to output the patched font file to')
parser.add_argument('--glyphdir', dest='glyphdir', default=__dir__ + "/src/glyphs/", type=str, nargs='?', help='Path to glyphs to be used for patching')
parser.add_argument('--parser', dest='parser', default=False, action='store_true', help='Use alternative method to name patched fonts (experimental)')
parser.add_argument('--makegroups', dest='makegroups', default=False, action='store_true', help='Use alternative method to name patched fonts (experimental)')

# progress bar arguments - https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse
progressbars_group_parser = parser.add_mutually_exclusive_group(required=False)
Expand Down Expand Up @@ -290,7 +290,7 @@ class font_patcher:
additionalFontNameSuffix += " M"
verboseAdditionalFontNameSuffix += " Mono"

if self.args.parser:
if self.args.makegroups:
use_fullname = type(self.sourceFont.fullname) == str # Usually the fullname is better to parse
# Use fullname if it is 'equal' to the fontname
if self.sourceFont.fullname:
Expand All @@ -304,12 +304,12 @@ class font_patcher:
parser_name = os.path.splitext(os.path.basename(self.args.font))[0]
n = FontnameParser(parser_name)
if not n.parse_ok:
print("Have only minimal naming information, check resulting name. Maybe omit --parser option")
print("Have only minimal naming information, check resulting name. Maybe omit --makegroups option")
n.drop_for_powerline()
n.enable_short_families(True, "Noto")
n.set_for_windows(self.args.windows)

# All the following stuff is ignored in parser-mode
# All the following stuff is ignored in makegroups-mode

# basically split the font name around the dash "-" to get the fontname and the style (e.g. Bold)
# this does not seem very reliable so only use the style here as a fallback if the font does not
Expand Down Expand Up @@ -444,7 +444,7 @@ class font_patcher:
fullname = replace_font_name(fullname, additionalFontNameReplacements2)
fontname = replace_font_name(fontname, additionalFontNameReplacements2)

if not self.args.parser:
if not self.args.makegroups:
# replace any extra whitespace characters:
self.sourceFont.familyname = " ".join(familyname.split())
self.sourceFont.fullname = " ".join(fullname.split())
Expand Down
2 changes: 1 addition & 1 deletion src/unpatched-fonts/CascadiaCode/config.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
config_rfn="Cascadia Code"
config_rfn_substitue="Caskaydia Cove"
config_patch_flags="--parser"
config_patch_flags="--makegroups"

0 comments on commit 251de5a

Please sign in to comment.