def build_glyphs(bitbucket, f):

    from sortsmill import cap_spacing

    figures = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']

    def base(letter):
        if letter == 'i':
            base = 'dotlessi'
        elif letter == 'j':
            base = 'uni0237'
        else:
            base = letter
        return base    

    db = font_db.db_create(f)

    db['spacing_anchor_heights'] = {
        'hi' : 650,             # caps and ascenders,
        'x'  : 380,             # ex-height
        'o'  : 200,             # like the letter o
        'bl' : 10,              # baseline
        'lo' : -260,            # descenders
        }

    all_glyphs = set(f) - set(['.notdef'])
    proportional_figures = ['zero.p', 'one.p', 'two.p', 'three.p', 'four.p', 'five.p', 'six.p', 'seven.p', 'eight.p', 'nine.p']
    (uppercase, lowercase, fraction_bar, numerators, denominators, remaining) = \
        tuple(separate_strings(all_glyphs, [
                (lambda s: is_uppercase(s, last_name)),
                (lambda s: is_lowercase(s, last_name) or s in proportional_figures),
                (lambda s: s == 'fraction'),
                (lambda s: s[-6:] == '.numer'),
                (lambda s: s[-6:] == '.denom'),
                ]))

    db["kerning_sets"] = [
        (remaining, uppercase | lowercase | remaining),
        (uppercase, uppercase | lowercase | remaining),
        (lowercase, uppercase | lowercase | remaining),
        (numerators, fraction_bar),
        (fraction_bar, denominators),
        ]

    build_several_space_glyphs(f, emsize = emsize, spacesize = spacesize,
                               thinspacesize = emsize / 6,
                               hairspacesize = emsize / 10,
                               tabwidth = f['zero'].width)

    propagate_hyphens(f)
    propagate_hyphens(f, '.u')
    build_spacing_marks(f, width = 2 * 200)

    make_glyph_reference('minute', f['quotesingle'])
    make_glyph_reference('second', f['quotedbl'])
    make_glyph_reference('asciitilde', f['uni2053']) # Swung dash.
    make_glyph_reference('i.TRK', f['i'])
    make_glyph_reference('L.CAT', f['L'])
    make_glyph_reference('l.CAT', f['l'])
    make_glyph_reference('Dcroat', f['Eth'])

    build_multigraph('ellipsis', [f['period'], f['period'], f['period']])

    for extension in [('.numer', 250), ('.sub', -150), ('.sup', 350)]:
        for fig in figures + ['comma', 'period', 'hyphen',
                              'parenleft', 'parenright',
                              'bracketleft', 'bracketright',
                              'dollar', 'cent',
                              ] + [string.ascii_lowercase[i] for i in range(0, 26)]:
            make_glyph_reference(fig + extension[0],
                                 f[fig + '.denom'],
                                 transformation = (1, 0, 0, 1, 0, extension[1]),
                                 copy_spacing_anchors = (extension[0] == '.numer'))

    make_glyph_reference('uni00B9', f['one.sup'])
    make_glyph_reference('uni00B2', f['two.sup'])
    make_glyph_reference('uni00B3', f['three.sup'])
    make_glyph_reference('ordfeminine', f['a.sup'])
    make_glyph_reference('ordmasculine', f['o.sup'])
    build_multigraph('onequarter', [f['one.numer'], f['fraction'], f['four.denom']], copy_spacing_anchors = False)
    build_multigraph('onehalf', [f['one.numer'], f['fraction'], f['two.denom']], copy_spacing_anchors = False)
    build_multigraph('threequarters', [f['three.numer'], f['fraction'], f['four.denom']], copy_spacing_anchors = False)

    #--------------------------------------------------------------------------

    for letter in 'GKkLlNnRr':
        build_accented_glyph(letter + 'commaaccent', f[base(letter)], f['uni0326'])
    build_accented_glyph('uni0218', f['S'], f['uni0326'])
    build_accented_glyph('uni0219', f['s'], f['uni0326'])
    build_accented_glyph('uni021A', f['T'], f['uni0326'])
    build_accented_glyph('uni021B', f['t'], f['uni0326'])
    build_accented_glyph('gcommaaccent', f['g'], f['uni0312'])

    #--------------------------------------------------------------------------

    for letter in 'CcSs':
        build_accented_glyph(letter + 'cedilla', f[base(letter)], f['uni0327'])
        remove_overlap(f[letter + 'cedilla'])
    build_accented_glyph('uni0162', f['T'], f['uni0327'])
    remove_overlap(f['uni0162'])
    build_accented_glyph('uni0163', f['t'], f['uni0327'])
    remove_overlap(f['uni0163'])

    #--------------------------------------------------------------------------

    for letter in 'aeiou':
        build_accented_glyph(letter + 'grave', f[base(letter)], f['gravecomb'])
    for letter in 'AEIOU':
        build_accented_glyph(letter + 'grave', f[base(letter)], f['gravecomb.cap'])

    #--------------------------------------------------------------------------

    for letter in 'aceinorsuyz':
        build_accented_glyph(letter + 'acute', f[base(letter)], f['acutecomb'])
    for letter in 'ACEILNORSUYZ':
        build_accented_glyph(letter + 'acute', f[base(letter)], f['acutecomb.cap'])
    build_accented_glyph('lacute', f['l'], f['acutecomb.cap'])

    #--------------------------------------------------------------------------

    for letter in 'ainou':
        build_accented_glyph(letter + 'tilde', f[base(letter)], f['tildecomb'])
    for letter in 'AINOU':
        build_accented_glyph(letter + 'tilde', f[base(letter)], f['tildecomb.cap'])

    #--------------------------------------------------------------------------

    for letter in 'aeouy':
        build_accented_glyph(letter + 'dieresis', f[base(letter)], f['uni0308'])
    for letter in 'AEIOUY':
        build_accented_glyph(letter + 'dieresis', f[base(letter)], f['uni0308.cap'])
    for letter in 'i':
        build_accented_glyph(letter + 'dieresis', f[base(letter)], f['uni0308.narrow'])

    #--------------------------------------------------------------------------

    for letter in 'au':
        build_accented_glyph(letter + 'ring', f[base(letter)], f['uni030A'])
    for letter in 'AU':
        build_accented_glyph(letter + 'ring', f[base(letter)], f['uni030A.cap'])

    #--------------------------------------------------------------------------

    for letter in 'acegijosuwy':
        build_accented_glyph(letter + 'circumflex', f[base(letter)], f['uni0302'])
    for letter in 'ACEGHIJOSUWYh':
        build_accented_glyph(letter + 'circumflex', f[base(letter)], f['uni0302.cap'])

    # A gift for Esperantists, although 'ffĥ' seems unlikely.
    for letter in ['f_h', 'f_f_h']:
        build_accented_glyph(letter + 'circumflex', f[base(letter)], f['uni0302.cap'])

    #--------------------------------------------------------------------------

    for letter in 'aegiou':
        build_accented_glyph(letter + 'breve', f[base(letter)], f['uni0306'])
    for letter in 'AEGIOU':
        build_accented_glyph(letter + 'breve', f[base(letter)], f['uni0306.cap'])

    #--------------------------------------------------------------------------

    for letter in 'cegz':
        build_accented_glyph(letter + 'dotaccent', f[base(letter)], f['uni0307'])
    for letter in 'CEGIZ':
        build_accented_glyph(letter + 'dotaccent', f[base(letter)], f['uni0307.cap'])

    # Extra dot accents for Old Irish.
    build_accented_glyph('uni1E02', f['B'], f['uni0307.cap'])
    build_accented_glyph('uni1E03', f['b'], f['uni0307.cap'])
    build_accented_glyph('uni1E0A', f['D'], f['uni0307.cap'])
    build_accented_glyph('uni1E0B', f['d'], f['uni0307.cap'])
    build_accented_glyph('uni1E1E', f['F'], f['uni0307.cap'])
    build_accented_glyph('uni1E1F', f['f'], f['uni0307.cap'])
    build_accented_glyph('uni1E22', f['H'], f['uni0307.cap'])
    build_accented_glyph('uni1E23', f['h'], f['uni0307.cap'])
    build_accented_glyph('uni1E40', f['M'], f['uni0307.cap'])
    build_accented_glyph('uni1E41', f['m'], f['uni0307'])
    build_accented_glyph('uni1E56', f['P'], f['uni0307.cap'])
    build_accented_glyph('uni1E57', f['p'], f['uni0307'])
    build_accented_glyph('uni1E60', f['S'], f['uni0307.cap'])
    build_accented_glyph('uni1E61', f['s'], f['uni0307'])
    build_accented_glyph('uni1E6A', f['T'], f['uni0307.cap'])
    build_accented_glyph('uni1E6B', f['t'], f['uni0307'])

    #--------------------------------------------------------------------------

    for letter in 'cenrsz':
        build_accented_glyph(letter + 'caron', f[base(letter)], f['uni030C'])
    for letter in 'CDENRTSZ':
        build_accented_glyph(letter + 'caron', f[base(letter)], f['uni030C.cap'])
    for letter in 'dLlt':
        build_accented_glyph(letter + 'caron', f[base(letter)], f['uni0315'])

    #--------------------------------------------------------------------------

    for letter in 'aeiou':
        build_accented_glyph(letter + 'macron', f[base(letter)], f['uni0304'])
    for letter in 'AEIOU':
        build_accented_glyph(letter + 'macron', f[base(letter)], f['uni0304.cap'])

    #--------------------------------------------------------------------------

    for letter in 'ou':
        build_accented_glyph(letter + 'hungarumlaut', f[base(letter)], f['uni030B'])
    for letter in 'OU':
        build_accented_glyph(letter + 'hungarumlaut', f[base(letter)], f['uni030B.cap'])

    #--------------------------------------------------------------------------

    build_multigraph('napostrophe', [f['quoteright'], f['n']])
    build_multigraph('ldot', [f['l'], f['periodcentered']])

    build_multigraph('IJ', [f['I'], f['J']])
    build_multigraph('ij', [f['i'], f['j']])

    #--------------------------------------------------------------------------

    f.selection.all()
    space_selected_by_anchors(f)
    f.selection.none()

    generate_kerning_and_read_features(None, f)

    #--------------------------------------------------------------------------

    font_db.db_close(f)
