Using the following code I want to display letters from some languages into one label.
These languages are: English, German, Japanese, Chinese, Russian, French, Spanish, Arabic.
I tried with some Windows system fonts, but none of them could display ALL letters correctly.
I would like to know if there is any font to support all of the languages above?
Or how can I do it in kivy? (to have all of them in one label.)
Here is the code:
# -*- coding: utf-8 -*-
from kivy.app import App
#kivy.require("1.8.0")
from kivy.uix.label import Label
from kivy.uix.widget import Widget
from kivy.lang import Builder
import kivy.resources
#kivy.resources.resource_add_path(r'/home/kivy/android/android-sdk-linux/platforms/android-18/data/fonts')
kivy.resources.resource_add_path('C:\Windows\Fonts')
import os.path
Builder.load_string('''
<Label>:
font_name: 'AdobeGothicStd-Bold.otf'
<Widgets>:
Label:
text: "ABC ÄäÜüß にほんご 中文 ру́сский язы́к ÉéÈèÊêËë Españolالعَرَبِيَّة français"
size: root.width, 75
pos: root.x, root.top - 150
font_size: 50
height: 75
''')
class Widgets(Widget):
def build(self):
return Widgets()
class MyApp(App):
def build(self):
return Widgets()
if __name__ == "__main__":
MyApp().run()
Thanks!
For many technical and social reasons you won't find a single font of good quality that covers all the locales you want to target.
Good software achieves what you intend to do by composing different fonts (and the labels need to be annotated with the target locale, codepoint is not enough, Japanese and Chinese codepoints overlap but should not be rendered the same way).
Lots of python software is not internationalization-ready and still assumes selecting a specific font or font file is good enough. Yes it is but only in an ascii world.
To learn about font composition, look up fontconfig and harfbuzz-ng.
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