So if there were only three characters on the label then the font size would be very large, however as you add more character the size would decrease.
I don't think there is a built-in feature for this one but I've came up with this. Hope it can help you somehow.
.kv file
<MyLayout>:
label_id: label_id
BoxLayout:
orientation:"horizontal"
size: root.width, root.height
TextInput:
text: "hello"
size_hint: 0.1, 0.1
on_text: root.update_label(self.text)
Label:
id: label_id
size_hint: 0.1, 0.1
text: "hello"
font_size: 16 if self.text == '' else min(48,max(10/len(self.text) * 16, 16))
.py file
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.lang import Builder
from kivy.uix.label import Label
Builder.load_file("a.kv")
class MyLayout(Widget, App):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def update_label(self, text):
self.ids['label_id'].text = text
class UiApp(App):
def build(self):
return MyLayout()
UiApp().run()
I've made a textinput just so you can play around with the given text inputs and font sizes. So when you put some text in the TextInput, it will pass it through to the Label. When the label updates its text, the font_size will get recalculated.
The reason I used the min() and max() functions is:
The main "formula" for the font_size calculation I used is:
10/len(self.text) * 16
The bigger your text, the smaller the font_size.. Play around with the numbers to get the perfect font_size for your case.