示例#2
0
def build_glyphs(bitbucket, f):

    from sortsmill import cap_spacing

    figures = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
    lining_figures = [s + '.lining' for s in figures]

    caps = [
        'A', 'Agrave', 'Aacute', 'Acircumflex', 'Atilde', 'Adieresis', 'Aring', 'Amacron', 'Abreve', 'Aogonek',
        'B',
        'C', 'Ccedilla', 'Cacute', 'Ccircumflex', 'Cdotaccent', 'Ccaron',
        'D', 'Dcaron', 'Dcroat',
        'E', 'Egrave', 'Eacute', 'Ecircumflex', 'Edieresis', 'Emacron', 'Ebreve', 'Edotaccent', 'Eogonek', 'Ecaron',
        'F',
        'G', 'Gcircumflex', 'Gbreve', 'Gdotaccent', 'Gcommaaccent',
        'H', 'Hcircumflex', 'Hbar',
        'I', 'Igrave', 'Iacute', 'Icircumflex', 'Idieresis', 'Itilde', 'Imacron', 'Ibreve', 'Iogonek',
        'J', 'Jcircumflex',
        'K', 'Kcommaaccent',
        'L', 'Lacute', 'Lcommaaccent', 'Lcaron', 'Ldot', 'Lslash',
        'M',
        'N', 'Ntilde', 'Nacute', 'Ncommaaccent', 'Ncaron',
        'O', 'Ograve', 'Oacute', 'Ocircumflex', 'Otilde', 'Odieresis', 'Oslash', 'Omacron', 'Obreve', 'Ohungarumlaut',
        'P',
        'Q',
        'R', 'Racute', 'Rcommaaccent', 'Rcaron',
        'S', 'Sacute', 'Scircumflex', 'Scedilla', 'uni0218', 'Scaron',
        'T', 'uni0162', 'uni021A', 'Tcaron', 'Tbar',
        'U', 'Ugrave', 'Uacute', 'Ucircumflex', 'Udieresis', 'Utilde', 'Umacron', 'Ubreve', 'Uring', 'Uhungarumlaut', 'Uogonek',
        'V',
        'W', 'Wcircumflex',
        'X',
        'Y', 'Yacute', 'Ydieresis', 'Ycircumflex',
        'Z', 'Zacute', 'Zdotaccent', 'Zcaron',
        'IJ', 'AE', 'OE', 'Eth', 'Thorn',
        'question', 'questiondown',
        'exclam', 'exclamdown',
        'ampersand'
        ]

    def base(letter):
        if letter == 'i':
            base = 'dotlessi'
        elif letter == 'j':
            base = 'uni0237'
        else:
            base = letter
        return base    

    db = font_db.db_create(f)

    db['spacing_anchor_heights'] = { 'hi' : 732, # caps and ascenders
                                     't'  : 562, # top diacritics
                                     'x'  : 415,  # ex-height
                                     'o'  : 220,  # like the letter o
                                     'bl' : 20,   # baseline
                                     'lo' : -205 } # descenders

    build_several_space_glyphs(f, emsize = 1000, spacesize = 213,
                               thinspacesize = 1000 / 6,
                               hairspacesize = 1000 / 10,
                               tabwidth = f['zero.lining'].width)
    propagate_hyphens(f)
    propagate_hyphens(f, '.uppercase')
    build_spacing_marks(f, width = 439)

    make_glyph_reference('quotesingle', f['quoteright'])
    make_glyph_reference('quotedbl', f['quotedblright'])
    make_glyph_reference('i.TRK', f['i'])
    make_glyph_reference('Dcroat', f['Eth'])
    make_glyph_reference('dcroat.sc', f['eth.sc'])

    make_glyph_reference('uni00B9', f['one.lining.sup'])
    make_glyph_reference('uni00B2', f['two.lining.sup'])
    make_glyph_reference('uni00B3', f['three.lining.sup'])
    for g in f:
        if g[-4:] == '.sup':
            make_glyph_reference(g[:-4] + '.sub', f[g], (1, 0, 0, 1, 0, -707))
    for g in lining_figures + ['comma', 'period']:
        make_glyph_reference(g + '.numer', f[g + '.sup'], (1, 0, 0, 1, 0, -177))
    for g in lining_figures + ['comma', 'period']:
        make_glyph_reference(g + '.denom', f[g + '.sup'], (1, 0, 0, 1, 0, -386))
    build_multigraph('onequarter', [f['one.lining.numer'], f['fraction'], f['four.lining.denom']])
    build_multigraph('onehalf', [f['one.lining.numer'], f['fraction'], f['two.lining.denom']])
    build_multigraph('threequarters', [f['three.lining.numer'], f['fraction'], f['four.lining.denom']])

    for g in f:
        if g[-3:] == '.sc':
            if g == 'periodcentered.sc':
                make_glyph_reference(g[:-3] + '.c2', f[g])
            elif g == 'uni0163.sc':
                make_glyph_reference('uni0162.c2', f[g])
            elif g == 'uni0219.sc':
                make_glyph_reference('uni0218.c2', f[g])
            elif g == 'uni021B.sc':
                make_glyph_reference('uni021A.c2', f[g])
            elif g in ('ae.sc', 'oe.sc'):
                make_glyph_reference(g[:-3].upper() + '.c2', f[g])
            else:
                make_glyph_reference(g[:-3].capitalize() + '.c2', f[g])

    #--------------------------------------------------------------------------

    for letter in 'GKkLlNnRr':
                build_accented_glyph(letter + 'commaaccent', f[base(letter)], f['uni0326'])
    build_accented_glyph('gcommaaccent', f['g'], f['uni0312'])
    build_accented_glyph('uni0218', f['S'], f['uni0326'])
    build_accented_glyph('uni0219', f['s'], f['uni0326'])
    build_accented_glyph('uni021A', f['T'], f['uni0326'])
    build_accented_glyph('uni021B', f['t'], f['uni0326'])

    for letter in 'gklnr':
                build_accented_glyph(letter + 'commaaccent.sc', f[letter + '.sc'], f['uni0326'])
    build_accented_glyph('uni0219.sc', f['s.sc'], f['uni0326'])
    build_accented_glyph('uni021B.sc', f['t.sc'], f['uni0326'])

    #--------------------------------------------------------------------------

    for letter in 'CcSs':
                build_accented_glyph(letter + 'cedilla', f[base(letter)], f['uni0327'])
    build_accented_glyph('uni0162', f['T'], f['uni0327'])
    build_accented_glyph('uni0163', f['t'], f['uni0327'])

    for letter in 'cs':
                build_accented_glyph(letter + 'cedilla.sc', f[letter + '.sc'], f['uni0327'])
    build_accented_glyph('uni0163.sc', f['t.sc'], f['uni0327'])

    #--------------------------------------------------------------------------

    for letter in 'AaEeIiOoUu':
                build_accented_glyph(letter + 'grave', f[base(letter)], f['gravecomb'])

    for letter in 'aeiou':
                build_accented_glyph(letter + 'grave.sc', f[letter + '.sc'], f['gravecomb'])

    #--------------------------------------------------------------------------

    for letter in 'AaCcEeIiLlNnOoRrSsUuYyZz':
                build_accented_glyph(letter + 'acute', f[base(letter)], f['acutecomb'])

    for letter in 'aceilnorsuyz':
                build_accented_glyph(letter + 'acute.sc', f[letter + '.sc'], f['acutecomb'])

    #--------------------------------------------------------------------------

    for letter in 'AaIiNnOoUu':
                build_accented_glyph(letter + 'tilde', f[base(letter)], f['tildecomb'])

    for letter in 'ainou':
                build_accented_glyph(letter + 'tilde.sc', f[letter + '.sc'], f['tildecomb'])

    #--------------------------------------------------------------------------

    for letter in 'AaEeIiOoUuYy':
                build_accented_glyph(letter + 'dieresis', f[base(letter)], f['uni0308'])

    for letter in 'aeiouy':
                build_accented_glyph(letter + 'dieresis.sc', f[letter + '.sc'], f['uni0308'])

    #--------------------------------------------------------------------------

    for letter in 'AaUu':
                build_accented_glyph(letter + 'ring', f[base(letter)], f['uni030A'])

    for letter in 'au':
                build_accented_glyph(letter + 'ring.sc', f[letter + '.sc'], f['uni030A'])

    #--------------------------------------------------------------------------

    for letter in 'AaCcEeGgHhIiJjOoSsUuWwYy':
        build_accented_glyph(letter + 'circumflex', f[base(letter)], f['uni0302'])

    for letter in 'aceghijosuwy':
        build_accented_glyph(letter + 'circumflex.sc', f[letter + '.sc'], f['uni0302'])

    #--------------------------------------------------------------------------

    for letter in 'AaEeGgIiOoUu':
                build_accented_glyph(letter + 'breve', f[base(letter)], f['uni0306'])

    for letter in 'aegiou':
                build_accented_glyph(letter + 'breve.sc', f[letter + '.sc'], f['uni0306'])

    #--------------------------------------------------------------------------

    for letter in 'CcEeGgIZz':
                build_accented_glyph(letter + 'dotaccent', f[base(letter)], f['uni0307'])

    for letter in 'cegz':
                build_accented_glyph(letter + 'dotaccent.sc', f[letter + '.sc'], f['uni0307'])
    build_accented_glyph('i.TRK.sc', f['i.sc'], f['uni0307'])

    #--------------------------------------------------------------------------

    for letter in 'CcDEeNnRrTSsZz':
                build_accented_glyph(letter + 'caron', f[base(letter)], f['uni030C'])
    for letter in 'dLlt':
                build_accented_glyph(letter + 'caron', f[base(letter)], f['uni0315'])

    for letter in 'cdenrstz':
                build_accented_glyph(letter + 'caron.sc', f[letter + '.sc'], f['uni030C'])
    build_accented_glyph('lcaron.sc', f['l.sc'], f['uni0315'])

    #--------------------------------------------------------------------------

    for letter in 'AaEeIiOoUu':
                build_accented_glyph(letter + 'macron', f[base(letter)], f['uni0304'])

    for letter in 'aeiou':
                build_accented_glyph(letter + 'macron.sc', f[letter + '.sc'], f['uni0304'])

    #--------------------------------------------------------------------------

    for letter in 'OoUu':
                build_accented_glyph(letter + 'hungarumlaut', f[base(letter)], f['uni030B'])

    for letter in 'ou':
                build_accented_glyph(letter + 'hungarumlaut.sc', f[letter + '.sc'], f['uni030B'])

    #--------------------------------------------------------------------------

    build_multigraph('ellipsis', [f['period'], f['period'], f['period']])
    build_multigraph('napostrophe', [f['quoteright'], f['n']])
    build_multigraph('IJ', [f['I'], f['J']])
    build_multigraph('ij', [f['i'], f['j']])
    build_multigraph('Ldot', [f['L'], f['periodcentered']])
    build_multigraph('ldot', [f['l'], f['periodcentered']])
    build_multigraph('ldot.sc', [f['l.sc'], f['periodcentered.sc']])

    #--------------------------------------------------------------------------

    f.selection.all()
    spacing_by_anchors.space_selected_by_anchors(f)
    f.selection.none()

    generate_kerning_and_read_features(None, f)

    #--------------------------------------------------------------------------

    font_db.db_close(f)
