Hindi Font rendering incorrect in Kivy (Python for Android) App

160 views
Skip to first unread message

Ramprasad S

unread,
Oct 14, 2020, 1:21:32 PM10/14/20
to Kivy users support

Software Versions

  • Python:3.7
  • OS:Android
  • Kivy:1.11
  • Kivy installation method: P4A

When I render the following text with the google NotoSansfont for Devanagari script in kivy android, I get it rendered wrongly. I have seen similar messages in SO for other languages and it says use pango text provider but it also mentions it is not available for android. Is there a possibility to render the font correctly in android in a kivy App. This will be a make or break for using kivy as the app development platform for us as we need to support Indian languages in our mobile app.

Example Text Expected output ->
image

Example Text Rendered Output ->
image

This happens in all the controls - Label and TextInputs and we have tried different ttf files - NotoSans, Akshar, atleast 10 other font files.

The only font which works correctly is GNU Unifont for us but that is because it has all the glyphs within and the problem we have is it does not look good and readable although that is now our current and only option.

Can we get some help here please?

example code:
from kivy.app import App
from kivy.uix.image import Image
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button

class MainApp(App):
def build(self):
label = Label(text="अंतरिक्ष", font_name="notosans.ttf", size_hint=(0.5,0.5),pos_hint={'center_x':.5,'center_y':.5})
layout = BoxLayout(padding =10)
layout.add_widget(label)
return layout

if name=='main':
app = MainApp()
app.run()

Font file link : https://fonts.google.com/specimen/Noto+Sans?subset=devanagari

Darpan Verma

unread,
Oct 15, 2020, 2:17:38 AM10/15/20
to Kivy users support
It is already mentioned in documentation that kivy doesn't support देवनागरी scripts.
For longer texts, try to use webview or see if it is possible to create a hidden webview in label।

homeo...@gmail.com

unread,
Oct 15, 2020, 2:49:31 AM10/15/20
to Kivy users support
Can you please point to the documentation where this is mentioned?
Also can a webview be used and packaged along with an Android Application using P4A, any pointers here please?

Darpan Verma

unread,
Oct 15, 2020, 3:25:44 AM10/15/20
to Kivy users support
Yes, it is there on page no.19 of kivy documentation 2.0.0rc3

Plus, implementation of webview is my own idea if possible, it's not recommended by any of kivy developer.
IMG_20201015_125513.jpg

Reply all
Reply to author
Forward
0 new messages