Coder Social home page Coder Social logo

Comments (3)

i-g-g-y avatar i-g-g-y commented on August 16, 2024

Forgot to mention, this was observed when using MS Sans Serif

from lcd-image-converter.

riuson avatar riuson commented on August 16, 2024

Sorry, I can't fix it.
Fonts like

  • Courier
  • MS Sans Serif
  • MS Serif

are bitmap fonts. They can't be scaled to any size. Only fixed list of values are available.
I can only add note for such fonts and update list of sizes.

For example, Arial is a scalable font:

#include "mainwindow.h"
#include <QFontDatabase>
#include <QDebug>
#include <QFontMetrics>
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QFontDatabase fonts;
    QString family =
            //"MS Sans Serif";
            //"Arial";
            "Courier";

    QString style = "Normal";

    QList<int> sizes = fonts.smoothSizes(family, style);
    qDebug() << "Sizes for " << family << " " << style;

    for (int i = 0; i < sizes.count(); i++)
    {
        qDebug() << sizes.at(i);
    }

    bool isScalable = fonts.isScalable(family, style);
    bool isSmoothlyScalable = fonts.isSmoothlyScalable(family, style);
    qDebug() << "isScalable: " << (isScalable ? "true" : "false");
    qDebug() << "isSmoothlyScalable: " << (isSmoothlyScalable ? "true" : "false");

    for (int i = 16; i <= 72; i++)
    {
        QFont font = fonts.font(family, style, i);
        QFontMetrics metrics(font);
        qDebug() << "i = " << i << ", h = " << metrics.height();
    }

    MainWindow w;
    w.show();
    return a.exec();
}
Sizes for  "MS Sans Serif"   "Normal"
10
12
15
18
19
22
27
28
35
isScalable:  false
isSmoothlyScalable:  false
i =  16 , h =  23
i =  17 , h =  29
i =  18 , h =  29
i =  19 , h =  28
i =  20 , h =  33
i =  21 , h =  33
i =  22 , h =  33
i =  23 , h =  33
i =  24 , h =  33
i =  25 , h =  41
i =  26 , h =  41
i =  27 , h =  41
i =  28 , h =  42
i =  29 , h =  42
i =  30 , h =  42
i =  31 , h =  42
i =  32 , h =  52
i =  33 , h =  52
i =  34 , h =  52
i =  35 , h =  52
i =  36 , h =  52
i =  37 , h =  52
i =  38 , h =  52
i =  39 , h =  52
i =  40 , h =  52
i =  41 , h =  52
i =  42 , h =  52
i =  43 , h =  52
i =  44 , h =  52
i =  45 , h =  52
i =  46 , h =  52
i =  47 , h =  52
i =  48 , h =  52
i =  49 , h =  52
i =  50 , h =  52
i =  51 , h =  52
i =  52 , h =  52
i =  53 , h =  52
i =  54 , h =  52
i =  55 , h =  52
i =  56 , h =  52
i =  57 , h =  52
i =  58 , h =  52
i =  59 , h =  52
i =  60 , h =  52
i =  61 , h =  52
i =  62 , h =  52
i =  63 , h =  52
i =  64 , h =  52
i =  65 , h =  52
i =  66 , h =  52
i =  67 , h =  52
i =  68 , h =  52
i =  69 , h =  52
i =  70 , h =  52
i =  71 , h =  52
i =  72 , h =  52
Sizes for  "Arial"   "Normal"
isScalable:  true
isSmoothlyScalable:  true
i =  16 , h =  24
i =  17 , h =  26
i =  18 , h =  27
i =  19 , h =  28
i =  20 , h =  32
i =  21 , h =  32
i =  22 , h =  33
i =  23 , h =  35
i =  24 , h =  36
i =  25 , h =  38
i =  26 , h =  40
i =  27 , h =  41
i =  28 , h =  42
i =  29 , h =  44
i =  30 , h =  45
i =  31 , h =  47
i =  32 , h =  49
i =  33 , h =  50
i =  34 , h =  50
i =  35 , h =  53
i =  36 , h =  55
i =  37 , h =  56
i =  38 , h =  58
i =  39 , h =  60
i =  40 , h =  60
i =  41 , h =  63
i =  42 , h =  65
i =  43 , h =  65
i =  44 , h =  66
i =  45 , h =  67
i =  46 , h =  68
i =  47 , h =  71
i =  48 , h =  72
i =  49 , h =  73
i =  50 , h =  75
i =  51 , h =  76
i =  52 , h =  77
i =  53 , h =  80
i =  54 , h =  81
i =  55 , h =  82
i =  56 , h =  83
i =  57 , h =  84
i =  58 , h =  87
i =  59 , h =  88
i =  60 , h =  89
i =  61 , h =  91
i =  62 , h =  92
i =  63 , h =  94
i =  64 , h =  96
i =  65 , h =  97
i =  66 , h =  99
i =  67 , h =  100
i =  68 , h =  101
i =  69 , h =  103
i =  70 , h =  104
i =  71 , h =  106
i =  72 , h =  107
Sizes for  "Courier"   "Normal"
10
12
15
19
isScalable:  false
isSmoothlyScalable:  false
i =  16 , h =  22
i =  17 , h =  29
i =  18 , h =  29
i =  19 , h =  29
i =  20 , h =  29
i =  21 , h =  29
i =  22 , h =  29
i =  23 , h =  29
i =  24 , h =  29
i =  25 , h =  29
i =  26 , h =  29
i =  27 , h =  29
i =  28 , h =  29
i =  29 , h =  29
i =  30 , h =  29
i =  31 , h =  29
i =  32 , h =  29
i =  33 , h =  29
i =  34 , h =  29
i =  35 , h =  29
i =  36 , h =  29
i =  37 , h =  29
i =  38 , h =  29
i =  39 , h =  29
i =  40 , h =  29
i =  41 , h =  29
i =  42 , h =  29
i =  43 , h =  29
i =  44 , h =  29
i =  45 , h =  29
i =  46 , h =  29
i =  47 , h =  29
i =  48 , h =  29
i =  49 , h =  29
i =  50 , h =  29
i =  51 , h =  29
i =  52 , h =  29
i =  53 , h =  29
i =  54 , h =  29
i =  55 , h =  29
i =  56 , h =  29
i =  57 , h =  29
i =  58 , h =  29
i =  59 , h =  29
i =  60 , h =  29
i =  61 , h =  29
i =  62 , h =  29
i =  63 , h =  29
i =  64 , h =  29
i =  65 , h =  29
i =  66 , h =  29
i =  67 , h =  29
i =  68 , h =  29
i =  69 , h =  29
i =  70 , h =  29
i =  71 , h =  29
i =  72 , h =  29

from lcd-image-converter.

i-g-g-y avatar i-g-g-y commented on August 16, 2024

OK, thanks for info, I will use a scalable font then.

from lcd-image-converter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.