Results 1 to 9 of 9

Thread: Using fonts without X server

  1. #1
    Join Date
    Jul 2006
    Location
    Poprad/Prague
    Posts
    33
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Using fonts without X server

    Hello,

    I am using Qt to draw some graphics and I want to use the application also form console, without X server running. The problem is, that when I call QPainter::drawText(...) on my QImage, I got runtime error saying
    Qt Code:
    1. ASSERT failure in QFontDatabase: "A QApplication object needs to be constructed before FontConfig is used.", file text/qfontdatabase_x11.cpp
    To copy to clipboard, switch view to plain text mode 

    I can't construct QApplication, because then the application would not run without X server. I tried to construct QCoreApplication, but that did not help. So how can I draw text onto QImage without X server running?

    Any advice appreciated...

  2. #2
    Join Date
    Jul 2006
    Location
    Poprad/Prague
    Posts
    33
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using fonts without X server

    At first, the search didn't return any results, but now I've found a topic about it
    here

    ...I think that nothing has changed since february, so the answer is probably sad: it is not possible...

    If somebody knows about anything, please, let me know...

  3. #3
    Join Date
    Jul 2006
    Location
    Poprad/Prague
    Posts
    33
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using fonts without X server

    Ok folks, that's what I thought up:
    a) using an additional library, of course the first thing that crossed my mind
    b) save the images of characters in png using alpha channel and resizing them according to the needs (may compromise quality and readability of text )
    c) (somehow) save the rendered paths for every character and then used these saved paths

    both b) and c) needs some preparation and loading extern resources to the app.

    So my question now is: got an idea how to save QPainterPath so the application will be able to load it at startup?

  4. #4
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using fonts without X server

    Quote Originally Posted by macbeth
    Ok folks, that's what I thought up:
    a) using an additional library, of course the first thing that crossed my mind
    b) save the images of characters in png using alpha channel and resizing them according to the needs (may compromise quality and readability of text )
    c) (somehow) save the rendered paths for every character and then used these saved paths

    both b) and c) needs some preparation and loading extern resources to the app.

    So my question now is: got an idea how to save QPainterPath so the application will be able to load it at startup?
    Indeed, you need a connection to an XServer in order to access the font information on that server. No XServer, no fonts.

    As for (b) and (c), have you looked at QPicture?
    Save yourself some pain. Learn C++ before learning Qt.

  5. #5
    Join Date
    Jul 2006
    Location
    Poprad/Prague
    Posts
    33
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using fonts without X server

    Quote Originally Posted by Chicken Blood Machine
    Indeed, you need a connection to an XServer in order to access the font information on that server. No XServer, no fonts.
    I'm sure there are reasons for that, but it would be nice if there was a possibility of rendering text onto QImage or other QPaintDevice without x server...

    Quote Originally Posted by Chicken Blood Machine
    As for (b) and (c), have you looked at QPicture?
    Probably yes, but I forgot that it can be used this way. Thanks for the tip

  6. #6
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using fonts without X server

    Have a look at TwinLib:

    http://twinlib.roard.com/

    It hasn't been maintained for a while, but it works with Qt3. Maybe you can port it to Qt4?
    Save yourself some pain. Learn C++ before learning Qt.

  7. #7
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: Using fonts without X server

    Ever tried to use QApplication ( int & argc, char ** argv, bool GUIenabled ) with GUIenabled = false?


    Ok, might not help you either. At least not in Qt 4.1. Looks like Qt 4.2 might be your salvation:

    int QFontDatabase::addApplicationFont ( const QString & fileName ) [static]

    Added in 4.2
    Last edited by Kumosan; 1st August 2006 at 09:51. Reason: More information found

  8. #8
    Join Date
    Jul 2006
    Location
    Poprad/Prague
    Posts
    33
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using fonts without X server

    Quote Originally Posted by Kumosan
    Ever tried to use QApplication ( int & argc, char ** argv, bool GUIenabled ) with GUIenabled = false?
    No, I used QCoreApplication instead. But I've just tried to use QApplication with GUIenabled=false and I got SegFault when trying to draw text on QImage...

    Quote Originally Posted by Kumosan
    Ok, might not help you either. At least not in Qt 4.1. Looks like Qt 4.2 might be your salvation:

    int QFontDatabase::addApplicationFont ( const QString & fileName ) [static]

    Added in 4.2
    I'll try Qt 4.2 TP today and we'll see...

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Using fonts without X server

    How about Qtopia Core? It could be one option too..
    J-P Nurmi

Similar Threads

  1. Fonts, Colors, and QStyle
    By Jimmy2775 in forum Qt Programming
    Replies: 1
    Last Post: 28th September 2006, 07:26
  2. Using QTcpSockt to check an IMAP server
    By guilugi in forum Qt Programming
    Replies: 12
    Last Post: 20th March 2006, 08:51
  3. connect to sql server
    By raphaelf in forum Qt Programming
    Replies: 15
    Last Post: 27th February 2006, 18:06
  4. Asynchronous server msg vs synchronous functions
    By nouknouk in forum Qt Programming
    Replies: 9
    Last Post: 2nd February 2006, 17:10
  5. synching client readings to server output
    By OnionRingOfDoom in forum Qt Programming
    Replies: 14
    Last Post: 28th January 2006, 18:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.