def build_glyphs(bitbucket, f):

    from sortsmill import cap_spacing

    figures = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']

    def base(letter):
        if letter == 'i':
            base = 'dotlessi'
        elif letter == 'j':
            base = 'uni0237'
        else:
            base = letter
        return base

    db = font_db.db_create(f)

    db['spacing_anchor_heights'] = { 'hi2' : 670, # caps and ascenders,
                                     'hi' : 610,  # caps and ascenders,
                                     'x'  : 385,  # ex-height
                                     'o'  : 200,  # like the letter o
                                     'bl' : 10,   # baseline
                                     'lo' : -200, # descenders
                                     }

#    all_glyphs = set(f) - set(['.notdef'])
#    (smallcaps, capssmall, uppercase, lowercase, fraction_bar, numerators, denominators, remaining) = \
#        tuple(separate_strings(all_glyphs, [
#                (lambda s: s[-3:] == '.sc'),
#                (lambda s: s[-3:] == '.c2'),
#                (lambda s: is_uppercase(s, last_name)),
#                (lambda s: is_lowercase(s, last_name)),
#                (lambda s: s == 'fraction'),
#                (lambda s: s[-6:] == '.numer'),
#                (lambda s: s[-6:] == '.denom'),
#                ]))
#    db["kerning_sets"] = [
#        (remaining, uppercase | lowercase | smallcaps | capssmall | remaining),
#        (uppercase, uppercase | lowercase | smallcaps | remaining),
#        (smallcaps, uppercase | smallcaps | capssmall | remaining),
#        (lowercase, uppercase | lowercase | remaining),
#        (numerators, fraction_bar),
#        (fraction_bar, denominators),
#        ]
#    db['kerning_rounding'] = '(lambda x: int(round(x/5.0)) * 5)'
##    db['kerning_rounding'] = '(lambda x: x if abs(x) < 10 else int(round(x/5.0))*5)'

    build_several_space_glyphs(f, emsize = emsize, spacesize = spacesize,
                               thinspacesize = emsize / 6,
                               hairspacesize = emsize / 10,
#                               tabwidth = f['zero.l'].width)
                               tabwidth = 300) # <-- FIX: SET THIS CORRECTLY

    propagate_hyphens(f)
#    propagate_hyphens(f, '.uppercase')
    build_spacing_marks(f, width = 2 * 230)

#    for fig in figures:
#        make_glyph_reference(fig, f[fig + '.h'])

    make_glyph_reference('asciitilde', f['uni2053']) # Swung dash.
    make_glyph_reference('i.TRK', f['i'])
    make_glyph_reference('Dcroat', f['Eth'])
#    make_glyph_reference('dcroat.sc', f['eth.sc'])

    build_multigraph('ellipsis', [f['period'], f['period'], f['period']])

#    for fig in figures + ['dollar']:
#        make_glyph_reference(fig, f[fig + '.hanging'])
#
#    make_glyph_reference('uni00B9', f['one.sup'])
#    make_glyph_reference('uni00B2', f['two.sup'])
#    make_glyph_reference('uni00B3', f['three.sup'])
##    for extension in [('.numer', 244), ('.sub', -98), ('.sup', 293)]:
#    for extension in [('.sub', -98), ('.sup', 293)]:
#        for fig in figures:
#            make_glyph_reference(fig + extension[0],
#                                 f[fig + '.denom'],
#                                 transformation = (1, 0, 0, 1, 0, extension[1]),
#                                 copy_spacing_anchors = False)
#    build_multigraph('onequarter', [f['one.numer'], f['fraction'], f['four.denom']])
#    build_multigraph('onehalf', [f['one.numer'], f['fraction'], f['two.denom']])
#    build_multigraph('threequarters', [f['three.numer'], f['fraction'], f['four.denom']])

#    for g in f:
#        if g[-3:] == '.sc':
#            if g == 'periodcentered.sc':
#                make_glyph_reference(g[:-3] + '.c2', f[g])
#            elif g == 'uni0163.sc':
#                make_glyph_reference('uni0162.c2', f[g])
#            elif g == 'uni0219.sc':
#                make_glyph_reference('uni0218.c2', f[g])
#            elif g == 'uni021B.sc':
#                make_glyph_reference('uni021A.c2', f[g])
#            elif g in ('ae.sc', 'oe.sc'):
#                make_glyph_reference(g[:-3].upper() + '.c2', f[g])
#            else:
#                make_glyph_reference(g[:-3].capitalize() + '.c2', f[g])

    #--------------------------------------------------------------------------

    for letter in 'GKkLlNnRr':
        build_accented_glyph(letter + 'commaaccent', f[base(letter)], f['uni0326'])
    build_accented_glyph('uni0218', f['S'], f['uni0326'])
    build_accented_glyph('uni0219', f['s'], f['uni0326'])
    build_accented_glyph('uni021A', f['T'], f['uni0326'])
    build_accented_glyph('uni021B', f['t'], f['uni0326'])
    build_accented_glyph('gcommaaccent', f['g'], f['uni0312'])
    build_accented_glyph('gcommaaccent.ld', f['g.ld'], f['uni0312'])

#    for letter in 'gklnr':
#        build_accented_glyph(letter + 'commaaccent.sc', f[letter + '.sc'], f['uni0326'])
#    build_accented_glyph('uni0219.sc', f['s.sc'], f['uni0326'])
#    build_accented_glyph('uni021B.sc', f['t.sc'], f['uni0326'])

    #--------------------------------------------------------------------------

    for letter in 'CcSs':
        build_accented_glyph(letter + 'cedilla', f[base(letter)], f['uni0327'])
        remove_overlap(f[letter + 'cedilla'])
    build_accented_glyph('uni0162', f['T'], f['uni0327'])
    remove_overlap(f['uni0162'])
#    build_accented_glyph('uni0163', f['t'], f['uni0327']) <-- don't rebuild; it's manually hinted
#    remove_overlap(f['uni0163'])                          <-- don't rebuild; it's manually hinted

#    for letter in 'cs':
#        build_accented_glyph(letter + 'cedilla.sc', f[letter + '.sc'], f['uni0327'])
#    build_accented_glyph('uni0163.sc', f['t.sc'], f['uni0327'])

    #--------------------------------------------------------------------------

    for letter in 'aeiou':
        build_accented_glyph(letter + 'grave', f[base(letter)], f['gravecomb'])
    for letter in 'AEIOU':
        build_accented_glyph(letter + 'grave', f[base(letter)], f['gravecomb.cap'])
#    for letter in 'aeiou':
#        build_accented_glyph(letter + 'grave.sc', f[letter + '.sc'], f['gravecomb'])
#
    #--------------------------------------------------------------------------

    for letter in 'aceinorsuyz':
        build_accented_glyph(letter + 'acute', f[base(letter)], f['acutecomb'])
    for letter in 'ACEILNORSUYZ':
        build_accented_glyph(letter + 'acute', f[base(letter)], f['acutecomb.cap'])
    build_accented_glyph('lacute', f['l'], f['acutecomb.cap'])
    for letter in 'y':
        build_accented_glyph(letter + 'acute.ld', f[base(letter) + '.ld'], f['acutecomb'])
    for letter in 'y':
        build_accented_glyph(letter + 'acute.001', f[base(letter) + '.001'], f['acutecomb'])
#    for letter in 'aceilnorsuyz':
#        build_accented_glyph(letter + 'acute.sc', f[letter + '.sc'], f['acutecomb'])

    #--------------------------------------------------------------------------

    for letter in 'ainou':
        build_accented_glyph(letter + 'tilde', f[base(letter)], f['tildecomb'])
    for letter in 'AINOU':
        build_accented_glyph(letter + 'tilde', f[base(letter)], f['tildecomb.cap'])
#    for letter in 'ainou':
#        build_accented_glyph(letter + 'tilde.sc', f[letter + '.sc'], f['tildecomb'])
#
#    #--------------------------------------------------------------------------
#
    for letter in 'aeouy':
        build_accented_glyph(letter + 'dieresis', f[base(letter)], f['uni0308'])
    for letter in 'AEIOUY':
        build_accented_glyph(letter + 'dieresis', f[base(letter)], f['uni0308.cap'])
    for letter in 'i':
        build_accented_glyph(letter + 'dieresis', f[base(letter)], f['uni0308.narrow'])
    for letter in 'y':
        build_accented_glyph(letter + 'dieresis.ld', f[base(letter) + '.ld'], f['uni0308'])
    for letter in 'y':
        build_accented_glyph(letter + 'dieresis.001', f[base(letter) + '.001'], f['uni0308'])
#    for letter in 'aeiouy':
#        build_accented_glyph(letter + 'dieresis.sc', f[letter + '.sc'], f['uni0308'])

    #--------------------------------------------------------------------------

    for letter in 'au':
        build_accented_glyph(letter + 'ring', f[base(letter)], f['uni030A'])
    for letter in 'AU':
        build_accented_glyph(letter + 'ring', f[base(letter)], f['uni030A.cap'])
#    for letter in 'au':
#        build_accented_glyph(letter + 'ring.sc', f[letter + '.sc'], f['uni030A'])

    #--------------------------------------------------------------------------

    for letter in 'acegijosuwy':
        build_accented_glyph(letter + 'circumflex', f[base(letter)], f['uni0302'])
    for letter in 'hACEGHIJOSUWY':
        build_accented_glyph(letter + 'circumflex', f[base(letter)], f['uni0302.cap'])
    for letter in 'gjy':
        build_accented_glyph(letter + 'circumflex.ld', f[base(letter) + '.ld'], f['uni0302'])
    for letter in 'y':
        build_accented_glyph(letter + 'circumflex.001', f[base(letter) + '.001'], f['uni0302'])
    build_accented_glyph('jcircumflex.001', f['uni0237.001'], f['uni0302'])
    build_accented_glyph('jcircumflex.002', f['uni0237.002'], f['uni0302'])

#    for letter in ['f_h', 'f_f_h']:
#        build_accented_glyph(letter + 'circumflex', f[base(letter)], f['uni0302.cap'])
#    for letter in 'aceghijosuwy':
#        build_accented_glyph(letter + 'circumflex.sc', f[letter + '.sc'], f['uni0302'])

    #--------------------------------------------------------------------------

    for letter in 'aegiou':
        build_accented_glyph(letter + 'breve', f[base(letter)], f['uni0306'])
    for letter in 'AEGIOU':
        build_accented_glyph(letter + 'breve', f[base(letter)], f['uni0306.cap'])
    for letter in 'g':
        build_accented_glyph(letter + 'breve.ld', f[base(letter) + '.ld'], f['uni0306'])
#    for letter in 'aegiou':
#        build_accented_glyph(letter + 'breve.sc', f[letter + '.sc'], f['uni0306'])

    #--------------------------------------------------------------------------

    for letter in 'cegz':
        build_accented_glyph(letter + 'dotaccent', f[base(letter)], f['uni0307'])
    for letter in 'CEGIZ':
        build_accented_glyph(letter + 'dotaccent', f[base(letter)], f['uni0307.cap'])
    for letter in 'g':
        build_accented_glyph(letter + 'dotaccent.ld', f[base(letter) + '.ld'], f['uni0307'])
#    for letter in 'cegz':
#        build_accented_glyph(letter + 'dotaccent.sc', f[letter + '.sc'], f['uni0307'])
#    build_accented_glyph('i.TRK.sc', f['i.sc'], f['uni0307'])

    build_accented_glyph('i', f['dotlessi'], f['uni0307'])
    build_accented_glyph('iogonek', f['iogonek.dotless'], f['uni0307'])
    build_accented_glyph('j', f['uni0237'], f['uni0307'])
    build_accented_glyph('j.ld', f['uni0237.ld'], f['uni0307'])
    build_accented_glyph('j.001', f['uni0237.001'], f['uni0307'])
    build_accented_glyph('j.002', f['uni0237.002'], f['uni0307'])

    # Extra dot accents for Old Irish.
    build_accented_glyph('uni1E02', f['B'], f['uni0307.cap'])
    build_accented_glyph('uni1E03', f['b'], f['uni0307.cap'])
    build_accented_glyph('uni1E0A', f['D'], f['uni0307.cap'])
    build_accented_glyph('uni1E0B', f['d'], f['uni0307.cap'])
    build_accented_glyph('uni1E1E', f['F'], f['uni0307.cap'])
    build_accented_glyph('uni1E1F', f['f'], f['uni0307.cap'])
    build_accented_glyph('uni1E1F.ld', f['f.ld'], f['uni0307.cap'])
    build_accented_glyph('uni1E1F.001', f['f.001'], f['uni0307.cap'])
    build_accented_glyph('uni1E22', f['H'], f['uni0307.cap'])
    build_accented_glyph('uni1E23', f['h'], f['uni0307.cap'])
    build_accented_glyph('uni1E40', f['M'], f['uni0307.cap'])
    build_accented_glyph('uni1E41', f['m'], f['uni0307'])
    build_accented_glyph('uni1E56', f['P'], f['uni0307.cap'])
    build_accented_glyph('uni1E57', f['p'], f['uni0307'])
    build_accented_glyph('uni1E57.ld', f['p.ld'], f['uni0307'])
    build_accented_glyph('uni1E57.001', f['p.001'], f['uni0307'])
    build_accented_glyph('uni1E57.002', f['p.002'], f['uni0307'])
    build_accented_glyph('uni1E60', f['S'], f['uni0307.cap'])
    build_accented_glyph('uni1E61', f['s'], f['uni0307'])
    build_accented_glyph('uni1E6A', f['T'], f['uni0307.cap'])
    build_accented_glyph('uni1E6B', f['t'], f['uni0307'])

    #--------------------------------------------------------------------------

    for letter in 'cenrsz':
        build_accented_glyph(letter + 'caron', f[base(letter)], f['uni030C'])
    for letter in 'CDENRTSZ':
        build_accented_glyph(letter + 'caron', f[base(letter)], f['uni030C.cap'])
    for letter in 'dLlt':
        build_accented_glyph(letter + 'caron', f[base(letter)], f['uni0315'])

#    for letter in 'cdenrstz':
#        build_accented_glyph(letter + 'caron.sc', f[letter + '.sc'], f['uni030C'])
#    build_accented_glyph('lcaron.sc', f['l.sc'], f['uni0315'])

    #--------------------------------------------------------------------------

    for letter in 'aeiou':
        build_accented_glyph(letter + 'macron', f[base(letter)], f['uni0304'])
    for letter in 'AEIOU':
        build_accented_glyph(letter + 'macron', f[base(letter)], f['uni0304.cap'])
#    for letter in 'aeiou':
#        build_accented_glyph(letter + 'macron.sc', f[letter + '.sc'], f['uni0304'])

    #--------------------------------------------------------------------------

    for letter in 'ou':
        build_accented_glyph(letter + 'hungarumlaut', f[base(letter)], f['uni030B'])
    for letter in 'OU':
        build_accented_glyph(letter + 'hungarumlaut', f[base(letter)], f['uni030B.cap'])
#    for letter in 'ou':
#        build_accented_glyph(letter + 'hungarumlaut.sc', f[letter + '.sc'], f['uni030B'])

    #--------------------------------------------------------------------------

    build_multigraph('napostrophe', [f['quoteright'], f['n']])

    build_multigraph('IJ', [f['I'], f['J']])
    build_multigraph('ij', [f['i'], f['j']])

    build_multigraph('f_b', [f['f'], f['b']])
    build_multigraph('f_h', [f['f'], f['h']])
    build_multigraph('f_hcircumflex', [f['f'], f['hcircumflex']])
    build_multigraph('f_k', [f['f'], f['k']])
    build_multigraph('f_l', [f['f'], f['l']])

    build_multigraph('f_f_b', [f['f_f'], f['b']])
    build_multigraph('f_f_h', [f['f_f'], f['h']])
    build_multigraph('f_f_hcircumflex', [f['f_f'], f['hcircumflex']])
    build_multigraph('f_f_k', [f['f_f'], f['k']])
    build_multigraph('f_f_l', [f['f_f'], f['l']])

    build_multigraph('f_b.ld', [f['f.ld'], f['b']])
    build_multigraph('f_h.ld', [f['f.ld'], f['h']])
    build_multigraph('f_hcircumflex.ld', [f['f.ld'], f['hcircumflex']])
    build_multigraph('f_k.ld', [f['f.ld'], f['k']])
    build_multigraph('f_l.ld', [f['f.ld'], f['l']])

    build_multigraph('f_f_b.ld', [f['f_f.ld'], f['b']])
    build_multigraph('f_f_h.ld', [f['f_f.ld'], f['h']])
    build_multigraph('f_f_hcircumflex.ld', [f['f_f.ld'], f['hcircumflex']])
    build_multigraph('f_f_k.ld', [f['f_f.ld'], f['k']])
    build_multigraph('f_f_l.ld', [f['f_f.ld'], f['l']])

    #--------------------------------------------------------------------------

    f.selection.all()
    space_selected_by_anchors(f)
    f.selection.none()

    generate_kerning_and_read_features(None, f)

    #--------------------------------------------------------------------------

    font_db.db_close(f)
def build_glyphs(bitbucket, f):

    from sortsmill import cap_spacing

    figures = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']

    def base(letter):
        if letter == 'i':
            base = 'dotlessi'
        elif letter == 'j':
            base = 'uni0237'
        else:
            base = letter
        return base    

    db = font_db.db_create(f)

    db['spacing_anchor_heights'] = { 'hi' : 684, # caps and ascenders
                                     'x'  : 376,  # ex-height
                                     'o'  : 195,  # like the letter o
                                     'bl' : 15,   # baseline
                                     'lo' : -244 } # descenders

    all_glyphs = set(f) - set(['.notdef'])
    (uppercase, lowercase, fraction_bar, numerators, denominators, remaining) = \
        tuple(separate_strings(all_glyphs, [
                (lambda s: is_uppercase(s, last_name)),
                (lambda s: is_lowercase(s, last_name)),
                (lambda s: s == 'fraction'),
                (lambda s: s[-6:] == '.numer'),
                (lambda s: s[-6:] == '.denom'),
                ]))
    db["kerning_sets"] = [
        (remaining, uppercase | lowercase | remaining),
        (uppercase, uppercase | lowercase | remaining),
        (lowercase, uppercase | lowercase | remaining),
        (numerators, fraction_bar),
        (fraction_bar, denominators),
        ]
    db['kerning_rounding'] = '(lambda x: int(round(x/5.0)) * 5)'

    build_several_space_glyphs(f, emsize = 1000, spacesize = 185,
                               thinspacesize = 1000 / 6,
                               hairspacesize = 1000 / 10,
                               tabwidth = f['zero.lining'].width)
    propagate_hyphens(f)
