Skip to content

Commit

Permalink
Move exclusion of codepoints after the subsets.
Browse files Browse the repository at this point in the history
Useful to ignore missing TAB and LFD, those don't have glyphs in font
files.
  • Loading branch information
Szunti committed Sep 24, 2018
1 parent 7b1b7ca commit a005efe
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
Binary file modified HanaMinA.woff
Binary file not shown.
40 changes: 18 additions & 22 deletions webfont/make_woff.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ def error(*args):
"dataFiles": [
"../data/pages/en-GB/**/*.txt"
],
// List of individual code points and ranges (list with start an end).
"excludeCodepoints": [
[0, 127]
],
// The order of fonts are important, fonts will be checked for every code
// point until one has a glyph. First element is the input, second is the
// output.
Expand All @@ -47,6 +43,10 @@ def error(*args):
// Missing characters will be written to this file in utf-8. relative to
// config file's location.
"missingOutput": "missing.txt",
// TAB and LFD don't have a glyph
"ignore_missing": [
9, 10
],
// if true, only print which fonts are used and missing characters
"justCheck": false
}}"""
Expand Down Expand Up @@ -181,17 +181,16 @@ def feed(self, codepoint):

class ExcludeFilter(BaseFilter):
def __init__(self):
self.exclude_ranges = []
self.excluded = set()

def exclude_range(self, unicode_range):
self.exclude_ranges.append(unicode_range)
def exclude(self, codepoint):
self.excluded.add(codepoint)

def feed(self, codepoint):
for range_ in self.exclude_ranges:
if codepoint in range_:
return True
else:
return False
if codepoint in self.excluded:
return True
else:
return False


def main():
Expand Down Expand Up @@ -231,14 +230,6 @@ def silence_unknown_subset_table(record):
uniq_filt = UniqueFilter()
pipeline.add_filter(uniq_filt)

excl_filt = ExcludeFilter()
for excl in config['excludeCodepoints']:
if isinstance(excl, list):
excl_filt.exclude_range(range(excl[0], excl[1]))
else:
excl_filt.exclude_range(range(excl, excl+1))
pipeline.add_filter(excl_filt)

fonts = []
for font_conf in config['fonts']:
infile = configdir / font_conf[0]
Expand All @@ -250,12 +241,17 @@ def silence_unknown_subset_table(record):
for filt in font_filts:
pipeline.add_filter(filt)

missing = set()

excl_filt = ExcludeFilter()
for excl in config['ignore_missing']:
excl_filt.exclude(excl)
pipeline.add_filter(excl_filt)

paths = []
for pattern in config['dataFiles']:
paths.extend(configdir.glob(pattern))

missing = set()

for path in paths:
with path.open(encoding='utf_8') as file:
c = file.read(1)
Expand Down
6 changes: 3 additions & 3 deletions webfont/woff.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"dataFiles": [
"../data/pages/en-GB/**/*.txt"
],
"excludeCodepoints": [
[0, 127]
],
"fonts": [
["HanaMinA.ttf", "../HanaMinA.woff"],
["HanaMinB.ttf", "../HanaMinB.woff"]
],
"missingOutput": "missing.txt",
"ignore_missing": [
9, 10
],
"justCheck": false
}

0 comments on commit a005efe

Please sign in to comment.