Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kivy label show Khmer error #7227

Closed
onsunsl opened this issue Nov 23, 2020 · 6 comments
Closed

Kivy label show Khmer error #7227

onsunsl opened this issue Nov 23, 2020 · 6 comments
Labels
Component: Widgets kivy/uix, style.kv Type: Bug A bug or something not working as intended

Comments

@onsunsl
Copy link
Contributor

onsunsl commented Nov 23, 2020

Software Versions

  • Python: 3.6.6
  • OS: Windows 10
  • Kivy: 1.11.1
  • Kivy installation method: pip install kivy

Expected behavior

I want to show Khmer text like this សួស្តី, but the kivy show effect is like this:

image

I think SDL2 has a problem with Khmer rendering. The KhmerOSBattambang-Regular.ttf font file i have verified in PyQt
that it can be show Khmer language normally.

Code and Logs and screenshots

from kivy.uix.label import Label
from kivy.app import App


class KhmerApp(App):
    def build(self):
        label = Label(text="សួស្តី")
        label.font_name = "./KhmerOSBattambang-Regular.ttf"
        label.font_size = 40
        return label


if __name__ == '__main__':
    KhmerApp().run()
@Julian-O
Copy link
Contributor

Julian-O commented Nov 2, 2023

Confirming that I ran this code on Windows 11, Kivy 2.2.1 using a copy of the font I downloaded from khmer-fonts.com, and got the wrongly-displayed text.

Furthermore, I copied the text into the previewer on that site, and confirmed that the font is capable of showing it.

@Julian-O Julian-O added Component: Widgets kivy/uix, style.kv Type: Bug A bug or something not working as intended labels Nov 2, 2023
@misl6
Copy link
Member

misl6 commented Nov 10, 2023

Well ...

I've just tested the following on macOS (and maybe @Julian-O can confirm that on Windows):

  • Downloaded a copy of the font from khmer-fonts.com: I'm able to replicate the issue
  • Downloaded a copy of the font from https://github.com/python-pillow/Pillow/blob/main/Tests/fonts/KhmerOSBattambang-Regular.ttf, the issue disappears.

Is that a font issue that needs to be investigated on freetype?

@misl6
Copy link
Member

misl6 commented Nov 10, 2023

By looking at file infos, dates and releases are pretty different between the two versions, but I'm not able to find a release note for the font file.

@Julian-O
Copy link
Contributor

Julian-O commented Nov 10, 2023

Interesting. On Windows...

Is Khmer OS Battambang the same font (albeit different versions) as the ones called Battambang on Google? Well EagleFonts seems to think so, listing Danh Hong as the author.

@misl6
Copy link
Member

misl6 commented Nov 10, 2023

Downloaded a copy from Google Fonts. Problem replicated also on macOS.

However, by providing the correct script name it actually works. (with all the 3 fonts files)

from kivy.uix.label import Label
from kivy.app import App


class KhmerApp(App):
    def build(self):
        label = Label(text="សួស្តី")
        label.font_name = "./Battambang-Regular.ttf"
        label.font_script_name = "Khmr"
        label.font_size = 300
        return label


if __name__ == '__main__':
    KhmerApp().run()

If you @Julian-O can confirm the same, I guess we can close the issue as fixed. (font_script_name landed in 2.2.0 - https://kivy.org/doc/stable/api-kivy.uix.label.html#kivy.uix.label.Label.font_script_name)

@Julian-O
Copy link
Contributor

Confirm it works on Windows when label.font_script_name = "Khmr" is set.

That's a new concept for me.

Closing as solved, but I am thinking about working it into the FAQ.

(Oh, and a big thanks to the @onsunsl. Your test code and clear explanation made this possible to debug and test despite not being able to read a word of Khmer. សូមអរគុណ)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Widgets kivy/uix, style.kv Type: Bug A bug or something not working as intended
Projects
None yet
Development

No branches or pull requests

3 participants