#    propagate_hyphens(f, '.uppercase')
    build_spacing_marks(f, width = 2 * 195)

    make_glyph_reference('quotesingle', f['minute'])
    make_glyph_reference('quotedbl', f['second'])
    make_glyph_reference('asciitilde', f['uni2053']) # Swung dash.
#    make_glyph_reference('i.TRK', f['i']) <-- Handled below.
    make_glyph_reference('Dcroat', f['Eth'])
    make_glyph_reference('Dcroat.001', f['Eth.001'])
    make_glyph_reference('L.CAT', f['L'])

    build_multigraph('ellipsis', [f['period'], f['period'], f['period']])

    for fig in figures + ['dollar']:
        make_glyph_reference(fig, f[fig + '.hanging'])

    make_glyph_reference('uni00B9', f['one.sup'])
    make_glyph_reference('uni00B2', f['two.sup'])
    make_glyph_reference('uni00B3', f['three.sup'])
    for extension in [('.numer', 244), ('.sub', -180), ('.sup', 244)]:
        for fig in figures:
            make_glyph_reference(fig + extension[0],
                                 f[fig + '.denom'],
                                 transformation = (1, 0, 0, 1, 0, extension[1]),
                                 copy_spacing_anchors = (extension[0] == '.numer'))
    build_multigraph('onequarter', [f['one.numer'], f['fraction'], f['four.denom']])
    build_multigraph('onehalf', [f['one.numer'], f['fraction'], f['two.denom']])
    build_multigraph('threequarters', [f['three.numer'], f['fraction'], f['four.denom']])

    #--------------------------------------------------------------------------

    for letter in 'GKkLlNnRr':
        build_accented_glyph(letter + 'commaaccent', f[base(letter)], f['uni0326'])
    for letter in 'k':
        build_accented_glyph(letter + 'commaaccent.001', f[base(letter) + '.001'], f['uni0326'])
    for letter in 'GNR':
        build_accented_glyph(letter + 'commaaccent.001', f[base(letter) + '.001'], f['uni0326'])
    build_accented_glyph('uni0218', f['S'], f['uni0326'])
    build_accented_glyph('uni0219', f['s'], f['uni0326'])
    build_accented_glyph('uni021A', f['T'], f['uni0326'])
    build_accented_glyph('uni021A.001', f['T.001'], f['uni0326'])
    build_accented_glyph('uni021A.002', f['T.002'], f['uni0326'])
    build_accented_glyph('uni021B', f['t'], f['uni0326'])
    build_accented_glyph('gcommaaccent', f['g'], f['uni0312'])
    build_accented_glyph('gcommaaccent.001', f['g.001'], f['uni0312'])

    #--------------------------------------------------------------------------

    for letter in 'CcSs':
        build_accented_glyph(letter + 'cedilla', f[base(letter)], f['uni0327'])
        remove_overlap(f[letter + 'cedilla'])
    build_accented_glyph('uni0162', f['T'], f['uni0327'])
    remove_overlap(f['uni0162'])
    build_accented_glyph('uni0162.001', f['T.001'], f['uni0327'])
    remove_overlap(f['uni0162.001'])
    build_accented_glyph('uni0162.002', f['T.002'], f['uni0327'])
    remove_overlap(f['uni0162.002'])
    build_accented_glyph('uni0163', f['t'], f['uni0327'])
    remove_overlap(f['uni0163'])

    #--------------------------------------------------------------------------

    for letter in 'aeiou':
        build_accented_glyph(letter + 'grave', f[base(letter)], f['gravecomb'])
    for letter in 'AEIOU':
        build_accented_glyph(letter + 'grave', f[base(letter)], f['gravecomb.cap'])
    for letter in 'AE':
        build_accented_glyph(letter + 'grave.001', f[base(letter) + '.001'], f['gravecomb.cap'])

    #--------------------------------------------------------------------------

    for letter in 'aceinorsuyz':
        build_accented_glyph(letter + 'acute', f[base(letter)], f['acutecomb'])
    for letter in 'z':
        build_accented_glyph(letter + 'acute.001', f[base(letter) + '.001'], f['acutecomb'])
    for letter in 'ACEILNORSUYZ':
        build_accented_glyph(letter + 'acute', f[base(letter)], f['acutecomb.cap'])
    for letter in 'ACENR':
        build_accented_glyph(letter + 'acute.001', f[base(letter) + '.001'], f['acutecomb.cap'])
    # build_accented_glyph('lacute', f['l'], f['acutecomb.cap']) <-- We are making this one by hand.

    #--------------------------------------------------------------------------

    for letter in 'ainou':
        build_accented_glyph(letter + 'tilde', f[base(letter)], f['tildecomb'])
    for letter in 'AINOU':
        build_accented_glyph(letter + 'tilde', f[base(letter)], f['tildecomb.cap'])
    for letter in 'AN':
        build_accented_glyph(letter + 'tilde.001', f[base(letter) + '.001'], f['tildecomb.cap'])

    #--------------------------------------------------------------------------

    for letter in 'aeouy':
        build_accented_glyph(letter + 'dieresis', f[base(letter)], f['uni0308'])
    for letter in 'AEIOUY':
        build_accented_glyph(letter + 'dieresis', f[base(letter)], f['uni0308.cap'])
    for letter in 'AE':
        build_accented_glyph(letter + 'dieresis.001', f[base(letter) + '.001'], f['uni0308.cap'])
    for letter in 'i':
        build_accented_glyph(letter + 'dieresis', f[base(letter)], f['uni0308'])

    #--------------------------------------------------------------------------

    for letter in 'au':
        build_accented_glyph(letter + 'ring', f[base(letter)], f['uni030A'])
    for letter in 'AU':
        build_accented_glyph(letter + 'ring', f[base(letter)], f['uni030A.cap'])
    for letter in 'A':
        build_accented_glyph(letter + 'ring.001', f[base(letter) + '.001'], f['uni030A.cap'])

    #--------------------------------------------------------------------------

    for letter in 'acegijosuwy':
        build_accented_glyph(letter + 'circumflex', f[base(letter)], f['uni0302'])
    for letter in 'g':
        build_accented_glyph(letter + 'circumflex.001', f[base(letter) + '.001'], f['uni0302'])
    for letter in 'hACEGHIJOSUWY':
        build_accented_glyph(letter + 'circumflex', f[base(letter)], f['uni0302.cap'])
    for letter in 'ACEG':
        build_accented_glyph(letter + 'circumflex.001', f[base(letter) + '.001'], f['uni0302.cap'])
    for letter in ['f_h', 'f_f_h']:
        build_accented_glyph(letter + 'circumflex', f[base(letter)], f['uni0302.cap'])

    #--------------------------------------------------------------------------

    for letter in 'aegiou':
        build_accented_glyph(letter + 'breve', f[base(letter)], f['uni0306'])
    for letter in 'g':
        build_accented_glyph(letter + 'breve.001', f[base(letter) + '.001'], f['uni0306'])
    for letter in 'AEGIOU':
        build_accented_glyph(letter + 'breve', f[base(letter)], f['uni0306.cap'])
    for letter in 'AEG':
        build_accented_glyph(letter + 'breve.001', f[base(letter) + '.001'], f['uni0306.cap'])

    #--------------------------------------------------------------------------

    for letter in 'cegz':
        build_accented_glyph(letter + 'dotaccent', f[base(letter)], f['uni0307'])
    for letter in 'gz':
        build_accented_glyph(letter + 'dotaccent.001', f[base(letter) + '.001'], f['uni0307'])
    for letter in 'CEGIZ':
        build_accented_glyph(letter + 'dotaccent', f[base(letter)], f['uni0307.cap'])
    for letter in 'CEG':
        build_accented_glyph(letter + 'dotaccent.001', f[base(letter) + '.001'], f['uni0307.cap'])
    build_accented_glyph('i.TRK', f['dotlessi'], f['uni0307'])
    build_accented_glyph('j.TRK', f['uni0237'], f['uni0307'])
    build_accented_glyph('i', f['dotlessi'], f['uni0307.high'])
    build_accented_glyph('iogonek', f['iogonek.dotless'], f['uni0307.high'])
    build_accented_glyph('j', f['uni0237'], f['uni0307.high'])

    #--------------------------------------------------------------------------

    for letter in 'cenrsz':
        build_accented_glyph(letter + 'caron', f[base(letter)], f['uni030C'])
    for letter in 'z':
        build_accented_glyph(letter + 'caron.001', f[base(letter) + '.001'], f['uni030C'])
    for letter in 'CDENRTSZ':
        build_accented_glyph(letter + 'caron', f[base(letter)], f['uni030C.cap'])
    for letter in 'CDENRT':
        build_accented_glyph(letter + 'caron.001', f[base(letter) + '.001'], f['uni030C.cap'])
    for letter in 'T':
        build_accented_glyph(letter + 'caron.002', f[base(letter) + '.002'], f['uni030C.cap'])
    for letter in 'dLlt':
        build_accented_glyph(letter + 'caron', f[base(letter)], f['uni0315'])

    #--------------------------------------------------------------------------

    for letter in 'aeiou':
        build_accented_glyph(letter + 'macron', f[base(letter)], f['uni0304'])
    for letter in 'AEIOU':
        build_accented_glyph(letter + 'macron', f[base(letter)], f['uni0304.cap'])
    for letter in 'AE':
        build_accented_glyph(letter + 'macron.001', f[base(letter) + '.001'], f['uni0304.cap'])

    #--------------------------------------------------------------------------

    for letter in 'ou':
        build_accented_glyph(letter + 'hungarumlaut', f[base(letter)], f['uni030B'])
    for letter in 'OU':
        build_accented_glyph(letter + 'hungarumlaut', f[base(letter)], f['uni030B.cap'])

    #--------------------------------------------------------------------------

