Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x
Accepted Solution

Fonts in Qt

Is there a way to use custom Fonts in Qt or change visual size of Fonts supplied with Qt. Minimum size 6 currently is too large for some use-cases.

Thanks.

Please use plain text.
Developer
Zmey
Posts: 1,511
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Fonts in Qt

I've been using ttf fonts in Desktop apps. Most likely this will work on mobile too:

 

FontLoader {
    id: scadaRegularFontLoader
    source: "Fonts/Scada-Regular.ttf" 
}

Text {
    color: "white" 
    font.family: scadaRegularFontLoader.name
    font.pointSize: 9
}

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Fonts in Qt

Thanks, I'll try.

My concern is how BB10 renders these fonts.

For example I am trying to use the smallest possible Font:

font = QFont(QString("Courier New"), 6);

but it's huge:Qt_fonts.png

Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Fonts in Qt

Tried this code to load .ttf font:

    QString fontName(QLatin1String("/usr/fonts/font_repository/monotype/cour.ttf"));
    int appFontId = QFontDatabase::addApplicationFont(fontName);
    if (appFontId < 0){
        qWarning() << "Attempt to load application font: "<< fontName << " failed.";
    }

Anyway letters are too big:

IMG_00000048.png

Please use plain text.
Developer
oniongarlic
Posts: 69
Registered: ‎10-19-2012
My Device: Playbook, BB10DevAlphaB
My Carrier: Sonera, Saunalahti

Re: Fonts in Qt

The default size is in points, and I'm guessing, the real size used then depends on the font size setting of the device.

If you need exact pixels, try setPixelSize http://qt-project.org/doc/qt-4.8/qfont.html#setPixelSize
Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Fonts in Qt

Thanks! This is what I was looking for.

Please use plain text.
Contributor
tzander
Posts: 40
Registered: ‎05-14-2013
My Device: Z10
My Carrier: none

Re: Fonts in Qt

Notice that different devices of different sizes will come out; using a size in points is the main way to get the same physical size on all devices.

Also, if you think 6pt looks too big, I'm wondering if you tried to read it on a real device. Since thats the smalles I can read without a magnifying glass.

Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Fonts in Qt

Screenshots in this thread are taken from real device.

Please use plain text.