Kivy Display Chinese

Source: Internet
Author: User
Recently in learning Kivy, practice writing demo when found Chinese can not be displayed correctly, online query said to specify the font can be found in the OS X font Library directory

/system/library/fonts, you can directly use the Chinese font such as, bold: ' Stheiti MEDIUM.TTC ', in the code used as follows:

Self.add_widget (Label (text= ' username: ', font_name= ' Stheiti MEDIUM.TTC '))

If you do not want to use the font of the system, but want to use the font you specify, you can use the following method


1. Specify the path where the font library is located

Kivy.resources.resource_add_path ("/usr/share/fonts/truetype/")

2. Define variable names for font libraries

Font_heiti = Kivy.resources.resource_find ("Xxxx.ttf")

3. Can be set directly by variable name when using

Self.add_widget (Label (text= ' username: ', font_name=font_heiti))



 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.