How to get QML FontLoader to load UTF-8 on boot

161 views Asked by At

My setup:

  • Qt 5.9.4
  • buildroot Linux system
  • rockchip rk3288 processor
  • bootscript in /etc/init.d

I have some qml to display some utf8 characters

// roboto font
FontLoader {
    id: roboto
    source: "qrc:/fonts/Roboto-Regular.ttf"
}

Text {
    text: "The temperature is: \u2103"
    font.pixelSize: 24
    font.family: roboto.name
}

When I run the application from the command line (UART) the font renders correctly. When I reboot and have my application run from the boot script. The utf-8 characters are NOT rendered correctly.

I have tried all sorts of combinations:

  • The font is on the file system
  • The font is in different places on the filesystem
  • different fonts (montserrat, Avenir, etc).
  • display the font based on the loader status == FontLoader.Ready

All with the same results. I happened to accidentally stumble upon this solution:

// japanese font
FontLoader {
    id: jpFont
    source: "qrc:/fonts/NotoSansJP-Regular.otf"
}

// roboto font
FontLoader {
    id: roboto
    source: "qrc:/fonts/Roboto-Regular.ttf"
}

Text {
    text: "The temperature is: \u2103"
    font.pixelSize: 24
    font.family: roboto.name
}

This works. I'm not even using the japanese font, but it seems to make the Roboto start working correctly.

  • Why does my font load utf8 debugging, but not from bootup
  • why does this extra font magically fix it ?
0

There are 0 answers