#    build_multigraph('quotedblleft', [f['quoteleft'], f['quoteleft']])
#    build_multigraph('quotedblright', [f['quoteright'], f['quoteright']])
#    build_multigraph('quotedblbase', [f['quotesinglbase'], f['quotesinglbase']])
#    build_multigraph('uni201F', [f['quotereversed'], f['quotereversed']])
#    build_multigraph('guillemotleft', [f['guilsinglleft'], f['guilsinglleft']])
#    build_multigraph('guillemotright', [f['guilsinglright'], f['guilsinglright']])
    build_multigraph('napostrophe', [f['quoteright'], f['n']])
    build_multigraph('IJ', [f['I'], f['J']])
    build_multigraph('ij', [f['i'], f['j']])
#    build_multigraph('Ldot', [f['L'], f['periodcentered']])
    build_multigraph('ldot', [f['l'], f['periodcentered']])

    #--------------------------------------------------------------------------

    f.selection.all()
    spacing_by_anchors.space_selected_by_anchors(f)
    f.selection.none()

    generate_kerning_and_read_features(None, f)

    #--------------------------------------------------------------------------

    font_db.db_close(f)
def build_glyphs(bitbucket, f):

    from sortsmill import cap_spacing

    figures = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]

    def base(letter):
        if letter == "i":
            base = "dotlessi"
        elif letter == "j":
            base = "uni0237"
        else:
            base = letter
        return base

    db = font_db.db_create(f)

    db["spacing_anchor_heights"] = {
        "hi": 684,  # caps and ascenders
        "x": 376,  # ex-height
        "o": 195,  # like the letter o
        "bl": 15,  # baseline
        "lo": -244,
    }  # descenders

    all_glyphs = set(f) - set([".notdef"])
    (smallcaps, capssmall, uppercase, lowercase, fraction_bar, numerators, denominators, remaining) = tuple(
        separate_strings(
            all_glyphs,
            [
                (lambda s: s[-3:] == ".sc"),
                (lambda s: s[-3:] == ".c2"),
                (lambda s: is_uppercase(s, last_name)),
                (lambda s: is_lowercase(s, last_name)),
                (lambda s: s == "fraction"),
                (lambda s: s[-6:] == ".numer"),
                (lambda s: s[-6:] == ".denom"),
            ],
        )
    )
    db["kerning_sets"] = [
        (remaining, uppercase | lowercase | smallcaps | capssmall | remaining),
        (uppercase, uppercase | lowercase | smallcaps | remaining),
        (smallcaps, uppercase | smallcaps | capssmall | remaining),
        (lowercase, uppercase | lowercase | remaining),
        (numerators, fraction_bar),
        (fraction_bar, denominators),
    ]
    db["kerning_rounding"] = "(lambda x: int(round(x/5.0)) * 5)"
    #    db['kerning_rounding'] = '(lambda x: x if abs(x) < 10 else int(round(x/5.0))*5)'

    build_several_space_glyphs(
        f, emsize=1000, spacesize=185, thinspacesize=1000 / 6, hairspacesize=1000 / 10, tabwidth=f["zero.lining"].width
    )
    propagate_hyphens(f)
    #    propagate_hyphens(f, '.uppercase')
    build_spacing_marks(f, width=2 * 195)

    make_glyph_reference("quotesingle", f["minute"])
    make_glyph_reference("quotedbl", f["second"])
    make_glyph_reference("asciitilde", f["uni2053"])  # Swung dash.
    #    make_glyph_reference('i.TRK', f['i']) <-- Handled below.
    make_glyph_reference("Dcroat", f["Eth"])
    make_glyph_reference("dcroat.sc", f["eth.sc"])
    make_glyph_reference("L.CAT", f["L"])
    make_glyph_reference("l.CAT", f["l"])
    make_glyph_reference("L.CAT.c2", f["L.c2"])
    make_glyph_reference("l.CAT.sc", f["l.sc"])

    build_multigraph("ellipsis", [f["period"], f["period"], f["period"]])

    for fig in figures + ["dollar"]:
        make_glyph_reference(fig, f[fig + ".hanging"])

    make_glyph_reference("uni00B9", f["one.sup"])
    make_glyph_reference("uni00B2", f["two.sup"])
    make_glyph_reference("uni00B3", f["three.sup"])
    for extension in [(".numer", 244), (".sub", -180), (".sup", 244)]:
        for fig in figures:
            make_glyph_reference(
                fig + extension[0],
                f[fig + ".denom"],
                transformation=(1, 0, 0, 1, 0, extension[1]),
                copy_spacing_anchors=(extension[0] == ".numer"),
            )
    build_multigraph("onequarter", [f["one.numer"], f["fraction"], f["four.denom"]])
    build_multigraph("onehalf", [f["one.numer"], f["fraction"], f["two.denom"]])
    build_multigraph("threequarters", [f["three.numer"], f["fraction"], f["four.denom"]])

    for g in f:
        if g[-3:] == ".sc" and g not in ["i.TRK.sc", "l.CAT.sc"]:
            if g == "periodcentered.sc":
                make_glyph_reference(g[:-3] + ".c2", f[g])
            elif g == "uni0163.sc":
                make_glyph_reference("uni0162.c2", f[g])
            elif g == "uni0219.sc":
                make_glyph_reference("uni0218.c2", f[g])
            elif g == "uni021B.sc":
                make_glyph_reference("uni021A.c2", f[g])
            elif g in ("ae.sc", "oe.sc", "ij.sc"):
                make_glyph_reference(g[:-3].upper() + ".c2", f[g])
            else:
                make_glyph_reference(g[:-3].capitalize() + ".c2", f[g])

    # --------------------------------------------------------------------------

    for letter in "GKkLlNnRr":
        build_accented_glyph(letter + "commaaccent", f[base(letter)], f["uni0326"])
    build_accented_glyph("gcommaaccent", f["g"], f["uni0312"])
    build_accented_glyph("uni0218", f["S"], f["uni0326"])
    build_accented_glyph("uni0219", f["s"], f["uni0326"])
    build_accented_glyph("uni021A", f["T"], f["uni0326"])
    build_accented_glyph("uni021B", f["t"], f["uni0326"])

    for letter in "gklnr":
        build_accented_glyph(letter + "commaaccent.sc", f[letter + ".sc"], f["uni0326"])
    build_accented_glyph("uni0219.sc", f["s.sc"], f["uni0326"])
    build_accented_glyph("uni021B.sc", f["t.sc"], f["uni0326"])

    # --------------------------------------------------------------------------

    for letter in "CcSs":
        build_accented_glyph(letter + "cedilla", f[base(letter)], f["uni0327"])
        remove_overlap(f[letter + "cedilla"])
    build_accented_glyph("uni0162", f["T"], f["uni0327"])
    remove_overlap(f["uni0162"])
    build_accented_glyph("uni0163", f["t"], f["uni0327"])
    remove_overlap(f["uni0163"])

    for letter in "cs":
        build_accented_glyph(letter + "cedilla.sc", f[letter + ".sc"], f["uni0327"])
        remove_overlap(f[letter + "cedilla.sc"])
    build_accented_glyph("uni0163.sc", f["t.sc"], f["uni0327"])
    remove_overlap(f["uni0163.sc"])

    # --------------------------------------------------------------------------

    for letter in "aeiou":
        build_accented_glyph(letter + "grave", f[base(letter)], f["gravecomb"])
    for letter in "AEIOU":
        build_accented_glyph(letter + "grave", f[base(letter)], f["gravecomb.cap"])
    for letter in "aeiou":
        build_accented_glyph(letter + "grave.sc", f[letter + ".sc"], f["gravecomb"])

    # --------------------------------------------------------------------------

    for letter in "aceinorsuyz":
        build_accented_glyph(letter + "acute", f[base(letter)], f["acutecomb"])
    for letter in "ACEILNORSUYZ":
        build_accented_glyph(letter + "acute", f[base(letter)], f["acutecomb.cap"])
    # build_accented_glyph('lacute', f['l'], f['acutecomb.cap']) <-- We are making this one by hand.
    for letter in "aceilnorsuyz":
        build_accented_glyph(letter + "acute.sc", f[letter + ".sc"], f["acutecomb"])

    # --------------------------------------------------------------------------

    for letter in "ainou":
        build_accented_glyph(letter + "tilde", f[base(letter)], f["tildecomb"])
    for letter in "AINOU":
        build_accented_glyph(letter + "tilde", f[base(letter)], f["tildecomb.cap"])
    for letter in "ainou":
        build_accented_glyph(letter + "tilde.sc", f[letter + ".sc"], f["tildecomb"])

    # --------------------------------------------------------------------------

    for letter in "aeouy":
        build_accented_glyph(letter + "dieresis", f[base(letter)], f["uni0308"])
    for letter in "AEIOUY":
        build_accented_glyph(letter + "dieresis", f[base(letter)], f["uni0308.cap"])
    for letter in "aeiouy":
        build_accented_glyph(letter + "dieresis.sc", f[letter + ".sc"], f["uni0308"])
    for letter in "i":
        build_accented_glyph(letter + "dieresis", f[base(letter)], f["uni0308.narrow"])

    # --------------------------------------------------------------------------

    for letter in "au":
        build_accented_glyph(letter + "ring", f[base(letter)], f["uni030A"])
    for letter in "AU":
        build_accented_glyph(letter + "ring", f[base(letter)], f["uni030A.cap"])
    for letter in "au":
        build_accented_glyph(letter + "ring.sc", f[letter + ".sc"], f["uni030A"])

    # --------------------------------------------------------------------------

    for letter in "acegijosuwy":
        build_accented_glyph(letter + "circumflex", f[base(letter)], f["uni0302"])
    for letter in "hACEGHIJOSUWY":
        build_accented_glyph(letter + "circumflex", f[base(letter)], f["uni0302.cap"])
    for letter in ["f_h", "f_f_h"]:
        build_accented_glyph(letter + "circumflex", f[base(letter)], f["uni0302.cap"])
    for letter in "aceghijosuwy":
        build_accented_glyph(letter + "circumflex.sc", f[letter + ".sc"], f["uni0302"])

    # --------------------------------------------------------------------------

    for letter in "aegiou":
        build_accented_glyph(letter + "breve", f[base(letter)], f["uni0306"])
    for letter in "AEGIOU":
        build_accented_glyph(letter + "breve", f[base(letter)], f["uni0306.cap"])
    for letter in "aegiou":
        build_accented_glyph(letter + "breve.sc", f[letter + ".sc"], f["uni0306"])

    # --------------------------------------------------------------------------

    for letter in "cegz":
        build_accented_glyph(letter + "dotaccent", f[base(letter)], f["uni0307"])
    for letter in "CEGIZ":
        build_accented_glyph(letter + "dotaccent", f[base(letter)], f["uni0307.cap"])
    for letter in "cegz":
        build_accented_glyph(letter + "dotaccent.sc", f[letter + ".sc"], f["uni0307"])
    build_accented_glyph("i.TRK", f["dotlessi"], f["uni0307"])
    build_accented_glyph("i.TRK.sc", f["i.sc"], f["uni0307"])
    build_accented_glyph("j.TRK", f["uni0237"], f["uni0307"])
    build_accented_glyph("i", f["dotlessi"], f["uni0307.high"])
    build_accented_glyph("iogonek", f["iogonek.dotless"], f["uni0307.high"])
    build_accented_glyph("j", f["uni0237"], f["uni0307.high"])

    # --------------------------------------------------------------------------

    for letter in "cenrsz":
        build_accented_glyph(letter + "caron", f[base(letter)], f["uni030C"])
    for letter in "CDENRTSZ":
        build_accented_glyph(letter + "caron", f[base(letter)], f["uni030C.cap"])
    for letter in "dLlt":
        build_accented_glyph(letter + "caron", f[base(letter)], f["uni0315"])

    for letter in "cdenrstz":
        build_accented_glyph(letter + "caron.sc", f[letter + ".sc"], f["uni030C"])
    build_accented_glyph("lcaron.sc", f["l.sc"], f["uni0315"])

    # --------------------------------------------------------------------------

    for letter in "aeiou":
        build_accented_glyph(letter + "macron", f[base(letter)], f["uni0304"])
    for letter in "AEIOU":
        build_accented_glyph(letter + "macron", f[base(letter)], f["uni0304.cap"])
    for letter in "aeiou":
        build_accented_glyph(letter + "macron.sc", f[letter + ".sc"], f["uni0304"])

    # --------------------------------------------------------------------------

    for letter in "ou":
        build_accented_glyph(letter + "hungarumlaut", f[base(letter)], f["uni030B"])
    for letter in "OU":
        build_accented_glyph(letter + "hungarumlaut", f[base(letter)], f["uni030B.cap"])
    for letter in "ou":
        build_accented_glyph(letter + "hungarumlaut.sc", f[letter + ".sc"], f["uni030B"])

    # --------------------------------------------------------------------------

    build_multigraph("napostrophe", [f["quoteright"], f["n"]])
    build_multigraph("IJ", [f["I"], f["J"]])
    build_multigraph("ij", [f["i"], f["j"]])
    build_multigraph("ij.sc", [f["i.sc"], f["j.sc"]])
    #    build_multigraph('Ldot', [f['L'], f['periodcentered']]) # Done by hand.
    build_multigraph("ldot", [f["l"], f["periodcentered"]])
    #    build_multigraph('ldot.sc', [f['l.sc'], f['periodcentered.sc']]) # Done by hand.

    # --------------------------------------------------------------------------

    f.selection.all()
    space_selected_by_anchors(f)
    f.selection.none()

    generate_kerning_and_read_features(None, f)

    # --------------------------------------------------------------------------

    font_db.db_close(f)
