Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Different font pixel metrics in different devices.
Forum Update on Monday, May 27th 2025

Different font pixel metrics in different devices.

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 296 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    XavierLL
    wrote on last edited by
    #1

    Hi!

    When I execute this code in Windows

        QFont f = QFont("Verdana");
        f.setPixelSize(18);
        QFontMetrics fm(f);
        int pixelsWidth = fm.width("What's the width of this text?What's the width of this text?");
        int pixelsHeight = fm.height();
        qDebug() << "Width: " << pixelsWidth;
        qDebug() << "Height: " << pixelsHeight;
    

    I Obtain:

    Width: 528;
    Height: 22;

    When executed on Android:

    Width: 458
    Height: 21

    If I load the font as a ".ttf"

    fontId = QFontDatabase::addApplicationFont(":/fonts/verdana/verdana");
    

    On windows I get:

    Width: 528
    Height: 22

    On Android:

    Width: 534
    Height: 22

    Is Qt using a different font rendering engine for different platforms? Is there any way to obtain the same pixel size for both devices?

    thanks!!

    Xavierll

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved