(hex_resources, height, all_needed)
return fontdict
Load a set of overlaying unifont .hex files.
Load a set of overlaying unifont .hex files.
Load a set of overlaying unifont . hex files .
def load_hex(hex_resources, height, all_needed):
    """Load a set of overlaying unifont .hex files."""
    fontdict = {}
    # get elements of codepoint sequences in case we need to combine glyphs
    elements = set.union(*(set(unicodedata.normalize('NFD', _c)) for _c in all_needed))
    all_needed = set(all_needed).union(elements)
    # transform the (smaller) set of needed chars into sequences for comparison
    # rather than the (larger) set of available sequences into chars
    needed_sequences = set(b','.join(b'%04X' % ord(_c) for _c in _s) for _s in all_needed)
    missing = set(all_needed)
    for hexres in reversed(hex_resources):
        if hexres is None:
            continue
        missing = _get_glyphs_from_hex(height, hexres, fontdict, missing, needed_sequences)
    missing = _combine_glyphs(height, fontdict, missing)
    # fill missing with nulls
    fontdict.update({_u: b'\0' * height for _u in missing})
    # char 0 should always be defined and empty
    fontdict[u'\0'] = b'\0' * height
    missing -= {u'\0'}
    # warn if we miss needed glyphs
    _warn_missing(height, missing)
    return fontdict
def load_hex ( hex_resources , height , all_needed ) : fontdict = { } # get elements of codepoint sequences in case we need to combine glyphs elements = set . union ( * ( set ( unicodedata . normalize ( 'NFD' , _c ) ) for _c in all_needed ) ) all_needed = set ( all_needed ) . union ( elements ) # transform the (smaller) set of needed chars into sequences for comparison # rather than the (larger) set of available sequences into chars needed_sequences = set ( b',' . join ( b'%04X' % ord ( _c ) for _c in _s ) for _s in all_needed ) missing = set ( all_needed ) for hexres in reversed ( hex_resources ) : if hexres is None : continue missing = _get_glyphs_from_hex ( height , hexres , fontdict , missing , needed_sequences ) missing = _combine_glyphs ( height , fontdict , missing ) # fill missing with nulls fontdict . update ( { _u : b'\0' * height for _u in missing } ) # char 0 should always be defined and empty fontdict [ u'\0' ] = b'\0' * height missing -= { u'\0' } # warn if we miss needed glyphs _warn_missing ( height , missing ) return fontdict