def build_glyphs(bitbucket, f):

    from sortsmill import cap_spacing

    figures = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']

    def base(letter):
        if letter == 'i':
            base = 'dotlessi'
        elif letter == 'j':
            base = 'uni0237'
        else:
            base = letter
        return base    

    db = font_db.db_create(f)

    db['spacing_anchor_heights'] = {
        'hi' : 675,             # caps and ascenders,
        'x'  : 389,             # ex-height
        'o'  : 215,             # like the letter o
        'bl' : 10,              # baseline
        'lo' : -204,            # descenders
        }

    all_glyphs = set(f) - set(['.notdef'])
    (smallcaps, capssmall, uppercase, lowercase, fraction_bar, numerators, denominators, remaining) = \
        tuple(separate_strings(all_glyphs, [
                (lambda s: s[-3:] == '.sc'),
                (lambda s: s[-3:] == '.c2'),
                (lambda s: is_uppercase(s, last_name)),
                (lambda s: is_lowercase(s, last_name)),
                (lambda s: s == 'fraction'),
                (lambda s: s[-6:] == '.numer'),
                (lambda s: s[-6:] == '.denom'),
                ]))

    db["kerning_sets"] = [
        (remaining, uppercase | lowercase | smallcaps | capssmall | remaining),
        (uppercase, uppercase | lowercase | smallcaps | remaining),
        (smallcaps, uppercase | smallcaps | capssmall | remaining),
        (capssmall, smallcaps | capssmall | remaining),
        (lowercase, uppercase | lowercase | remaining),
        (numerators, fraction_bar),
        (fraction_bar, denominators),
        ]

    build_several_space_glyphs(f, emsize = emsize, spacesize = spacesize,
                               thinspacesize = emsize / 6,
                               hairspacesize = emsize / 10,
                               tabwidth = f['zero'].width)

    propagate_hyphens(f)
    propagate_hyphens(f, '.u')
    build_spacing_marks(f, width = 2 * 220)

    make_glyph_reference('asciitilde', f['uni2053']) # Swung dash.
    make_glyph_reference('i.TRK', f['i'])
    make_glyph_reference('L.CAT', f['L'])
    make_glyph_reference('l.CAT', f['l'])
    make_glyph_reference('L.CAT.c2', f['L.c2'])
    make_glyph_reference('l.CAT.sc', f['l.sc'])
    make_glyph_reference('Dcroat', f['Eth'])
    make_glyph_reference('dcroat.sc', f['eth.sc'])

    build_multigraph('ellipsis', [f['period'], f['period'], f['period']])

    make_glyph_reference('quotesingle', f['minute'])
    make_glyph_reference('quotedbl', f['second'])

    for extension in [('.numer', 250), ('.sub', -150), ('.sup', 350)]:
        for fig in figures + ['comma', 'period',
                              'parenleft', 'parenright',
                              'bracketleft', 'bracketright',
#                              'hyphen',
#                              'dollar', 'cent',
                              ] + [string.ascii_lowercase[i] for i in range(0, 26)]:
            make_glyph_reference(fig + extension[0],
                                 f[fig + '.denom'],
                                 transformation = (1, 0, 0, 1, 0, extension[1]),
                                 copy_spacing_anchors = (extension[0] == '.numer'))

    make_glyph_reference('uni00B9', f['one.sup'])
    make_glyph_reference('uni00B2', f['two.sup'])
    make_glyph_reference('uni00B3', f['three.sup'])
    make_glyph_reference('ordfeminine', f['a.sup'])
    make_glyph_reference('ordmasculine', f['o.sup'])
    build_multigraph('onequarter', [f['one.numer'], f['fraction'], f['four.denom']], copy_spacing_anchors = False)
    build_multigraph('onehalf', [f['one.numer'], f['fraction'], f['two.denom']], copy_spacing_anchors = False)
    build_multigraph('threequarters', [f['three.numer'], f['fraction'], f['four.denom']], copy_spacing_anchors = False)

    special_cases = {
        'uni0163.sc' : 'uni0162.c2',
        'uni0219.sc' : 'uni0218.c2',
        'uni021B.sc' : 'uni021A.c2',
        'uni1E03.sc' : 'uni1E02.c2',
        'uni1E0B.sc' : 'uni1E0A.c2',
        'uni1E1F.sc' : 'uni1E1E.c2',
        'uni1E23.sc' : 'uni1E22.c2',
        'uni1E41.sc' : 'uni1E40.c2',
        'uni1E57.sc' : 'uni1E56.c2',
        'uni1E61.sc' : 'uni1E60.c2',
        'uni1E6B.sc' : 'uni1E6A.c2',
        }

    for g in f:
        if g[-3:] == '.sc' and g not in ['i.TRK.sc', 'l.CAT.sc', 'germandbls.sc']:
            if g in special_cases:
                make_glyph_reference(special_cases[g], f[g])
            elif g in ('ampersand.sc', 'periodcentered.sc'):
                make_glyph_reference(g[:-3] + '.c2', f[g])
            elif g == 'uni0163.sc':
                make_glyph_reference('uni0162.c2', f[g])
            elif g == 'uni0219.sc':
                make_glyph_reference('uni0218.c2', f[g])
            elif g == 'uni021B.sc':
                make_glyph_reference('uni021A.c2', f[g])
            elif g in ('ae.sc', 'oe.sc', 'ij.sc'):
                make_glyph_reference(g[:-3].upper() + '.c2', f[g])
            else:
                make_glyph_reference(g[:-3].capitalize() + '.c2', f[g])

    #--------------------------------------------------------------------------

    for letter in 'GKkLlNnRr':
        build_accented_glyph(letter + 'commaaccent', f[base(letter)], f['uni0326'])
    build_accented_glyph('uni0218', f['S'], f['uni0326'])
    build_accented_glyph('uni0219', f['s'], f['uni0326'])
    build_accented_glyph('uni021A', f['T'], f['uni0326'])
    build_accented_glyph('uni021B', f['t'], f['uni0326'])
    build_accented_glyph('gcommaaccent', f['g'], f['uni0312'])

    for letter in 'gklnr':
        build_accented_glyph(letter + 'commaaccent.sc', f[letter + '.sc'], f['uni0326'])
    build_accented_glyph('uni0219.sc', f['s.sc'], f['uni0326'])
    build_accented_glyph('uni021B.sc', f['t.sc'], f['uni0326'])

    #--------------------------------------------------------------------------

    for letter in 'CcSs':
        build_accented_glyph(letter + 'cedilla', f[base(letter)], f['uni0327'])
        remove_overlap(f[letter + 'cedilla'])
    build_accented_glyph('uni0162', f['T'], f['uni0327'])
    remove_overlap(f['uni0162'])
