PDA

View Full Version : QFontDatabase::pointSizes question / bug



giotto
14th October 2008, 14:28
Hi Guys,

I'd like to list the available font sizes of the user selected font - like a custom font dialog. I have some problem with the size of the NonScalableFonts.

If I select a scalable font, than its sizes are (6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72). This is the returned list of the QFontDatabase::pointSizes method.

If I selects a NonScalableFont - for example font Terminal - and ask for its size with pointSizes than the list is the same, but this shouldn't be.

I've tried this with thing with QFontDialog::getFont, than this dialog has the same problem. I select there the Terminal font, and change the size form 6 to 7 or 8 but the preview window has the font with unchanged size. So this means to me that something is wrong. The officially available sizes for the font Terminal are 4.5, 6, 9, 12, 13.5.

This is the code, how I try to get the available sizes and display it in a message box:



void Class::getAvailableFontSizes(const QString& fontName){
QString str;
QFontDatabase database;
QList<int> fontSizes = database.pointSizes(fontName);

str.append("FontName: "+fontName+"\n");

for(int i = 0; i < fontSizes.size(); ++i){
str.append("("+QString::number(i)+") "+ QString::number(fontSizes.at(i))+"\n");
}

QMessageBox mb(this);
mb.setText(str);
mb.exec();
}


Am I missing something??
How can I get the correct sizes??

giotto

jacek
23rd October 2008, 02:13
What does QFont( fontName ).exactMatch() return?