Important: Please read the Qt Code of Conduct -

QFont setFixedPitch

  • Setting setFixedPitch to true doesn't seem to work with Dejavu sans. Is this allowed? The following code doesn't yeild the same rectangles for the given text. To me if you set fixed pitch to true, those rectangles should be the same. Am I wrong here?

    @QFont dejavu("DejaVu Sans");
    QFontMetrics fm(dejaVu);
    QRect r1 = fm.boundingRect("Test ");
    QRect r2 = fm.boundingRect("Test0");

  • DejaVu Sans is a proportional font. Did you try setFixedPitch with any other proportional font and did that work? Your code snip returns the same bounding rectangle for fixed fonts (DejaVu Sans Mono, courier etc)

    Looks like no effect of calling setFixedPitch ... maybe a bug that you should log "here":

  • So I tried other proportional fonts and set fixed pitch had no effect on them. I logged a bug report.

  • thanks :)

Log in to reply