Angus Leeming wrote:
Michael Schmitt wrote:

Dear Christian and all Qt developers,

I would like to tell you that the LyX team has released a series of pre-releases for LyX 1.3.6 on Windows.

You can find the latest version at

 http://wiki.lyx.org/Windows/LyX136pre

The LyX community has also generated a short list of Qt/WinFree bugs which you can find on the same page.

Section "Apparent Qt/WinFree bugs" at the bottom of the page.
I've attached two tiny programs that demonstrate two of the bugs. Maybe they'll help...

I think that the attached program demonstrates two bugs. One, definitely, in Qt/WinFree and one, possibly, in LyX.

The problem lies with the QFont style hint (which isn't useful on *nix because the OS doesn't support it). On my WinXP box, the compiled program returns:

    Serif: Arial [MS]
    SansSerif: Arial [MS]
    TypeWriter: Arial [MS]

I think that the Qt/WinFree bug is clear; different style hints should return different fonts.

The LyX bug, if bug it is, is a little more subtle. Other Qt libraries (eg Qt Non-Commercial 3.2.1) apparently return the font name without the foundary on QFontInfo::family(). Ie, "Arial" rather than "Arial [MS]".

It's trivial for me to handle this difference but I'd like to establish what Qt/WinFree *should* be returning here. The docs don't make it clear, to me at least.

Regards,
Angus


#include <qapplication.h>
#include <qpushbutton.h>

#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>

using std::string;

template <class Target, class Source>
Target convert(Source arg);


template<>
int convert<int>(char * cptr)
{
        return strtol(cptr, 0, 10);
}


int usage(string const & name)
{
        std::cerr << "Usage: " << name
                  << " [1-3]\nwhere 1==times,2==helvetica,3==courier\n";
        return 1;
}

int main( int argc, char **argv )
{
        if (argc != 2)
                return usage(argv[0]);

        int const choice = convert<int>(argv[1]);
        QFont::StyleHint font_hint = QFont::Serif;
        string font_name = "Serif";
        switch (choice) {
        case 1:
                font_hint = QFont::Serif;
                font_name = "Serif";
                break;
        case 2:
                font_hint = QFont::SansSerif;
                font_name = "SansSerif";
                break;
        case 3:
                font_hint = QFont::TypeWriter;
                font_name = "TypeWriter";
                break;
        default:
                return usage(argv[0]);
        }

        QApplication a( argc, argv );

        // Try the hint
        QFont font;
        font.setStyleHint(font_hint);
        QFontInfo fi(font);

        std::ostringstream ss;
        ss << font_name << " = " << fi.family();

        QPushButton hello( ss.str(), 0 );
        hello.resize( 200, 30 );

        a.setMainWidget( &hello );
        hello.show();
        return a.exec();
}

Reply via email to