Simple helper functions to make easier to use icon fonts in Labels and derived widgets
Once you have a .fontd file (see below) for your ttf iconfont generated you can use it like this:
In your main.py register your font:
iconfonts.register('default_font', 'iconfont_sample.ttf', 'iconfont_sample.fontd')
In your kv file or string:
#: import icon garden.iconfonts.icon
Button:
markup: True # Always turn markup on
text: "%s"%(icon('icon-comment'))
See init.py for another example.
A .fontd file is just a python dictionary filled with icon_code: unicode_value entries. This information is extracted from a css file (all iconfonts packages I've seen have one).
Example with Font-Awesome
- Download Font-Awesome (http://fortawesome.github.io/Font-Awesome/)
- Copy both the TTF and CSS files (fonts/fontawesome-webfont.ttf and css/font-awesome.css) to your project
- Create and execute a python script to generate your fontd file:
inconfonts.create_fontdict_file('font-awesome.css', 'font-awesome.fontd')
- If everything went well your font dictionary file exists. You can delete the css file (font-awesome.css)
MIT (except sample font that I got from http://fontello.com)
Author: Jeyson Molina [email protected]