Вопрос

I am trying to use robot thin font in QML in Linux.I have install bold,thin and light fonts on ubuntu. Other programs like openoffice shows me only roboto. How do i get to use roboto thin or light in qml?

Это было полезно?

Решение 2

You can bundle the font files with your application and then use FontLoader component to load the version you want and use these in QML.

This component also exist for QtQuick 1.0 as it was introduced in Qt 4.7 FontLoader

Другие советы

FontLoader will solve the issue for Light Roboto but not for Thin as it's not a sported weight. Remember to call font.weight: Font.Light in the text elements were you want to use Light weight.

You will need to repackage the Roboto-thin.ttf as a new font and then import it back with FontLoader, (no need for the font.weight: Font.Light call in this case)

AlexB's answer is correct, and has cost me too long struggling why it didn't work.

For those wondering why their Roboto-Light font looks like Roboto-Bold, heres how to fix it:

FontLoader
{
   id: robotoLight
   source: "../fonts/Roboto/Roboto-Light.ttf"
}

Text
{
   text: "This text is Roboto-Light"
   font.family: robotoLight.name
   font.weight: Font.Light   // this is necessary or else it'll look like Roboto-Bold
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top