Kivy isn't showing (Bengali) Unicode character properly

570 Views Asked by At

Currently I am Working on a Kivy desktop application but I am facing a problem while trying to display unicode characters in Bengali in my application's Label and Button Text. Every time I'm getting output like the image below. I have tried different fonts such as SolaimanLipi.ttf, kalpurush.ttf, NikoshBAN.ttf but still no luck. I am using a Windows PC. The same text in the same font displays correctly outside of Kivy; it works fine in all text editors and to make sure I have tested in a Java Swing desktop application, too.

Can any one please describe what is the problem? What can i do to solve it?

Expected Output:

correctly rendered sakālē

Program Output:

incorrect rendering

        #-- coding: utf-8 --

        from kivy.base import runTouchApp
        from kivy.lang import Builder

        runTouchApp(Builder.load_string("""
        #:import sp kivy.metrics.sp
        Label:
            text: 'সকালে'
            font_size: sp(50)
            font_name: "SolaimanLipi.ttf"    
        """))
2

There are 2 best solutions below

2
On

There is a bug in Kivy which has been open since 2014 (!) - https://github.com/kivy/kivy/issues/2669

To the extent that I can understand the discussion and the current status, the developer is looking for a solution still.

Languages such as Tamil require reshaping, a process which is not supported in our current providers. I'm working on a new text provider using Pango as an option to provide this support on Linux (and probably OSX).

-- kived in 2014

This (from 2017) seems relevant, too, but also vaguely stale: https://github.com/kivy/kivy/issues/4902

0
On

Unicode text can be converted to Bijoy (ANSI) text and can be used easily in Kivy with the use of [font] tag like this:

text = "[font=font/SutonnyMJ]Avwg evsjvq K_v ewj[/font] means I speak Bangla"

This repo provides code and instructions related to Unicode to Bijoy (ANSI) conversion in Kivy. Not a perfect solution, but most of the apps will meet their need.