#    build_accented_glyph('uni0163', f['t'], f['uni0327']) <-- Manually hinted, so don't rebuild.
#    remove_overlap(f['uni0163'])

    for letter in 'cs':
        build_accented_glyph(letter + 'cedilla.sc', f[letter + '.sc'], f['uni0327'])
        remove_overlap(f[letter + 'cedilla.sc'])
    build_accented_glyph('uni0163.sc', f['t.sc'], f['uni0327'])
    remove_overlap(f['uni0163.sc'])

    #--------------------------------------------------------------------------

    for letter in 'aeiou':
        build_accented_glyph(letter + 'grave', f[base(letter)], f['gravecomb'])
    for letter in 'AEIOU':
        build_accented_glyph(letter + 'grave', f[base(letter)], f['gravecomb.cap'])
    for letter in 'aeiou':
        build_accented_glyph(letter + 'grave.sc', f[letter + '.sc'], f['gravecomb'])

    #--------------------------------------------------------------------------

    for letter in 'aceinorsuyz':
        build_accented_glyph(letter + 'acute', f[base(letter)], f['acutecomb'])
    for letter in 'ACEILNORSUYZ':
        build_accented_glyph(letter + 'acute', f[base(letter)], f['acutecomb.cap'])
    build_accented_glyph('lacute', f['l'], f['acutecomb.cap'])
    for letter in 'aceilnorsuyz':
        build_accented_glyph(letter + 'acute.sc', f[letter + '.sc'], f['acutecomb'])

    #--------------------------------------------------------------------------

    for letter in 'ainou':
        build_accented_glyph(letter + 'tilde', f[base(letter)], f['tildecomb'])
    for letter in 'AINOU':
        build_accented_glyph(letter + 'tilde', f[base(letter)], f['tildecomb.cap'])
    for letter in 'ainou':
        build_accented_glyph(letter + 'tilde.sc', f[letter + '.sc'], f['tildecomb'])

    #--------------------------------------------------------------------------

    for letter in 'aeouy':
        build_accented_glyph(letter + 'dieresis', f[base(letter)], f['uni0308'])
    for letter in 'AEIOUY':
        build_accented_glyph(letter + 'dieresis', f[base(letter)], f['uni0308.cap'])
    for letter in 'i':
        build_accented_glyph(letter + 'dieresis', f[base(letter)], f['uni0308.narrow'])
    for letter in 'aeiouy':
        build_accented_glyph(letter + 'dieresis.sc', f[letter + '.sc'], f['uni0308'])

    #--------------------------------------------------------------------------

    for letter in 'au':
        build_accented_glyph(letter + 'ring', f[base(letter)], f['uni030A'])
    for letter in 'AU':
        build_accented_glyph(letter + 'ring', f[base(letter)], f['uni030A.cap'])
    for letter in 'au':
        build_accented_glyph(letter + 'ring.sc', f[letter + '.sc'], f['uni030A'])

    #--------------------------------------------------------------------------

    for letter in 'acegijosuwy':
        build_accented_glyph(letter + 'circumflex', f[base(letter)], f['uni0302'])
    for letter in 'ACEGHIJOSUWY':
        build_accented_glyph(letter + 'circumflex', f[base(letter)], f['uni0302.cap'])
    for letter in 'h':
        build_accented_glyph(letter + 'circumflex', f[base(letter)], f['uni0302.ascend'])
    for letter in ['f_h', 'f_f_h']:
        build_accented_glyph(letter + 'circumflex', f[base(letter)], f['uni0302.cap'])
    for letter in 'aceghijosuwy':
        build_accented_glyph(letter + 'circumflex.sc', f[letter + '.sc'], f['uni0302'])

    #--------------------------------------------------------------------------

    for letter in 'aegiou':
        build_accented_glyph(letter + 'breve', f[base(letter)], f['uni0306'])
    for letter in 'AEGIOU':
        build_accented_glyph(letter + 'breve', f[base(letter)], f['uni0306.cap'])
    for letter in 'aegiou':
        build_accented_glyph(letter + 'breve.sc', f[letter + '.sc'], f['uni0306'])

    #--------------------------------------------------------------------------

    for letter in 'cegz':
        build_accented_glyph(letter + 'dotaccent', f[base(letter)], f['uni0307'])
    for letter in 'CEGIZ':
        build_accented_glyph(letter + 'dotaccent', f[base(letter)], f['uni0307.cap'])
    for letter in 'cegz':
        build_accented_glyph(letter + 'dotaccent.sc', f[letter + '.sc'], f['uni0307'])
    build_accented_glyph('i.TRK.sc', f['i.sc'], f['uni0307'])

    # Extra dot accents for Old Irish.
    build_accented_glyph('uni1E02', f['B'], f['uni0307.cap'])
    build_accented_glyph('uni1E03', f['b'], f['uni0307.cap'])
    build_accented_glyph('uni1E0A', f['D'], f['uni0307.cap'])
    build_accented_glyph('uni1E0B', f['d'], f['uni0307.cap'])
    build_accented_glyph('uni1E1E', f['F'], f['uni0307.cap'])
    build_accented_glyph('uni1E1F', f['f'], f['uni0307.cap'])
    build_accented_glyph('uni1E22', f['H'], f['uni0307.cap'])
    build_accented_glyph('uni1E23', f['h'], f['uni0307.cap'])
    build_accented_glyph('uni1E40', f['M'], f['uni0307.cap'])
    build_accented_glyph('uni1E41', f['m'], f['uni0307'])
    build_accented_glyph('uni1E56', f['P'], f['uni0307.cap'])
    build_accented_glyph('uni1E57', f['p'], f['uni0307'])
    build_accented_glyph('uni1E60', f['S'], f['uni0307.cap'])
    build_accented_glyph('uni1E61', f['s'], f['uni0307'])
    build_accented_glyph('uni1E6A', f['T'], f['uni0307.cap'])
    build_accented_glyph('uni1E6B', f['t'], f['uni0307'])

    # Extra small caps for Old Irish.
    build_accented_glyph('uni1E03.sc', f['b.sc'], f['uni0307'])
    build_accented_glyph('uni1E0B.sc', f['d.sc'], f['uni0307'])
    build_accented_glyph('uni1E1F.sc', f['f.sc'], f['uni0307'])
    build_accented_glyph('uni1E23.sc', f['h.sc'], f['uni0307'])
    build_accented_glyph('uni1E41.sc', f['m.sc'], f['uni0307'])
    build_accented_glyph('uni1E57.sc', f['p.sc'], f['uni0307'])
    build_accented_glyph('uni1E61.sc', f['s.sc'], f['uni0307'])
    build_accented_glyph('uni1E6B.sc', f['t.sc'], f['uni0307'])

    #--------------------------------------------------------------------------

    for letter in 'cenrsz':
        build_accented_glyph(letter + 'caron', f[base(letter)], f['uni030C'])
    for letter in 'CDENRTSZ':
        build_accented_glyph(letter + 'caron', f[base(letter)], f['uni030C.cap'])
    for letter in 'dLlt':
        build_accented_glyph(letter + 'caron', f[base(letter)], f['uni0315'])

    for letter in 'cdenrstz':
        build_accented_glyph(letter + 'caron.sc', f[letter + '.sc'], f['uni030C'])
    build_accented_glyph('lcaron.sc', f['l.sc'], f['uni0315'])

    #--------------------------------------------------------------------------

    for letter in 'aeiou':
        build_accented_glyph(letter + 'macron', f[base(letter)], f['uni0304'])
    for letter in 'AEIOU':
        build_accented_glyph(letter + 'macron', f[base(letter)], f['uni0304.cap'])
    for letter in 'aeiou':
        build_accented_glyph(letter + 'macron.sc', f[letter + '.sc'], f['uni0304'])

    #--------------------------------------------------------------------------

    for letter in 'ou':
        build_accented_glyph(letter + 'hungarumlaut', f[base(letter)], f['uni030B'])
    for letter in 'OU':
        build_accented_glyph(letter + 'hungarumlaut', f[base(letter)], f['uni030B.cap'])
    for letter in 'ou':
        build_accented_glyph(letter + 'hungarumlaut.sc', f[letter + '.sc'], f['uni030B'])

    #--------------------------------------------------------------------------

    build_multigraph('Q_U', [f['Q.001'], f['U']])
    build_multigraph('Q_u', [f['Q.002'], f['u']])

    build_multigraph('napostrophe', [f['quoteright'], f['n']])
    build_multigraph('napostrophe.sc', [f['quoteright'], f['n.sc']])

    build_multigraph('IJ', [f['I'], f['J']])
    build_multigraph('ij', [f['i'], f['j']])
    build_multigraph('ij.sc', [f['i.sc'], f['j.sc']])

    build_multigraph('germandbls.sc', [f['s.sc'], f['s.sc']])

    for g in ['parenleft', 'parenright',
              'bracketleft', 'bracketright',
              'braceleft', 'braceright',
              ]:
        make_glyph_reference(g + '.u', f[g],
                             transformation = (1, 0, 0, 1, 0, 70),
                             copy_spacing_anchors = False)

    for g in ['figuredash']:
        make_glyph_reference(g + '.u', f[g],
                             transformation = (1, 0, 0, 1, 0, 70),
                             copy_spacing_anchors = False)

    #--------------------------------------------------------------------------

    f.selection.all()
    space_selected_by_anchors(f)
    f.selection.none()

    generate_kerning_and_read_features(None, f)

    #--------------------------------------------------------------------------

    font_db.db_close(f)