mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-12 09:41:47 +02:00
Remove name_parser_test scripts
[why] The systematic evaluation of all fonts is finished and we do not need any comparison with the old naming anymore. This can partially replaced by something like NERDFONTS='--debug --dry --makegroups 1' ./gotta-patch-em-all-font-patcher\!.sh -cv /iA-Writer | grep '===' [note] Also update query_names helper to what I used recently with length indicators. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
4921e59554
commit
a044611194
8 changed files with 19 additions and 2474 deletions
|
@ -54,105 +54,8 @@ work as it always did.
|
|||
|
||||
### The Tests
|
||||
|
||||
In this directory there are two tests.
|
||||
|
||||
1. The first test checks the basics of the algorithm. It takes the filenames of all fonts in
|
||||
`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 `--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
|
||||
|
||||
* Fullname must be roughly equal
|
||||
* Fontname must be roughly equal
|
||||
* Familyname must roughly equal, order of all words does not matter
|
||||
_(Order of words is ignored with test 2 only)_
|
||||
* SubFamilyname must be equal, order of words does not matter
|
||||
_(First word must be equal, order of other words is ignored with test 2 only)_
|
||||
* Typographic names can be empty if the correct typographic name would be equal to the ordinary name
|
||||
* Tests are done case insensitive
|
||||
* Some special exemptions are made (see `lenient_cmp()` in test scripts)
|
||||
|
||||
#### Test 1
|
||||
|
||||
`fontforge name_parser_test1 ../../../src/unpatched-fonts/**/*.[ot]tf 2>/dev/null`
|
||||
|
||||
This test takes the filename of a font, parses it and generates names from it. Then the actual
|
||||
font is opened and the generated names are compared with the stored names. This test is used
|
||||
to test the algorithm itself. Of course no SIL table is active as we want to preserve the original
|
||||
names.
|
||||
|
||||
The output shows all the names, always two lines: first the generated names, then the readout
|
||||
names. If there are differences the generated names are tagged with `+` and the readout ones
|
||||
with `-`. If there are differences the actually different name part is marked with an `X`.
|
||||
|
||||
The differences have reasons, and there is a file with textual explanations for them. So far
|
||||
all differences are 'ok'. A new run of the script will compare all differences with the stored
|
||||
ones and alert the user if a new difference is detected (or a difference vanished). In this
|
||||
way changes of the algorithm can be tested with a wide base of inputs.
|
||||
|
||||
#### Test 2
|
||||
|
||||
`fontforge name_parser_test2 ../../../src/unpatched-fonts/**/*.[ot]tf 2>/dev/null`
|
||||
|
||||
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 `--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
|
||||
differences are reported. In the report an additional line is given, tagged with `>`, that
|
||||
contains the names of the original font, for human interpretation (often the reason
|
||||
for a difference is obvious, because the classic `font-patcher` dropped information.
|
||||
|
||||
_Note: Fonts `NotoColorEmoji` and `Lilex-VF` are not patchable, and thus ignored_
|
||||
_Note: Fonts `iosevka-heavyoblique`, `iosevka-term-heavyoblique`, `iosevka-mediumoblique` crash my machine and are ignored_
|
||||
|
||||
### Differences
|
||||
|
||||
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
|
||||
* The SubFamily contains only 4 Styles max: Regular, Bold, Italic, Bold-Italic
|
||||
* The Noto fonts retain their abbreviated style names in the Family information
|
||||
* `Nerd Font Mono` fonts get a `M` in windows mode (I believe that has been left out accidentally before)
|
||||
|
||||
Apart from these general things, all changes are documented in detail in the `name_parser_test2` issues file.
|
||||
Here is an overview over all the things that get renamed and why:
|
||||
|
||||
| Occurences | Description |
|
||||
|------------|-------------|
|
||||
| 511 | Add weight/style to family |
|
||||
| 43 | The fonts name is M+ not Mplus |
|
||||
| 36 | Drop unneeded Typogr.Family/Typogr.Style |
|
||||
| 26 | 'Term' is missing from Family |
|
||||
| 22 | Change regular-equivalent name to Regular |
|
||||
| 19 | Put Oblique into own SubFamily (and mark it as italic) |
|
||||
| 5 | Drop Regular from Style |
|
||||
| 4 | We handle (TTF) as sub-name |
|
||||
| 4 | Fullname has been missing 'Nerd Font' |
|
||||
| 4 | Bold / Bold-Italic are just a styles of Regular |
|
||||
| 2 | Original font broken (Light in Family) |
|
||||
| 2 | Classify Medium as own weigt and not Bold |
|
||||
| 2 | Bold and Italic are styles of a basefont |
|
||||
| 1 | Weight Condensed does not belong to base name |
|
||||
| 1 | Use only Regular/Bold/Italic in SubFamily |
|
||||
| 1 | Handle Retina as Weight and not Style |
|
||||
| 1 | Do not call Semibold Light-Bold |
|
||||
|
||||
From the count we see that almost all fonts are affected by incorrect Family naming.
|
||||
|
||||
### 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-makegroups,
|
||||
and patched-classic.
|
||||
|
||||
The Explanation sorts most differences into common groups. This helps to weed out
|
||||
explanations that might do not need much attention.
|
||||
In this directory were two tests. If interested you need to go back in the git history.
|
||||
They are not needed anymore.
|
||||
|
||||
### Helper scripts
|
||||
|
||||
|
@ -166,30 +69,3 @@ way:
|
|||
* `query_version` `font_name`
|
||||
|
||||
They can be invoked like this `$ fontforge query_sfnt foo.ttf`.
|
||||
|
||||
### Appendix: The `name_parser_test*.known_issues` files
|
||||
|
||||
All differences of 'old' to 'new' naming (if not one of the very general kind like resorting of
|
||||
the words) are documented in the `known_issues` files. For each difference a reason is given.
|
||||
|
||||
The files consist of entries that spans 3 (for test 1) or 4 (for test 2) lines.
|
||||
| Line starts with | Contents |
|
||||
|------------------|----------|
|
||||
| # | Reson for the difference (or `AUTOGENERATED`) |
|
||||
| > | Naming fo the original/source font (only test 2) |
|
||||
| + | 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
|
||||
from the `known_issues` file that were detected. Original issues that are not
|
||||
existing anymore are at the bottom of the new file, clearly marked as such. If new
|
||||
(previously unexplained) issues were detected they show up with the `AUTOGENERATED`
|
||||
reason.
|
||||
|
||||
After adding new fonts or replacing font files the test can be rerun. If there are issues
|
||||
in the `.new` file they should be documented there, and the `.new` file replace the
|
||||
original `known_issues` file (after removing possible 'obsolete' issues that are listed in
|
||||
the bottom of the new file).
|
||||
|
||||
In this way one can tweak the parser code and compare very easily what a change
|
||||
means for all the fonts, which will break or be repaired.
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
cat name_parser_test2.known_issues | grep '####' | sed -E 's/#### //;s/\] /]\n/g;s/ \[[0-9]+\]//g' | sort | uniq -c | sort -nr
|
||||
|
||||
511 Add weight/style to family
|
||||
43 The fonts name is M+ not Mplus
|
||||
36 Drop unneeded Typogr.Family/Typogr.Style
|
||||
26 'Term' is missing from Family
|
||||
22 Change regular-equivalent name to Regular
|
||||
19 Put Oblique into own SubFamily (and mark it as italic)
|
||||
5 Drop Regular from Style
|
||||
4 We handle (TTF) as sub-name
|
||||
4 Fullname has been missing 'Nerd Font'
|
||||
4 Bold / Bold-Italic are just a styles of Regular
|
||||
2 Original font broken (Light in Family)
|
||||
2 Classify Medium as own weigt and not Bold
|
||||
2 Bold and Italic are styles of a basefont
|
||||
1 Weight Condensed does not belong to base name
|
||||
1 Use only Regular/Bold/Italic in SubFamily
|
||||
1 Handle Retina as Weight and not Style
|
||||
1 Do not call Semibold Light-Bold
|
|
@ -1,160 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# coding=utf8
|
||||
|
||||
import sys
|
||||
import re
|
||||
import os.path
|
||||
import fontforge
|
||||
from FontnameParser import FontnameParser
|
||||
|
||||
###### Some helpers
|
||||
|
||||
def get_sfnt_dict(font):
|
||||
"""Extract SFNT table as nice dict"""
|
||||
d = []
|
||||
for i, el in enumerate(font.sfnt_names):
|
||||
d += [(el[1], el[2])]
|
||||
return dict(d)
|
||||
|
||||
def format_names(header, *stuff):
|
||||
"""Unify outputs (with header)"""
|
||||
f = '{:1.1}|{:50.50} |{:1.1}| {:50.50} |{:1.1}| {:30.30} |{:1.1}| {:30.30} |{:1.1}| {:30.30} |{:1.1}| {:.30}'
|
||||
if header:
|
||||
d = '------------------------------------------------------------'
|
||||
return f.format(*stuff) + '\n' + f.format('', d, d, d, d, d, d, d, d, d, d, d)
|
||||
return f.format(*stuff).rstrip()
|
||||
|
||||
def lenient_cmp(s1, s2):
|
||||
"""Compare two font name (parts) but be a bit lenient ;->"""
|
||||
# We do not care about:
|
||||
# - Case
|
||||
# - "Display" vs "Disp" (in Noto)
|
||||
# Allow for "IBM 3278" name
|
||||
s = [ s1, s2 ]
|
||||
for i in range(2):
|
||||
# Usually given transform from 'their' to 'our' style
|
||||
s[i] = s[i].lower()
|
||||
s[i] = re.sub(r'\bdisp\b', 'display', s[i]) # Noto
|
||||
s[i] = s[i].replace('ibm 3270', '3270') # 3270
|
||||
s[i] = s[i].replace('3270-', '3270 ') # 3270
|
||||
s[i] = s[i].replace('lekton-', 'lekton ') # Lekton
|
||||
s[i] = s[i].replace('semi-narrow', 'seminarrow') # 3270
|
||||
s[i] = s[i].replace('bolditalic', 'bold italic')
|
||||
s[i] = re.sub(r'\bfor\b', '', s[i]) # Meslo, Monofur
|
||||
s[i] = re.sub(r'\bpowerline\b', '', s[i]) # Meslo, Monofur
|
||||
s[i] = s[i].replace('fira mono', 'fura mono') # Obviously someone forgot to rename the fonts in Fira/
|
||||
s[i] = s[i].replace('aurulentsansmono-', 'aurulent sans mono ') # Aurulent fullname oddity
|
||||
s[i] = s[i].replace('mononoki-', 'mononoki ') # Mononoki has somtimes a dash
|
||||
s[i] = re.sub(r'\br\b', 'regular', s[i]) # Nonstandard style in Agave
|
||||
s[i] = re.sub(r'(bitstream vera sans mono.*) oblique', r'\1 italic', s[i]) # They call it Oblique but the filename says Italic
|
||||
s[i] = re.sub(r'gohufont (uni-)?(11|14)', 'gohufont', s[i]) # They put the 'name' into the subfamily/weight
|
||||
s[i] = s[i].replace('xltobl', 'extralight oblique') # Iosevka goes inventing names
|
||||
s[i] = re.sub(r'proggyclean(?!TT)( ?)', 'proggycleantt\1', s[i]) # ProggyClean has no TT in filename
|
||||
|
||||
s[i] = re.sub(r' +', ' ', s[i]).strip()
|
||||
return s[0] == s[1]
|
||||
|
||||
TEST_TABLE = [
|
||||
( '(m)plus', '\\1+'),
|
||||
( 'IAWriter', 'iA Writer'),
|
||||
( 'IBMPlex', 'IBM Plex'),
|
||||
( 'Vera', 'Bitstream Vera Sans'),
|
||||
]
|
||||
|
||||
###### Let's go!
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print('Usage: {} font_name [font_name ...]\n'.format(sys.argv[0]))
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
with open(sys.argv[0] + '.known_issues', 'r') as f:
|
||||
known_issues = f.read().splitlines()
|
||||
# known_issues = [line.rstrip() for line in known_issues]
|
||||
print('Found {:.0f} known issues'.format(len(known_issues) / 3)) # approx ;)
|
||||
except OSError:
|
||||
print('Can not open known_issues file')
|
||||
known_issues = []
|
||||
new_issues = open(sys.argv[0] + '.known_issues.new', 'w')
|
||||
|
||||
print('Examining {} font files'.format(len(sys.argv) - 1))
|
||||
all_files = 0
|
||||
issue_files = 0
|
||||
known_files = 0
|
||||
|
||||
print(format_names(True, '', 'Filename', '', 'Fullname', '', 'Family', '', 'Subfamily', '', 'Typogr. Family', '', 'Typogr. Subfamily'))
|
||||
|
||||
for filename in sys.argv[1:]:
|
||||
fullfile = os.path.basename(filename)
|
||||
fname = os.path.splitext(fullfile)[0]
|
||||
if fname == 'NotoColorEmoji':
|
||||
continue # font is not patchable
|
||||
n = FontnameParser(fname).enable_short_families(False, 'Noto').add_name_substitution_table(TEST_TABLE)
|
||||
# Example for name injection:
|
||||
# n.inject_suffix("Nerd Font Complete Mono", "Nerd Font Complete M", "Nerd Font Mono")
|
||||
|
||||
font = fontforge.open(filename, 1)
|
||||
sfnt = get_sfnt_dict(font)
|
||||
font.close()
|
||||
all_files += 1
|
||||
|
||||
sfnt_full = sfnt['Fullname']
|
||||
sfnt_fam = sfnt['Family']
|
||||
sfnt_subfam = sfnt['SubFamily']
|
||||
sfnt_pfam = sfnt['Preferred Family'] if 'Preferred Family' in sfnt else ''
|
||||
sfnt_psubfam = sfnt['Preferred Styles'] if 'Preferred Styles' in sfnt else ''
|
||||
|
||||
t1 = not lenient_cmp(sfnt_full, n.fullname())
|
||||
t2 = not lenient_cmp(sfnt_fam, n.family())
|
||||
t3 = not lenient_cmp(sfnt_subfam, n.subfamily())
|
||||
t4 = not lenient_cmp(sfnt_pfam, n.preferred_family())
|
||||
t5 = not lenient_cmp(sfnt_psubfam, n.preferred_styles())
|
||||
|
||||
# Lenience: Allow for dropping unneeded prefered stuff:
|
||||
# New (sub)family is same as old preferred sub(family)
|
||||
if t4 and n.preferred_family() == '' and sfnt_pfam.lower() == n.family().lower():
|
||||
t4 = False
|
||||
if t5 and n.preferred_styles() == '' and sfnt_psubfam.lower() == n.subfamily().lower():
|
||||
t5 = False
|
||||
|
||||
if t1 or t2 or t3 or t4 or t5:
|
||||
m1 = '+'; m2 = '-'
|
||||
else:
|
||||
m1 = ''; m2 = ''
|
||||
if not n.parse_ok:
|
||||
m1 = '!'
|
||||
t1_ = 'X' if t1 else ''
|
||||
t2_ = 'X' if t2 else ''
|
||||
t3_ = 'X' if t3 else ''
|
||||
t4_ = 'X' if t4 else ''
|
||||
t5_ = 'X' if t5 else ''
|
||||
|
||||
o1 = format_names(False, m1, fullfile, t1_, n.fullname(), t2_, n.family(), t3_, n.subfamily(), t4_, n.preferred_family(), t5_, n.preferred_styles())
|
||||
o2 = format_names(False, m2, fullfile, '', sfnt_full, '', sfnt_fam, '', sfnt_subfam, '', sfnt_pfam, '', sfnt_psubfam)
|
||||
|
||||
if len(m1):
|
||||
issue_files += 1
|
||||
if not o1 in known_issues or not o2 in known_issues:
|
||||
new_issues.writelines(['#### AUTOGENERATED\n', o1 + '\n', o2 + '\n'])
|
||||
else:
|
||||
known_files += 1
|
||||
idx = known_issues.index(o1) - 1 # should be the index of the explanation line
|
||||
if known_issues[idx][0] != '#':
|
||||
sys.exit('Problem with known issues file, line', known_issues.index(o1))
|
||||
new_issues.writelines([known_issues[idx] + '\n', o1 + '\n', o2 + '\n'])
|
||||
# remove known_issue triplet
|
||||
known_issues.pop(idx)
|
||||
known_issues.pop(idx)
|
||||
known_issues.pop(idx)
|
||||
|
||||
print(o1, o2, sep='\n')
|
||||
|
||||
print('Fonts with different name rendering: {}/{} ({}/{} are in known_issues)'.format(issue_files, all_files, known_files, issue_files))
|
||||
|
||||
if len(known_issues) > 0:
|
||||
print('There are {} lines not needed in known_issues, appending commented out in new known_issues'.format(len(known_issues)))
|
||||
new_issues.write('\n#### The following lines are not needed anymore\n\n')
|
||||
for l in known_issues:
|
||||
new_issues.writelines([' ', l, '\n'])
|
||||
|
||||
new_issues.close()
|
|
@ -1,207 +0,0 @@
|
|||
#### Limit Subfamiliy to 4 standard styles, put Subfamily name into Family instead
|
||||
+|3270Medium.otf | | 3270 Medium |X| 3270 Medium |X| Regular |X| 3270 |X| Medium
|
||||
-|3270Medium.otf | | 3270-Medium | | IBM 3270 | | Medium | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, put Subfamily name into Family instead
|
||||
+|3270Medium.ttf | | 3270 Medium |X| 3270 Medium |X| Regular |X| 3270 |X| Medium
|
||||
-|3270Medium.ttf | | 3270-Medium | | IBM 3270 | | Medium | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, obviously for them Medium is Regular
|
||||
+|3270Narrow.otf | | 3270 Narrow | | 3270 Narrow |X| Regular |X| 3270 |X| Narrow
|
||||
-|3270Narrow.otf | | 3270 Narrow | | IBM 3270 Narrow | | Medium | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, obviously for them Medium is Regular
|
||||
+|3270Narrow.ttf | | 3270 Narrow | | 3270 Narrow |X| Regular |X| 3270 |X| Narrow
|
||||
-|3270Narrow.ttf | | 3270 Narrow | | IBM 3270 Narrow | | Medium | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, obviously for them Medium is Regular
|
||||
+|3270SemiNarrow.otf | | 3270 SemiNarrow | | 3270 SemiNarrow |X| Regular |X| 3270 |X| SemiNarrow
|
||||
-|3270SemiNarrow.otf | | 3270 Semi-Narrow | | IBM 3270 Semi-Narrow | | Medium | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, obviously for them Medium is Regular
|
||||
+|3270SemiNarrow.ttf | | 3270 SemiNarrow | | 3270 SemiNarrow |X| Regular |X| 3270 |X| SemiNarrow
|
||||
-|3270SemiNarrow.ttf | | 3270 Semi-Narrow | | IBM 3270 Semi-Narrow | | Medium | | | |
|
||||
#### Drop special/unexpected name in Typographic Family
|
||||
+|Anonymice Powerline.ttf | | Anonymice Powerline | | Anonymice Powerline | | Regular |X| | |
|
||||
-|Anonymice Powerline.ttf | | Anonymice Powerline | | Anonymice Powerline | | Regular | | Anonymous Pro for Powerline | | Regular
|
||||
#### Font file says it is italic and not oblique
|
||||
+|VeraMono-Bold-Italic.ttf | | Bitstream Vera Sans Mono Bold Italic | | Bitstream Vera Sans Mono |X| Bold Italic | | | |
|
||||
-|VeraMono-Bold-Italic.ttf | | Bitstream Vera Sans Mono Bold Oblique | | Bitstream Vera Sans Mono | | Bold Oblique | | | |
|
||||
#### Font file says it is italic and not oblique
|
||||
+|VeraMono-Italic.ttf | | Bitstream Vera Sans Mono Italic | | Bitstream Vera Sans Mono |X| Italic | | | |
|
||||
-|VeraMono-Italic.ttf | | Bitstream Vera Sans Mono Oblique | | Bitstream Vera Sans Mono | | Oblique | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, Roman is usually equivalent to Regular
|
||||
+|VeraMono.ttf | | Bitstream Vera Sans Mono | | Bitstream Vera Sans Mono |X| Regular | | | |
|
||||
-|VeraMono.ttf | | Bitstream Vera Sans Mono | | Bitstream Vera Sans Mono | | Roman | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, Book is usually equivalent to Regular
|
||||
!|DaddyTimeMono.ttf | | DaddyTimeMono | | DaddyTimeMono |X| Regular | | | |
|
||||
-|DaddyTimeMono.ttf | | DaddyTimeMono | | DaddyTimeMono | | Book | | DaddyTimeMono | |
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|DejaVuSansMono-BoldOblique.ttf | | DejaVu Sans Mono Bold Oblique |X| DejaVu Sans Mono Oblique |X| Bold Italic |X| DejaVu Sans Mono |X| Bold Oblique
|
||||
-|DejaVuSansMono-BoldOblique.ttf | | DejaVu Sans Mono Bold Oblique | | DejaVu Sans Mono | | Bold Oblique | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|DejaVuSansMono-Oblique.ttf | | DejaVu Sans Mono Oblique |X| DejaVu Sans Mono Oblique |X| Italic |X| DejaVu Sans Mono |X| Oblique
|
||||
-|DejaVuSansMono-Oblique.ttf | | DejaVu Sans Mono Oblique | | DejaVu Sans Mono | | Oblique | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, Book is usually equivalent to Regular
|
||||
+|DejaVuSansMono.ttf | | DejaVu Sans Mono | | DejaVu Sans Mono |X| Regular | | | |
|
||||
-|DejaVuSansMono.ttf | | DejaVu Sans Mono | | DejaVu Sans Mono | | Book | | | |
|
||||
#### No need to have Typographic Family/Subfamily if it is identical to normal Family/Subfamily
|
||||
+|FuraMono-Bold Powerline.otf | | Fura Mono Powerline Bold | | Fura Mono Powerline | | Bold |X| | |
|
||||
-|FuraMono-Bold Powerline.otf | | Fira Mono Bold for Powerline | | Fira Mono for Powerline | | Bold | | Fira Mono for Powerline | |
|
||||
#### False positive, move Powerline from end to middle, Powerline will be dropped when patching anyhow
|
||||
+|FuraMono-Medium Powerline.otf | | Fura Mono Powerline Medium | | Fura Mono Powerline Medium | | Regular |X| Fura Mono Powerline | | Medium
|
||||
-|FuraMono-Medium Powerline.otf | | Fira Mono Medium for Powerline | | Fira Mono Medium for Powerline | | Regular | | Fira Mono Medium for Powerline | | Medium
|
||||
#### No need to have Typographic Family/Subfamily if it is identical to normal Family/Subfamily
|
||||
+|FuraMono-Regular Powerline.otf | | Fura Mono Powerline | | Fura Mono Powerline | | Regular |X| | |
|
||||
-|FuraMono-Regular Powerline.otf | | Fira Mono | | Fira Mono for Powerline | | Regular | | Fira Mono for Powerline | |
|
||||
#### Limit Subfamiliy to 4 standard styles, put Subfamily name into Family instead
|
||||
+|gohufont-11.ttf | | Gohufont 11 | | Gohufont 11 |X| Regular | | | |
|
||||
-|gohufont-11.ttf | | GohuFont | | GohuFont | | Medium | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, put Subfamily name into Family instead
|
||||
+|gohufont-14.ttf | | Gohufont 14 | | Gohufont 14 |X| Regular | | | |
|
||||
-|gohufont-14.ttf | | GohuFont | | GohuFont | | 14 | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, put Subfamily name into Family instead
|
||||
+|gohufont-uni-11.ttf | | Gohufont uni-11 | | Gohufont uni-11 |X| Regular | | | |
|
||||
-|gohufont-uni-11.ttf | | GohuFont | | GohuFont | | Medium | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, put Subfamily name into Family instead
|
||||
+|gohufont-uni-14.ttf | | Gohufont uni-14 | | Gohufont uni-14 |X| Regular | | | |
|
||||
-|gohufont-uni-14.ttf | | GohuFont | | GohuFont | | uni-14 | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, Normal is usually equivalent to Regular
|
||||
+|heavy_data.ttf | | Heavy Data | | Heavy Data |X| Regular | | | |
|
||||
-|heavy_data.ttf | | Heavy Data | | Heavy Data | | Normal | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, put Subfamily name into Family instead
|
||||
+|Hermit-light.otf | | Hermit Light |X| Hermit Light |X| Regular |X| Hermit |X| Light
|
||||
-|Hermit-light.otf | | Hermit Light | | Hermit | | light | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, put Subfamily name into Family instead
|
||||
+|Hermit-medium.otf | | Hermit Medium |X| Hermit Medium |X| Regular |X| Hermit |X| Medium
|
||||
-|Hermit-medium.otf | | Hermit Medium | | Hermit | | medium | | | |
|
||||
#### Limit Subfamiliy to 4 standard styles, put Bold into Subfamily name
|
||||
+|iAWriterDuospace-Bold.otf | | iA Writer Duospace Bold |X| iA Writer Duospace |X| Bold | | | |
|
||||
-|iAWriterDuospace-Bold.otf | | iA Writer Duospace Bold | | iA Writer Duospace Bold | | Regular | | iA Writer Duospace | | Bold
|
||||
#### Limit Subfamiliy to 4 standard styles, put Bold into Subfamily name
|
||||
+|iAWriterDuospace-Bold.ttf | | iA Writer Duospace Bold |X| iA Writer Duospace |X| Bold | | | |
|
||||
-|iAWriterDuospace-Bold.ttf | | iA Writer Duospace Bold | | iA Writer Duospace Bold | | Regular | | iA Writer Duospace | | Bold
|
||||
#### Limit Subfamiliy to 4 standard styles, put Bold into Subfamily name
|
||||
+|iAWriterDuospace-BoldItalic.otf | | iA Writer Duospace Bold Italic |X| iA Writer Duospace |X| Bold Italic | | |X|
|
||||
-|iAWriterDuospace-BoldItalic.otf | | iA Writer Duospace BoldItalic | | iA Writer Duospace Bold | | Italic | | iA Writer Duospace | | BoldItalic
|
||||
#### Limit Subfamiliy to 4 standard styles, put Bold into Subfamily name
|
||||
+|iAWriterDuospace-BoldItalic.ttf | | iA Writer Duospace Bold Italic |X| iA Writer Duospace |X| Bold Italic | | |X|
|
||||
-|iAWriterDuospace-BoldItalic.ttf | | iA Writer Duospace BoldItalic | | iA Writer Duospace Bold | | Italic | | iA Writer Duospace | | BoldItalic
|
||||
#### Ignore naming part Text
|
||||
+|IBMPlexMono-TextItalic.ttf | | IBM Plex Mono Text Italic | | IBM Plex Mono Text | | Italic |X| |X|
|
||||
-|IBMPlexMono-TextItalic.ttf | | IBM Plex Mono Text Italic | | IBM Plex Mono Text | | Italic | | IBM Plex Mono | | Text Italic
|
||||
#### Ignore naming part Text
|
||||
+|IBMPlexMono-Text.ttf | | IBM Plex Mono Text | | IBM Plex Mono Text | | Regular |X| |X|
|
||||
-|IBMPlexMono-Text.ttf | | IBM Plex Mono Text | | IBM Plex Mono Text | | Regular | | IBM Plex Mono | | Text
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-boldoblique.ttf | | Iosevka Bold Oblique | | Iosevka Oblique |X| Bold Italic | | Iosevka | | Bold Oblique
|
||||
-|iosevka-boldoblique.ttf | | Iosevka Bold Oblique | | Iosevka Oblique | | Bold | | Iosevka | | Bold Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-term-boldoblique.ttf | | Iosevka Term Bold Oblique | | Iosevka Term Oblique |X| Bold Italic | | Iosevka Term | | Bold Oblique
|
||||
-|iosevka-term-boldoblique.ttf | | Iosevka Term Bold Oblique | | Iosevka Term Oblique | | Bold | | Iosevka Term | | Bold Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-extraboldoblique.ttf | | Iosevka ExtraBold Oblique | | Iosevka ExtraBold Oblique |X| Italic | | Iosevka | | ExtraBold Oblique
|
||||
-|iosevka-extraboldoblique.ttf | | Iosevka Extrabold Oblique | | Iosevka Extrabold Oblique | | Regular | | Iosevka | | Extrabold Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-term-extraboldoblique.ttf | | Iosevka Term ExtraBold Oblique | | Iosevka Term ExtraBold Oblique |X| Italic | | Iosevka Term | | ExtraBold Oblique
|
||||
-|iosevka-term-extraboldoblique.ttf | | Iosevka Term Extrabold Oblique | | Iosevka Term Extrabold Oblique | | Regular | | Iosevka Term | | Extrabold Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-extralightoblique.ttf | | Iosevka ExtraLight Oblique | | Iosevka ExtraLight Oblique |X| Italic | | Iosevka | | ExtraLight Oblique
|
||||
-|iosevka-extralightoblique.ttf | | Iosevka Extralight Oblique | | Iosevka Extralight Oblique | | Regular | | Iosevka | | Extralight Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-term-extralightoblique.ttf | | Iosevka Term ExtraLight Oblique | | Iosevka Term ExtraLight Obliqu |X| Italic | | Iosevka Term | | ExtraLight Oblique
|
||||
-|iosevka-term-extralightoblique.ttf | | Iosevka Term Extralight Oblique | | Iosevka Term XLtObl | | Regular | | Iosevka Term | | Extralight Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-heavyoblique.ttf | | Iosevka Heavy Oblique | | Iosevka Heavy Oblique |X| Italic | | Iosevka | | Heavy Oblique
|
||||
-|iosevka-heavyoblique.ttf | | Iosevka Heavy Oblique | | Iosevka Heavy Oblique | | Regular | | Iosevka | | Heavy Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-term-heavyoblique.ttf | | Iosevka Term Heavy Oblique | | Iosevka Term Heavy Oblique |X| Italic | | Iosevka Term | | Heavy Oblique
|
||||
-|iosevka-term-heavyoblique.ttf | | Iosevka Term Heavy Oblique | | Iosevka Term Heavy Oblique | | Regular | | Iosevka Term | | Heavy Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-lightoblique.ttf | | Iosevka Light Oblique | | Iosevka Light Oblique |X| Italic | | Iosevka | | Light Oblique
|
||||
-|iosevka-lightoblique.ttf | | Iosevka Light Oblique | | Iosevka Light Oblique | | Regular | | Iosevka | | Light Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-term-lightoblique.ttf | | Iosevka Term Light Oblique | | Iosevka Term Light Oblique |X| Italic | | Iosevka Term | | Light Oblique
|
||||
-|iosevka-term-lightoblique.ttf | | Iosevka Term Light Oblique | | Iosevka Term Light Oblique | | Regular | | Iosevka Term | | Light Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-mediumoblique.ttf | | Iosevka Medium Oblique | | Iosevka Medium Oblique |X| Italic | | Iosevka | | Medium Oblique
|
||||
-|iosevka-mediumoblique.ttf | | Iosevka Medium Oblique | | Iosevka Medium Oblique | | Regular | | Iosevka | | Medium Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-term-mediumoblique.ttf | | Iosevka Term Medium Oblique | | Iosevka Term Medium Oblique |X| Italic | | Iosevka Term | | Medium Oblique
|
||||
-|iosevka-term-mediumoblique.ttf | | Iosevka Term Medium Oblique | | Iosevka Term Medium Oblique | | Regular | | Iosevka Term | | Medium Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-oblique.ttf | | Iosevka Oblique | | Iosevka Oblique |X| Italic | | Iosevka | | Oblique
|
||||
-|iosevka-oblique.ttf | | Iosevka Oblique | | Iosevka Oblique | | Regular | | Iosevka | | Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-term-oblique.ttf | | Iosevka Term Oblique | | Iosevka Term Oblique |X| Italic | | Iosevka Term | | Oblique
|
||||
-|iosevka-term-oblique.ttf | | Iosevka Term Oblique | | Iosevka Term Oblique | | Regular | | Iosevka Term | | Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-semiboldoblique.ttf | | Iosevka SemiBold Oblique | | Iosevka SemiBold Oblique |X| Italic | | Iosevka | | SemiBold Oblique
|
||||
-|iosevka-semiboldoblique.ttf | | Iosevka Semibold Oblique | | Iosevka Semibold Oblique | | Regular | | Iosevka | | Semibold Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-term-semiboldoblique.ttf | | Iosevka Term SemiBold Oblique | | Iosevka Term SemiBold Oblique |X| Italic | | Iosevka Term | | SemiBold Oblique
|
||||
-|iosevka-term-semiboldoblique.ttf | | Iosevka Term Semibold Oblique | | Iosevka Term Semibold Oblique | | Regular | | Iosevka Term | | Semibold Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-term-thinoblique.ttf | | Iosevka Term Thin Oblique | | Iosevka Term Thin Oblique |X| Italic | | Iosevka Term | | Thin Oblique
|
||||
-|iosevka-term-thinoblique.ttf | | Iosevka Term Thin Oblique | | Iosevka Term Thin Oblique | | Regular | | Iosevka Term | | Thin Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead (and mark it Italic so applications know it's slanted) & Keep the grouping in Typographic Family
|
||||
+|iosevka-thinoblique.ttf | | Iosevka Thin Oblique | | Iosevka Thin Oblique |X| Italic | | Iosevka | | Thin Oblique
|
||||
-|iosevka-thinoblique.ttf | | Iosevka Thin Oblique | | Iosevka Thin Oblique | | Regular | | Iosevka | | Thin Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Retina into Family instead
|
||||
+|Monoid-Retina.ttf | | Monoid Retina |X| Monoid Retina |X| Regular |X| Monoid |X| Retina
|
||||
-|Monoid-Retina.ttf | | Monoid Retina | | Monoid | | Retina | | | |
|
||||
#### Remove nonstandard BoldItalic typographic style
|
||||
+|mononoki-BoldItalic.ttf | | Mononoki Bold Italic | | Mononoki | | Bold Italic | | |X|
|
||||
-|mononoki-BoldItalic.ttf | | mononoki Bold Italic | | mononoki | | Bold Italic | | | | BoldItalic
|
||||
#### They say SemiBold is the same as Light Bold, we can not generalize this and make SemiBold self standing
|
||||
+|overpass-mono-semibold.otf | | Overpass Mono SemiBold |X| Overpass Mono SemiBold |X| Regular | | Overpass Mono | | SemiBold
|
||||
-|overpass-mono-semibold.otf | | Overpass Mono SemiBold | | Overpass Mono Light | | Bold | | Overpass Mono | | SemiBold
|
||||
#### They say SemiBold is the same as Light Bold, we can not generalize this and make SemiBold self standing
|
||||
+|overpass-semibold.otf | | Overpass SemiBold |X| Overpass SemiBold |X| Regular | | Overpass | | SemiBold
|
||||
-|overpass-semibold.otf | | Overpass SemiBold | | Overpass Light | | Bold | | Overpass | | SemiBold
|
||||
#### Nonstandard font naming: fullname shall be same as familyname plus more
|
||||
+|ProFontIIx.ttf | | ProFont IIx |X| ProFont IIx | | Regular | | | |
|
||||
-|ProFontIIx.ttf | | ProFont IIx | | ProFontIIx | | Regular | | | |
|
||||
#### We are fine here (just list with exclamation mark because it is a potentially problematic case)
|
||||
!|ProFontWindows.ttf | | ProFontWindows | | ProFontWindows | | Regular | | | |
|
||||
|ProFontWindows.ttf | | ProFontWindows | | ProFontWindows | | Regular | | | |
|
||||
#### No mention of TT in file name
|
||||
+|ProggyCleanCE.ttf |X| ProggyClean CE |X| ProggyClean CE | | Regular | | | |
|
||||
-|ProggyCleanCE.ttf | | ProggyCleanTT CE | | ProggyCleanTT CE | | Regular | | | |
|
||||
#### No mention of TT in file name
|
||||
!|ProggyClean.ttf |X| ProggyClean |X| ProggyClean | | Regular | | | |
|
||||
-|ProggyClean.ttf | | ProggyCleanTT | | ProggyCleanTT | | Regular | | | |
|
||||
#### No mention of TT in file name
|
||||
+|ProggyCleanSZ.ttf |X| ProggyClean SZ |X| ProggyClean SZ | | Regular | | | |
|
||||
-|ProggyCleanSZ.ttf | | ProggyCleanTTSZ | | ProggyCleanTTSZ | | Regular | | | |
|
||||
#### They put one name part in parens
|
||||
+|TerminusTTF-Bold Italic-4.40.1.ttf |X| Terminus TTF Bold Italic |X| Terminus TTF | | Bold Italic | | | |
|
||||
-|TerminusTTF-Bold Italic-4.40.1.ttf | | Terminus (TTF) Bold Italic | | Terminus (TTF) | | Bold Italic | | | |
|
||||
#### They put one name part in parens
|
||||
+|TerminusTTF-Bold-4.40.1.ttf |X| Terminus TTF Bold |X| Terminus TTF | | Bold | | | |
|
||||
-|TerminusTTF-Bold-4.40.1.ttf | | Terminus (TTF) Bold | | Terminus (TTF) | | Bold | | | |
|
||||
#### They put one name part in parens
|
||||
+|TerminusTTF-Italic-4.40.1.ttf |X| Terminus TTF Italic |X| Terminus TTF | | Italic | | | |
|
||||
-|TerminusTTF-Italic-4.40.1.ttf | | Terminus (TTF) Italic | | Terminus (TTF) | | Italic | | | |
|
||||
#### They put one name part in parens
|
||||
+|TerminusTTF-4.40.1.ttf |X| Terminus TTF |X| Terminus TTF |X| Regular | | | |
|
||||
-|TerminusTTF-4.40.1.ttf | | Terminus (TTF) | | Terminus (TTF) | | Medium | | | |
|
||||
#### Ubuntu Condensed should be grouped with Ubuntu, that they didn't is an error?
|
||||
+|Ubuntu-C.ttf | | Ubuntu Condensed | | Ubuntu Condensed | | Regular |X| Ubuntu |X| Condensed
|
||||
-|Ubuntu-C.ttf | | Ubuntu Condensed | | Ubuntu Condensed | | Regular | | Ubuntu Condensed | | Regular
|
||||
#### They say Medium is the same as Light Bold, we can not generalize this and make Medium self standing
|
||||
+|Ubuntu-MI.ttf | | Ubuntu Medium Italic |X| Ubuntu Medium |X| Italic | | Ubuntu | | Medium Italic
|
||||
-|Ubuntu-MI.ttf | | Ubuntu Medium Italic | | Ubuntu Light | | Bold Italic | | Ubuntu | | Medium Italic
|
||||
#### They say Medium is the same as Light Bold, we can not generalize this and make Medium self standing
|
||||
+|Ubuntu-M.ttf | | Ubuntu Medium |X| Ubuntu Medium |X| Regular | | Ubuntu | | Medium
|
||||
-|Ubuntu-M.ttf | | Ubuntu Medium | | Ubuntu Light | | Bold | | Ubuntu | | Medium
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead
|
||||
+|VictorMono-ExtraLightOblique.ttf | | Victor Mono ExtraLight Oblique |X| Victor Mono ExtraLight Oblique | | Italic | | Victor Mono | | ExtraLight Oblique
|
||||
-|VictorMono-ExtraLightOblique.ttf | | Victor Mono ExtraLight Oblique | | Victor Mono ExtraLight | | Italic | | Victor Mono | | ExtraLight Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead
|
||||
+|VictorMono-LightOblique.ttf | | Victor Mono Light Oblique |X| Victor Mono Light Oblique | | Italic | | Victor Mono | | Light Oblique
|
||||
-|VictorMono-LightOblique.ttf | | Victor Mono Light Oblique | | Victor Mono Light | | Italic | | Victor Mono | | Light Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead
|
||||
+|VictorMono-MediumOblique.ttf | | Victor Mono Medium Oblique |X| Victor Mono Medium Oblique | | Italic | | Victor Mono | | Medium Oblique
|
||||
-|VictorMono-MediumOblique.ttf | | Victor Mono Medium Oblique | | Victor Mono Medium | | Italic | | Victor Mono | | Medium Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead
|
||||
+|VictorMono-SemiBoldOblique.ttf | | Victor Mono SemiBold Oblique |X| Victor Mono SemiBold Oblique | | Italic | | Victor Mono | | SemiBold Oblique
|
||||
-|VictorMono-SemiBoldOblique.ttf | | Victor Mono SemiBold Oblique | | Victor Mono SemiBold | | Italic | | Victor Mono | | SemiBold Oblique
|
||||
#### Limit Subfamiliy to 4 standard styles, put Oblique into Family instead
|
||||
+|VictorMono-ThinOblique.ttf | | Victor Mono Thin Oblique |X| Victor Mono Thin Oblique | | Italic | | Victor Mono | | Thin Oblique
|
||||
-|VictorMono-ThinOblique.ttf | | Victor Mono Thin Oblique | | Victor Mono Thin | | Italic | | Victor Mono | | Thin Oblique
|
|
@ -1,195 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# coding=utf8
|
||||
|
||||
import sys
|
||||
import re
|
||||
import os.path
|
||||
import glob
|
||||
import subprocess
|
||||
import fontforge
|
||||
|
||||
###### Some helpers
|
||||
|
||||
def get_sfnt_dict(font):
|
||||
"""Extract SFNT table as nice dict"""
|
||||
d = []
|
||||
for i, el in enumerate(font.sfnt_names):
|
||||
d += [(el[1], el[2])]
|
||||
return dict(d)
|
||||
|
||||
def extract_sfnt_data(sfnt):
|
||||
"""Get the usual names out of the SFNT table"""
|
||||
sfnt_full = sfnt['Fullname']
|
||||
sfnt_fam = sfnt['Family']
|
||||
sfnt_subfam = sfnt['SubFamily']
|
||||
sfnt_pfam = sfnt['Preferred Family'] if 'Preferred Family' in sfnt else ''
|
||||
sfnt_psubfam = sfnt['Preferred Styles'] if 'Preferred Styles' in sfnt else ''
|
||||
return (sfnt_full, sfnt_fam, sfnt_subfam, sfnt_pfam, sfnt_psubfam)
|
||||
|
||||
def format_names(header, *stuff):
|
||||
"""Unify outputs (with header)"""
|
||||
f = '{:1.1}|{:50.50} |{:1.1}| {:65.65} |{:1.1}| {:55.55} |{:1.1}| {:30.30} |{:1.1}| {:40.40} |{:1.1}| {:.40}'
|
||||
if header:
|
||||
d = '------------------------------------------------------------'
|
||||
return f.format(*stuff) + '\n' + f.format('', d, d, d, d, d, d, d, d, d, d, d)
|
||||
return f.format(*stuff).rstrip()
|
||||
|
||||
def lenient_cmp(s1, s2, allow_shuffle_all):
|
||||
"""Compare two font name (parts) but be a bit lenient ;->"""
|
||||
# We do not care about:
|
||||
# - Case
|
||||
# - "Display" vs "Disp" (in Noto)
|
||||
# Allow for "IBM 3278" name
|
||||
s = [ s1, s2 ]
|
||||
for i in range(2):
|
||||
# Usually given transform from 'their' to 'our' style
|
||||
s[i] = s[i].lower()
|
||||
s[i] = re.sub(r'\bdisp\b', 'display', s[i]) # Noto
|
||||
s[i] = s[i].replace('ibm 3270', '3270') # 3270
|
||||
s[i] = s[i].replace('3270-', '3270 ') # 3270
|
||||
s[i] = s[i].replace('lekton-', 'lekton ') # Lekton
|
||||
s[i] = s[i].replace('semi-narrow', 'seminarrow') # 3270
|
||||
s[i] = s[i].replace('bolditalic', 'bold italic')
|
||||
s[i] = re.sub(r'\bfor\b', '', s[i]) # Meslo, Monofur
|
||||
s[i] = re.sub(r'\bpowerline\b', '', s[i]) # Meslo, Monofur
|
||||
s[i] = s[i].replace('fira mono', 'fura mono') # Obviously someone forgot to rename the fonts in Fira/
|
||||
s[i] = s[i].replace('aurulentsansmono-', 'aurulent sans mono ') # Aurulent fullname oddity
|
||||
s[i] = s[i].replace('mononoki-', 'mononoki ') # Mononoki has somtimes a dash
|
||||
s[i] = re.sub(r'\br\b', 'regular', s[i]) # Nonstandard style in Agave
|
||||
s[i] = re.sub(r'(bitstream vera sans mono.*) oblique', r'\1 italic', s[i]) # They call it Oblique but the filename says Italic
|
||||
s[i] = re.sub(r'gohufont (uni-)?(11|14)', 'gohufont', s[i]) # They put the 'name' into the subfamily/weight
|
||||
s[i] = s[i].replace('xltobl', 'extralight oblique') # Iosevka goes inventing names
|
||||
s[i] = re.sub(r'proggyclean(?!TT)( ?)', 'proggycleantt\1', s[i]) # ProggyClean has no TT in filename
|
||||
|
||||
s[i] = re.sub(r' +', ' ', s[i]).strip()
|
||||
|
||||
p = []
|
||||
for e in s:
|
||||
parts = e.split(' ')
|
||||
if not allow_shuffle_all and len(parts) > 2:
|
||||
tail = parts[1:]
|
||||
tail.sort()
|
||||
parts = [parts[0]] + tail
|
||||
elif len(parts) > 1:
|
||||
parts.sort()
|
||||
p.append(' '.join(parts))
|
||||
return p[0] == p[1]
|
||||
|
||||
###### Let's go!
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print('Usage: {} font_name [font_name ...]\n'.format(sys.argv[0]))
|
||||
sys.exit(1)
|
||||
|
||||
font_patcher = os.path.realpath(os.path.dirname(os.path.realpath(sys.argv[0]))+'/../../../font-patcher')
|
||||
|
||||
existing_font = glob.glob('*.[ot]tf')
|
||||
if len(existing_font):
|
||||
sys.exit('Would overwrite any existing *.ttf and *.otf, bailing out (remove them first)')
|
||||
|
||||
try:
|
||||
with open(sys.argv[0] + '.known_issues', 'r') as f:
|
||||
known_issues = f.read().splitlines()
|
||||
# known_issues = [line.rstrip() for line in known_issues]
|
||||
print('Found {:.0f} known issues'.format(len(known_issues) / 4)) # approx ;)
|
||||
except OSError:
|
||||
print('Can not open known_issues file')
|
||||
known_issues = []
|
||||
new_issues = open(sys.argv[0] + '.known_issues.new', 'w')
|
||||
|
||||
print('Examining {} font files'.format(len(sys.argv) - 1))
|
||||
all_files = 0
|
||||
issue_files = 0
|
||||
known_files = 0
|
||||
|
||||
print(format_names(True, '', 'Filename', '', 'Fullname', '', 'Family', '', 'Subfamily', '', 'Typogr. Family', '', 'Typogr. Subfamily'))
|
||||
|
||||
for filename in sys.argv[1:]:
|
||||
data = []
|
||||
fullfile = os.path.basename(filename)
|
||||
fname = os.path.splitext(fullfile)[0]
|
||||
if fname == 'NotoColorEmoji':
|
||||
continue # font is not patchable
|
||||
if fname in [ 'iosevka-heavyoblique', 'iosevka-term-heavyoblique', 'iosevka-mediumoblique', 'Lilex-VF' ]:
|
||||
continue # Patch resultant font not openable
|
||||
log = open("log", "w")
|
||||
log.write(filename)
|
||||
log.close()
|
||||
|
||||
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')
|
||||
#ff = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf8')
|
||||
if ff.returncode:
|
||||
print("\nERROR running command:\n {}\n\n{}".format(' '.join(cmd), ''))#ff.stdout))
|
||||
sys.exit(1)
|
||||
new_font = glob.glob('*.[ot]tf')
|
||||
font = fontforge.open(new_font[0], 1)
|
||||
sfnt = get_sfnt_dict(font)
|
||||
font.close()
|
||||
os.system('rm -f *.[ot]tf')
|
||||
(sfnt_full, sfnt_fam, sfnt_subfam, sfnt_pfam, sfnt_psubfam) = extract_sfnt_data(sfnt)
|
||||
|
||||
data.append(( os.path.basename(new_font[0]), sfnt_full, sfnt_fam, sfnt_subfam, sfnt_pfam, sfnt_psubfam ))
|
||||
|
||||
all_files += 1
|
||||
|
||||
t1 = not lenient_cmp(data[0][1], data[1][1], False)
|
||||
t2 = not lenient_cmp(data[0][2], data[1][2], False)
|
||||
t3 = not lenient_cmp(data[0][3], data[1][3], True)
|
||||
t4 = not lenient_cmp(data[0][4], data[1][4], False)
|
||||
t5 = not lenient_cmp(data[0][5], data[1][5], True)
|
||||
|
||||
# Lenience: Allow for dropping unneeded prefered stuff:
|
||||
# New (sub)family is same as old preferred sub(family)
|
||||
if t4 and data[0][4] == '' and data[1][4].lower() == data[0][2].lower():
|
||||
t4 = False
|
||||
if t5 and data[0][5] == '' and data[1][5].lower() == data[0][3].lower():
|
||||
t5 = False
|
||||
|
||||
if t1 or t2 or t3 or t4 or t5:
|
||||
m1 = '+'; m2 = '-'
|
||||
else:
|
||||
m1 = ''; m2 = ''
|
||||
t1_ = 'X' if t1 else ''
|
||||
t2_ = 'X' if t2 else ''
|
||||
t3_ = 'X' if t3 else ''
|
||||
t4_ = 'X' if t4 else ''
|
||||
t5_ = 'X' if t5 else ''
|
||||
|
||||
o1 = format_names(False, m1, data[0][0], t1_, data[0][1], t2_, data[0][2], t3_, data[0][3], t4_, data[0][4], t5_, data[0][5])
|
||||
o2 = format_names(False, m2, data[1][0], '', data[1][1], '', data[1][2], '', data[1][3], '', data[1][4], '', data[1][5])
|
||||
|
||||
if len(m1):
|
||||
issue_files += 1
|
||||
font = fontforge.open(filename, 1)
|
||||
sfnt = get_sfnt_dict(font)
|
||||
font.close()
|
||||
(sfnt_full, sfnt_fam, sfnt_subfam, sfnt_pfam, sfnt_psubfam) = extract_sfnt_data(sfnt)
|
||||
o3 = format_names(False, '>', os.path.basename(filename), '', sfnt_full, '', sfnt_fam, '', sfnt_subfam, '', sfnt_pfam, '', sfnt_psubfam)
|
||||
if not o1 in known_issues or not o2 in known_issues:
|
||||
new_issues.writelines(['#### AUTOGENERATED\n', o3 + '\n', o1 + '\n', o2 + '\n'])
|
||||
else:
|
||||
known_files += 1
|
||||
idx = known_issues.index(o1) - 2 # should be the index of the explanation line
|
||||
if known_issues[idx][0] != '#':
|
||||
sys.exit('Problem with known issues file, line', known_issues.index(o1))
|
||||
new_issues.writelines([known_issues[idx] + '\n', o3 + '\n', o1 + '\n', o2 + '\n'])
|
||||
# remove known_issue triplet
|
||||
known_issues.pop(idx)
|
||||
known_issues.pop(idx)
|
||||
known_issues.pop(idx)
|
||||
known_issues.pop(idx)
|
||||
|
||||
print(o1, o2, sep='\n')
|
||||
|
||||
print('Fonts with different name rendering: {}/{} ({}/{} are in known_issues)'.format(issue_files, all_files, known_files, issue_files))
|
||||
|
||||
if len(known_issues) > 0:
|
||||
print('There are {} lines not needed in known_issues, appending commented out in new known_issues'.format(len(known_issues)))
|
||||
new_issues.write('\n#### The following lines are not needed anymore\n\n')
|
||||
for l in known_issues:
|
||||
new_issues.writelines([' ', l, '\n'])
|
||||
|
||||
new_issues.close()
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
# coding=utf8
|
||||
#
|
||||
# Usually called via
|
||||
# $ fontforge query_names fontfile.tff 2>/dev/null
|
||||
|
||||
import sys
|
||||
import os.path
|
||||
|
@ -13,10 +16,10 @@ def get_sfnt_dict(font):
|
|||
|
||||
def format_names(header, *stuff):
|
||||
"""Unify outputs (with header)"""
|
||||
f = '{:1.1}|{:50.50} |{:1.1}| {:65.65} |{:1.1}| {:55.55} |{:1.1}| {:30.30} |{:1.1}| {:40.40} |{:1.1}| {:.40}'
|
||||
f = '| {:50.50}|{:>2.2}| {:64.64}|{:>2.2}| {:64.64}|{:>2.2}| {:55.55}|{:>2.2}| {:30.30}|{:>2.2}| {:40.40}|{:>2.2}| {:40.40}|{:>2.2}|'
|
||||
if header:
|
||||
d = '------------------------------------------------------------'
|
||||
return f.format(*stuff) + '\n' + f.format('', d, d, d, d, d, d, d, d, d, d, d)
|
||||
d = ''
|
||||
return f.format(*stuff) + '\n' + f.format(d, d, d, d, d, d, d, d, d, d, d, d, d, d).replace(' ', '-')
|
||||
return f.format(*stuff).rstrip()
|
||||
|
||||
###### Let's go!
|
||||
|
@ -27,7 +30,7 @@ if len(sys.argv) < 2:
|
|||
|
||||
print('Examining {} font files'.format(len(sys.argv) - 1))
|
||||
|
||||
print(format_names(True, '', 'Filename', '', 'Fullname', '', 'Family', '', 'Subfamily', '', 'Typogr. Family', '', 'Typogr. Subfamily'))
|
||||
print(format_names(True, 'Filename', '', 'PS Name', '', 'Fullname', '', 'Family', '', 'Subfamily', '', 'Typogr. Family', '', 'Typogr. Subfamily', ''))
|
||||
|
||||
for filename in sys.argv[1:]:
|
||||
fullfile = os.path.basename(filename)
|
||||
|
@ -35,6 +38,7 @@ for filename in sys.argv[1:]:
|
|||
|
||||
font = fontforge.open(filename, 1)
|
||||
sfnt = get_sfnt_dict(font)
|
||||
psname = font.fontname
|
||||
font.close()
|
||||
|
||||
sfnt_full = sfnt['Fullname']
|
||||
|
@ -43,6 +47,14 @@ for filename in sys.argv[1:]:
|
|||
sfnt_pfam = sfnt['Preferred Family'] if 'Preferred Family' in sfnt else ''
|
||||
sfnt_psubfam = sfnt['Preferred Styles'] if 'Preferred Styles' in sfnt else ''
|
||||
|
||||
o2 = format_names(False, '', fullfile, '', sfnt_full, '', sfnt_fam, '', sfnt_subfam, '', sfnt_pfam, '', sfnt_psubfam)
|
||||
o2 = format_names(False,
|
||||
fullfile, str(len(fullfile)),
|
||||
psname, str(len(psname)),
|
||||
sfnt_full, str(len(sfnt_full)),
|
||||
sfnt_fam, str(len(sfnt_fam)),
|
||||
sfnt_subfam, str(len(sfnt_subfam)),
|
||||
# show length zero if a zero length string is stored, show nothing if nothing is stored:
|
||||
sfnt_pfam, str(len(sfnt_pfam)) if 'Preferred Family' in sfnt else '',
|
||||
sfnt_psubfam, str(len(sfnt_psubfam)) if 'Preferred Family' in sfnt else '')
|
||||
|
||||
print(o2)
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
Add weight/style to family [1]
|
||||
Use only Regular/Bold/Italic in SubFamily [2]
|
||||
Classify Medium as own weight and not Bold [3]
|
||||
Change regular-equivalent name to Regular [4]
|
||||
Drop unneeded Typogr.Family/Typogr.Style [5]
|
||||
Do not call Semibold Light-Bold [6]
|
||||
Fullname has been missing 'Nerd Font' [7]
|
||||
The fonts name is M+ not Mplus [8]
|
||||
Handle Retina as Weight and not Style [9]
|
||||
Bold and Italic are styles of a basefont [10]
|
||||
Put Oblique into own SubFamily (and mark it as italic) [11]
|
||||
'Term' is missing from Family [12]
|
||||
Bold / Bold-Italic are just a styles of Regular [13]
|
||||
Drop Regular from Style [14]
|
Loading…
Reference in a new issue