Qt Development Android app's Chinese font problem

Source: Internet
Author: User

1. Android default font is droidsansfallback: Google Chinese font
Due to inconsistent phone and PC fonts, the app developed on the PC is displayed as a small box in Chinese to the destination Android device.
Therefore, you need to set the system font in the main function of QT:
// Pass the font file name to Addapplicationfont to get the font ID int Fontid = Qfontdatabase::addapplicationfont ("/system/fonts/droidsansfallback.ttf " ); // Pass the font ID to applicationfontfamilies and get a qstringlist, where the first element is the newly added font family QString msyh = qfontdatabase::applicationfontfamilies (Fontid). at (0); Qfont font (MSYH,ten); App.setfont (font);

2. In order to facilitate debugging in the development environment, you can download Droidsansfallback fonts and install them into the development host, and choose font changes in the qtcreator environment.

Realize the font display effect of the development machine consistent with the target machine.

Qt Development Android app's Chinese font problem

Related Article

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.