Commit 81bf45b3 authored by Sebastian Friedl's avatar Sebastian Friedl
Browse files

Patch Small Capitals

parent 8b9d8559
......@@ -112,6 +112,40 @@ def update_flags(instance, weight, italic=False):
instance['head'].macStyle = mac_style
def patch_small_caps(font, style, italic=False):
gsub = font['GSUB'].table
lookup_list = []
for fr in [fr for fr in gsub.FeatureList.FeatureRecord if fr.FeatureTag == 'smcp']:
lookup_list += fr.Feature.LookupListIndex
for lookup_id in list(sorted(set(lookup_list))):
lookup = gsub.LookupList.Lookup[lookup_id]
for substitution_table in lookup.SubTable:
if substitution_table.LookupType != 1:
continue
if style == 'Serif' and not italic:
# lookup 35 sets different numbers for smallcaps
if lookup_id == 35:
for g in list(substitution_table.mapping.keys()):
del substitution_table.mapping[g]
# replace ß with appropriate glyph (not ss)
if 'germandbls' in substitution_table.mapping:
substitution_table.mapping['germandbls'] = 'glyph01192'
if style == 'Sans' and not italic:
# lookup 88 sets different numbers for smallcaps
if lookup_id == 88:
for g in list(substitution_table.mapping.keys()):
del substitution_table.mapping[g]
# replace ß with appropriate glyph (not ss)
if 'germandbls' in substitution_table.mapping:
substitution_table.mapping['germandbls'] = 'glyph01708'
def slice_font(style, source, weight, adobe_weight, verbose_weight, italic=False):
source_dir = _root_dir / 'adobe' / '-'.join(source.split(' ')[:2]).lower() / 'VAR'
source_fnt = f'{source.replace(" ", "")}-{"Roman" if not italic else "Italic"}.ttf'
......@@ -123,7 +157,7 @@ def slice_font(style, source, weight, adobe_weight, verbose_weight, italic=False
update_name_table(instance, style, weight, verbose_weight, italic)
update_flags(instance, weight, italic)
# TODO: patch small caps
patch_small_caps(instance, style, italic)
output_dir = _root_dir / 'out' / f'gypt-{style.lower()}' / 'TTF'
output_fnt = f'GYPT{style}-{(weight != 400 or not italic)*verbose_weight}{italic*"It"}.ttf'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment