×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Jul 2007
    Location
    Eindhoven, the Netherlands
    Posts
    187

    N97/Qt 4.6.2: Fixed width font?

    Hi,

    I've been playing with the QTextEdit widget, creating a simple text editor app so i can edit my python files on my N97. I would like this editor to use a fixed width font, but can't seem to make that work... here's the code i use to set the font of the mainwindow, and the textedit widget:

    Code:
    QFont font;
    font.setFamily(QString::fromUtf8("Courier"));
    font.setFixedPitch(true);
    font.setPointSize(5);
    setFont(font);
    Am i forgetting something?


    Regards,
    Mark.

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: N97/Qt 4.6.2: Fixed width font?

    This application lists all available fonts on the device:
    Code:
    #include <QApplication>
    #include <QFontDatabase>
    #include <QStringList>
    #include <QDebug>
    
    int main(int argc, char* argv[])
    {
        QApplication app(argc,argv);
    
        QFontDatabase db;
        QStringList families = db.families();
        for (int i = 0; i < families.length(); ++i) {
            qDebug() << i << families.at(i);
        }
    
        return app.exec();
    }
    Last edited by divanov; 2010-03-22 at 16:16. Reason: fixing a typo

  3. #3
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: N97/Qt 4.6.2: Fixed width font?

    There are three fonts available by default on the N97 under Qt (though I understand you can add more). The fonts are:
    • Series 60 Sans
    • Series 60 Sans TitleSmBd
    • Series 60 ZDigi

    As far as I can tell, none of them is fixed width by default, though I believe you can muck with the QFont properties to create fixed-width spacing.

  4. #4
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: N97/Qt 4.6.2: Fixed width font?

    (Note that the fonts available on the emulator are not the same ones that are available on the hardware.)

  5. #5
    Regular Contributor
    Join Date
    Jul 2007
    Location
    Eindhoven, the Netherlands
    Posts
    187

    Re: N97/Qt 4.6.2: Fixed width font?

    Quote Originally Posted by danhicksbyron View Post
    There are three fonts available by default on the N97 under Qt (though I understand you can add more). The fonts are:
    • Series 60 Sans
    • Series 60 Sans TitleSmBd
    • Series 60 ZDigi

    As far as I can tell, none of them is fixed width by default, though I believe you can muck with the QFont properties to create fixed-width spacing.
    I found the following fonts present in the emulator:
    • Heisei Kaku Gothic S60
    • Sans MT UniT_HKSCS_S60
    • Sans MT 936_S60
    • Sans MT SC 936_S60C
    • Sans MT TC Big5HK_S60C
    • Series 60 Sans
    • Series 60 Sans TitleSmBd
    • Series 60 ZDigi

    I have tried all of them, setting fixed width using the method stated in my initial post, but this does not seem to work for any of them. How can i manipulate a font to present itself as having a fixed width?

    Mark

  6. #6
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: N97/Qt 4.6.2: Fixed width font?

    If setFixedPitch doesn't do it, I suppose you either have to place each character individually or install a different font.

    Supposedly there are a bunch of fonts packaged up to be installed under Qt, but I know nothing about that.

Similar Threads

  1. can i count on font sizes and string width on real devices
    By TacB0sS in forum Mobile Java General
    Replies: 4
    Last Post: 2009-08-13, 17:07
  2. font flags not working
    By jtullis in forum Symbian
    Replies: 10
    Last Post: 2008-12-10, 08:27
  3. Replies: 2
    Last Post: 2008-11-02, 18:42
  4. How to get the name of the used font
    By chrishawaii in forum Symbian User Interface
    Replies: 1
    Last Post: 2007-06-22, 06:55
  5. [announce] full screen dot amtrix scroller
    By xchip in forum Symbian
    Replies: 7
    Last Post: 2006-06-08, 22:17

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×