Does anyone know how Kivy renders text in different fonts?
I have labels with text at 16sp.
On a tablets with screen sizes (1024, 552) and (2048, 1536) it works perfectly (width/height ratios 1.855 and 1.333 respectively)
On the pc with screen size (1280, 720) (ratio 1.778) it also displays perfectly, but on a phone with this screen size the letters are truncated
The only difference here is the physical size of the device. It thus appears, that Kivy text is not rendered according to some algorithm based on pixels, but takes into account the physical size of the screen
Is there any way to determine the physical size in Kivy? and hence allow me to adjust font size accordingly. The text appears correctly on the phone (small device) if I use a smaller (10sp) font size, but then it appears too small on the larger devices.
Either through the config http://kivy.org/docs/api-kivy.config.html or through the cmd line args (try `python kivyapp.py --help` to see the available options). For android and ios the app should be fullscreen anyways so getting the window. size should give you the screen resolution.
Using the dp unit is a simple solution to making the view dimensions in your layout resize properly for different screen densities. In others words, it provides consistency for the real-world size of your UI across different devices.
Yes, you can determine the physical size of screen with kivy - You could simply use this Module:
(from kivy.core.window import Window
)
and then determine sizes by writing this:
(Window.size
)
Check this code out (this code determines screen physical sizes on a simple label):
⬇️⬇️
from kivy.app import App
from kivy.uix.label import Label
from kivy.core.window import Window
class MyApp(App):
def build(self):
window_sizes=Window.size
return Label(text="screen sizes= "+str(window_sizes))
MyApp().run()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With