简体   繁体   English

如何在QML应用程序中更改字体系列?

[英]How to change font family in qml app?

how to change the font.family of a qml app on android smartphone? 如何在Android智能手机上更改qml应用程序的font.family? I use Qt 5.3. 我使用Qt 5.3。

I've tried to set the QApplication::setFont() and also the font.family property of the qml component: import QtQuick 2.3 import QtQuick.Controls 1.2 我尝试设置QApplication::setFont()以及font.family组件的font.family属性:import QtQuick 2.3 import QtQuick.Controls 1.2

ApplicationWindow {

    id: mainWindow
    visible: true
    width: 640
    height: 480

    Text {
        font.pointSize: 24;
        color: Qt.rgba(0.2,0.2,0.2,1);
        font.family: "Courier";
        text: qsTr("MyText");
    }

}

but nothing seems to work.. The only thing that happens on using setFont() is that the font size scale. 但是似乎没有任何效果。使用setFont()时唯一发生的是字体大小比例。

For Android Jelly Bean, with Qt, listing Font Families returned: 对于带有Qt的Android Jelly Bean,列出了返回的字体系列:

console.log(Qt.fontFamilies())

Android Emoji
AndroidClock
AndroidClock-Large
Clockopia
Droid Arabic Naskh
Droid Naskh Shift Alt
Droid Sans Armenian
Droid Sans Ethiopic
Droid Sans Fallback
Droid Sans Georgian
Droid Sans Hebrew
Droid Sans Mono
Droid Serif
MotoyaLMaru
NanumGothic
Noto Sans
Noto Sans Bengali
Noto Sans Bengali UI
Noto Sans Devanagari
Noto Sans Devanagari UI
Noto Sans Kannada
Noto Sans Kannada UI
Noto Sans Lao
Noto Sans Lao UI
Noto Sans Malayalam
Noto Sans Malayalam UI
Noto Sans Symbols
Noto Sans Tamil
Noto Sans Tamil UI
Noto Sans Telugu
Noto Sans Telugu UI
Noto Sans Thai
Noto Sans Thai UI
Padauk Book
Roboto
Roboto Condensed

The recommended one for "Fixed" is Helvetica . 推荐的“固定”版本是Helvetica

The best monospace solution, I think is: Droid Sans Mono . 我认为最好的等宽解决方案是: Droid Sans Mono

Hope that helps someone in the future looking for this info in the future. 希望可以帮助将来的某个人在将来查找此信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM