Using icon fonts (webfonts)?

691 views
Skip to first unread message

Oon-Ee Ng

unread,
Jan 28, 2016, 5:07:18 PM1/28/16
to kivy-...@googlegroups.com
I'd like to use https://design.google.com/icons/ (Google's material
design icons) in Kivy, but haven't been able to figure out how to
actually get them to show.

https://github.com/google/material-design-icons/tree/master/iconfont
has the font files itself, including the ttf Kivy needs. Opening that
ttf in fontforge shows nothing, but based on what I read in this link
- http://www.axure.com/c/forum/tips-tricks-examples/15335-googles-material-design-icon-font-widget-library-v7-icon-fonts.html
- that's because of the way google has designed those fonts.

So I do a standard Button, set font_name, and then start trying
various values for text, but I can never get anything to show. Shown
below is my attempt at getting the 3D rotation icon (
https://design.google.com/icons/#ic_3d_rotation )

Button:
font_name: 'MaterialIcons-Regular.ttf'
text: u'\xE84D'

Any advise?

Oon-Ee Ng

unread,
Jan 28, 2016, 6:18:46 PM1/28/16
to kivy-...@googlegroups.com
Also, based on further reading all the characters I want to use are in
the Private Use Area, not sure if that's relevant.

Brent Picasso

unread,
Jan 28, 2016, 6:39:04 PM1/28/16
to Kivy users support
Hi,

Try specifying your unicode character this way:
 text: u'\uf013'
Also, make sure you are referencing the font file relative to your project root as well.

We're using the fontawesome fonts in a similar way, so it should definitely work.

-Brent

Oon-Ee Ng

unread,
Jan 28, 2016, 9:22:23 PM1/28/16
to kivy-...@googlegroups.com
You're a champ, sir. What's the 'u' at the start of the string mean
anyway (not the u before the apostrophe, that's to indicate unicode
strings since I'm in python2)?

To be clear, here's what works:-
Button:
font_name: 'MaterialIcons-Regular.ttf'
text: u'\uE84D'
> --
> You received this message because you are subscribed to the Google Groups
> "Kivy users support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to kivy-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Brent Picasso

unread,
Jan 28, 2016, 10:35:14 PM1/28/16
to kivy-...@googlegroups.com

It's the special incantation needed to specify a unicode char, I believe.  Glad you got it working!

Brent Picasso
Autosport Labs
Technology for Race and Street

You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/f6TeHi8bGf8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.

Oon-Ee Ng

unread,
Jan 28, 2016, 10:47:53 PM1/28/16
to kivy-...@googlegroups.com
Right... magic, in other words. Thanks again.
Reply all
Reply to author
Forward
0 new messages