Roboto Font

180 views
Skip to first unread message

Leandro Davila

unread,
Mar 6, 2018, 4:11:05 PM3/6/18
to Kivy users support
How to use Roboto font in Kivy ? I have downloaded the .ttf files in Google fonts, but I don't know how ( and where ) to install it. 
thanks 

ZenCODE

unread,
Mar 6, 2018, 5:21:58 PM3/6/18
to Kivy users support
You don't need to install it. Place in a subfolder and use the LabelBase,register function to register it in kivy.

https://kivy.org/docs/api-kivy.core.text.html?highlight=labelbase#kivy.core.text.LabelBase.register

ps. In kivy 1.10.0, Roboto is the default?

Leandro Davila

unread,
Mar 6, 2018, 5:40:02 PM3/6/18
to Kivy users support
It seems the default is DroidSans .

Leandro Davila

unread,
Mar 6, 2018, 5:48:11 PM3/6/18
to Kivy users support
You need to place it in a Kivy subfolder ? 


Em terça-feira, 6 de março de 2018 19:21:58 UTC-3, ZenCODE escreveu:

Leandro Davila

unread,
Mar 6, 2018, 6:32:30 PM3/6/18
to Kivy users support
This is the code I'm using : 

#File : main.py 

import kivy 
from kivy.app import App 
from kivy.uix.label import Label 
from kivy.core.text import LabelBase
from kivy.core.window import Window 
from kivy.utils import get_color_from_hex


Window.clearcolor = get_color_from_hex('#101216')


class ClockApp(App): 
pass 

if __name__ == '__main__':

ClockApp().run() 


###The kivy file : 

#File : clockapp.kv 
#:kivy 1.10.0

BoxLayout:
orientation: 'vertical'
Label:
font_name: 'Roboto'
text:'[b]00[/b]:00:00'
markup : True
font_size: 70

ZenCODE

unread,
Mar 7, 2018, 12:01:54 AM3/7/18
to kivy-...@googlegroups.com
It does not HAVE to be in a subfolder, just somewhere accessible. So,

from kivy.core.text import LabelBase
LabelBase
.register('Roboto',
                   
'fonts/Roboto.ttf',
                   
'fonts/RobotoOblique.ttf',
                   
'fonts/RobotoBold.ttf',
                   
'fonts/FreeSansBoldOblique.ttf')

Would allow your code above to work if the above listed fonts are in the paths specified i.e. a "fonts" subfolder.
Reply all
Reply to author
Forward
0 new messages