Exemplo n.º 1
0
def print_c_form(table):
    count = 0
    for slot, type, upright, code in table:
        count += 1
    print 'static const unsigned long nglyph = %d;' % count
    print 'static const char *glyph_control_sequence[nglyph] = {'
    for slot, type, upright, code in table:
        print '    "' + maputil.escape_c_form(code) + '",'
    print '};'
    print
    print 'static const unsigned int glyph_type[nglyph] = {'
    for slot, type, upright, code in table:
        if type == 'Alpha':
            type = 'Ord'
        if type != '-':
            print '    atom_t::TYPE_' + type.upper() + ','
        else:
            print '    atom_t::TYPE_ORD,'
    print '};'
    print
    print 'static const bool glyph_upright[nglyph] = {'
    for slot, type, upright, code in table:
        if type != '-':
            if upright != '0':
                print '    true,'
            else:
                print '    false,'
        else:
            print '    true,'
    print '};'
    print
    print 'static const wchar_t glyph_code_point[nglyph] = {'
    for slot, type, upright, code in table:
        print '    ' + maputil.ucs_c_form(slot) + ','
    print '};'
Exemplo n.º 2
0
def print_c_form(table):
    count = 0
    for slot, type, upright, code in table:
        count += 1
    print 'static const unsigned long nglyph = %d;' % count
    print 'static const char *glyph_control_sequence[nglyph] = {'
    for slot, type, upright, code in table:
        print '    "' + maputil.escape_c_form(code) + '",'
    print '};'
    print
    print 'static const unsigned int glyph_type[nglyph] = {'
    for slot, type, upright, code in table:
        if type == 'Alpha':
            type = 'Ord'
        if type != '-':
            print '    atom_t::TYPE_' + type.upper() + ','
        else:
            print '    atom_t::TYPE_ORD,'
    print '};'
    print
    print 'static const bool glyph_upright[nglyph] = {'
    for slot, type, upright, code in table:
        if type != '-':
            if upright != '0':
                print '    true,'
            else:
                print '    false,'
        else:
            print '    true,'
    print '};'
    print
    print 'static const wchar_t glyph_code_point[nglyph] = {'
    for slot, type, upright, code in table:
        print '    ' + maputil.ucs_c_form(slot) + ','
    print '};'
Exemplo n.º 3
0
def format_math_alpha(name, code):
    int_code = int(code, 16)
    if int_code < 65536:
        line = 'case \'%s\': _glyph = %s; break;' % \
               (maputil.escape_c_form(name),
                maputil.ucs_c_form(code))
    elif name.isupper():
        line = '_glyph = %s + (_code[0] - \'A\');' % \
               maputil.ucs_c_form(int_code -
                                  (ord(name[0]) - ord('A')))
    elif name.islower():
        line = '_glyph = %s + (_code[0] - \'a\');' % \
               maputil.ucs_c_form(int_code -
                                  (ord(name[0]) - ord('a')))
    elif name.isdigit():
        line = '_glyph = %s + (_code[0] - \'0\');' % \
               maputil.ucs_c_form(int_code -
                                  (ord(name[0]) - ord('0')))
    else:
        line = '(unhandled Unicode glyph %s)' % code
    return line