juliettef / IconFontCppHeaders

C and C++ headers, C# and Python classes, Rust files and Go package for icon fonts Font Awesome, Fork Awesome, Google Material Design icons and symbols, Pictogrammers Material Design icons, Kenney game icons, Fontaudio, Codicons and Lucide.
zlib License
1.21k stars 146 forks source link

Simple fix for Material Design - GenerateIconFontCppHeaders.py #20

Closed Aincvy closed 2 years ago

Aincvy commented 2 years ago
class FontMD( Font ):               # Material Design
    font_name = 'Material Design'
    font_abbr = 'MD'
    # font_data = 'https://raw.githubusercontent.com/google/material-design-icons/master/iconfont/codepoints'
    # https://github.com/google/material-design-icons/blob/master/iconfont/MaterialIcons-Regular.ttf
    font_data = 'https://raw.githubusercontent.com/google/material-design-icons/master/font/MaterialIcons-Regular.codepoints'
    ttfs = [[ font_abbr, 'MaterialIcons-Regular.ttf', 'https://github.com/google/material-design-icons/blob/master/font/MaterialIcons-Regular.ttf' ]]

    @classmethod
    def get_icons( cls, input_data ):
        icons_data = {}
        lines = str.split( input_data, '\n' )
        if lines:
            font_min = 'ffff'
            font_max = '0'
            number_limit = int('ffff', 16)
            icons = []
            for line in lines :
                words = str.split(line)
                if words and len( words ) >= 2:
                    word_int = int(words[1], 16)
                    if word_int > number_limit:
                        print(words, 'Jump')
                        continue
                    if words[ 1 ] < font_min:
                        font_min = words[ 1 ]
                    if words[ 1 ] >= font_max:
                        font_max = words[ 1 ]
                    icons.append( words )
            icons_data.update({ 'font_min' : font_min,
                                'font_max' : font_max,
                                'icons' : icons })
            print(font_min, font_max)
        return icons_data

The number_limit is for goat 10fffd. goat 10fffd is a invalid data, no this icon.

Tested in Python 3.9.9, macOS.

juliettef commented 2 years ago

Thanks for this, I'll take a look.