Skip to content

kivy-garden/garden.iconfonts

Repository files navigation

Screenshot

Kivy-iconfonts

Simple helper functions to make easier to use icon fonts in Labels and derived widgets

Usage

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 kivy.garden.iconfonts.icon
    Button:
        markup: True # Always turn markup on
        text: "%s"%(icon('icon-comment'))

See init.py for another example.

Generating a fontd file

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

  1. Download Font-Awesome (http://fortawesome.github.io/Font-Awesome/)
  2. Copy both the TTF and CSS files (fonts/fontawesome-webfont.ttf and css/font-awesome.css) to your project
  3. Create and execute a python script to generate your fontd file:
iconfonts.create_fontdict_file('font-awesome.css', 'font-awesome.fontd')
  1. If everything went well your font dictionary file exists. You can delete the css file (font-awesome.css)

More IconFonts

LICENSE

MIT (except sample font that I got from http://fontello.com)

Credits

Author: Jeyson Molina jeyson.mco@gmail.com

About

Simple helper functions to make easier to use icon fonts in Labels and derived widgets

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •