MDRectangleFlatButton:
font_size: sp(0.5*self.height)
on_text:
print(self.font_size)


The labels look fine (“Enter Word”, “Category”). How are they being specified?
You are doing a multiplying calculating ½ the height, this is going to scale with the widget size, so you don’t need the metrics.
Note there is a difference between the font_size and the texture_size.
If you want to set the font_size by the height try converting the pixel height to point size.
font_size: self.height/pt(1)
Here is a small experiment.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.button import Button
kv = """
BoxLayout:
orientation: 'vertical'
Button:
size_hint_y: .7
text: 'size_hint_y: .7'
font_size: self.height/pt(1)
Button:
size_hint_y: 2
text: 'size_hint_y: 2'
font_size: self.height/pt(1)
Button:
text: 'Yet another string'
font_size: self.height/pt(1)
Button:
text: 'set height by font_size'
size_hint_y: None
font_size: sp(50)
height: pt(self.font_size)
Button:
text: 'set font_size by height'
font_size: self.height/pt(1)
"""
class ScaleFontApp(App):
def build(self):
return Builder.load_string(kv)
ScaleFontApp().run()

How it looks on phone:

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/8aab19cb-09d0-447f-b91f-529ab9149683o%40googlegroups.com.
There might be an issue with KivyMD, I have not used kivyMD.
On a Windows PC the density is 1 so there is generally no adjustment when using dp() or sp(). On your phone the density is over 2.6.
height is expressed in pixels. I’d expect the height value to be 2.6x what it is on the pc.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/54d44a97-5866-42d0-b233-7cfcf04cd8dfn%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/93f1be9b-5240-4b3f-989f-f7e6f5fa7ae6n%40googlegroups.com.