Results 1 to 11 of 11

Thread: How to make font Smooth in QT?

  1. #1
    Join Date
    Feb 2011
    Posts
    25
    Qt products
    Qt4
    Platforms
    Windows

    Question How to make font Smooth in QT?

    Hello All,

    I have a simple question, or more something i need to understand i think...

    I designed a application in Photoshop and though font would look simular in qt, but it doesn't ofcourse.. after some time googling i learned photoshop uses some soort of smoothing the fonts. I found this is also possible in qt or at least i found something but it wasn't really clear to me still.

    In the attachment you can see the difference. In the left image you see the Photoshop text and on the right you see the same font and size in qt
    SEE HERE:
    how to make text smooth in qt.png

    Is it possible i make the font more smooth, so it could look simular like the Photoshop version?

  2. #2
    Join Date
    Oct 2010
    Posts
    55
    Thanks
    1
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    9

    Default Re: How to make font Smooth in QT?

    What platform are you targeting? I have been asking myself the same question and find this problem especially prevelant when rendering fonts in smaller sizes on MS Windows.

    So I just started to create some Qt-styled wrapper classes for the FreeType library. FreeType (www.freetype.org) is a font engine capable of rendering high-quality font output. It provides a low-level C API and is already used in a number of projects, but I wanted something that works without too much effort together with Qt's Painter framework.

    Currently I have something like:

    QFreeTypeEngine
    QFreeTypeFont
    QFreeTypeGlyph

    ...where a QFreeTypeEngine is responsible for creating and managing QFreeTypeFont objects for a specific application, and individual QFreeTypeFonts can be created from a font in the local filesystem, or from a resource.

    In attached screenshot you can see the difference between FreeType (above), and Windows' default font rendering algorithm (below).

    (Actually I'm not sure it's the exact same font face in both examples, but you can still see the difference in quality, especially if you open the image in PS and zoom in and look at the anti-aliasing.)

    ftype.jpg

  3. #3
    Join Date
    Feb 2011
    Posts
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to make font Smooth in QT?

    "helloworld" thx for your reply, i will take a look in this, but i was hoping to only use QT and not add another 3dparty library... This perhaps would bring more work if i want to build the version for Mac OS X (yes freetype is also multiplatform but i have no experience with Mac OS X)
    Indeed the program running on Windows (Vista) right now.

    I couldn't see the difference right away because of different size and maybe different font... ;-) (also the image has lower quality because of the qt upload/converter i guess) If you would like to show me a example with color: white; font: bold 14px; font-family: Arial; that would be great... but only if you have the time ofcourse.

    i found this article: http://labs.qt.nokia.com/2008/09/01/...iasing-on-x11/
    Where is see this settings panel
    But this is only in Gnome i guess. (so nothing todo with QT)


    Added after 7 minutes:


    Aaaaa.. i now see there is a Qt FreeType engine... that makes it much easier!
    Last edited by janton; 16th May 2011 at 11:10.

  4. #4
    Join Date
    Oct 2010
    Posts
    55
    Thanks
    1
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    9

    Default Re: How to make font Smooth in QT?

    Aaaaa.. i now see there is a Qt FreeType engine... that makes it much easier!
    Where did you find this? Were you referring to my library, or something else you found? This is mainly intended for Windows, but AFAIK should work on all platforms. However I don't find this to be an issue on Mac. Anyway, I'll try to upload some more examples in a while with the settings you mentioned.
    Last edited by helloworld; 16th May 2011 at 14:10.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to make font Smooth in QT?

    Quote Originally Posted by helloworld View Post
    So I just started to create some Qt-styled wrapper classes for the FreeType library. FreeType (www.freetype.org) is a font engine capable of rendering high-quality font output. It provides a low-level C API and is already used in a number of projects, but I wanted something that works without too much effort together with Qt's Painter framework.
    I guess you are not aware Qt already uses FreeType...

    I'm not really sure what you guys are doing but font rendering in Qt is done using platform means and sometimes poor quality of fonts is caused by wrong settings of libraries responsible for font management/rendering, like FreeType, FontConfig or ClearType. Fonts in Qt apps and fonts on images in Photoshop are almost bound to look different as Photoshop provides a more fine-grained control over the rendering compared to what the system offers for applications. You can write the same text in Photoshop and on your window title bar and they will also look different.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Oct 2010
    Posts
    55
    Thanks
    1
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    9

    Post Re: How to make font Smooth in QT?

    I guess you are not aware Qt already uses FreeType...
    I am aware of this, but my understanding was that this was only supported on platforms that already provide the FreeType library; i.e., X11 and some flavors of Linux.

    Perhaps I have missed something here but I can't find anything in the documentation on how to enable this for Windows/other targets. Based on my tests, using FreeType makes a huge difference on Windows when rendering text in smaller size (see attachment, FreeType on the left with default settings).

    ft.jpg


    Added after 32 minutes:


    Photoshop provides a more fine-grained control over the rendering
    Using FreeType I can have exactly the same control over anti-aliasing, kerning and various typographic properties, obtaining and modifying individual glyphs of a font. I don't see how this is currently possible with Qt. My idea was to wrap this functionality in a high-level API: For example:

    Qt Code:
    1. QFreeTypeEngine *engine = new QFreeTypeEngine(this);
    2. QFreeTypeFont *font = new QFreeTypeEngine("myfont.ttf", engine);
    3.  
    4. QFreeTypeImage img = QFreeTypeImage::fromString("The lorem ipsum", font);
    5. painter.drawImage(30, 70, img);
    To copy to clipboard, switch view to plain text mode 
    Last edited by helloworld; 17th May 2011 at 17:54.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to make font Smooth in QT?

    Quote Originally Posted by helloworld View Post
    I am aware of this, but my understanding was that this was only supported on platforms that already provide the FreeType library; i.e., X11 and some flavors of Linux.
    The point is the implementation is there. No need to rewrite it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Oct 2010
    Posts
    55
    Thanks
    1
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    9

    Default Re: How to make font Smooth in QT?

    I am certainly not going to rewrite FreeType, but assuming I want the rendering quality that you see on the left side of my screenshot (256 gray-level anti-aliasing, rather than the normal 5-level Windows algorithm) without linking my (Qt) application against FreeType or any other third-party library. How would I achieve that on Windows?

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to make font Smooth in QT?

    If you want to use freetype then you will certainly need to link your application against it. My point is you don't need to manually wrap freetype calls into Qt API because it has already been done. By the way, I don't know why your default fonts look so bad on Windows. We don't experience such problems with our apps.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Oct 2010
    Posts
    55
    Thanks
    1
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    9

    Default Re: How to make font Smooth in QT?

    What am I missing here? I can't find anything in the docs about using FreeType under Windows, only how to access the FT_Face handle from QFont (on supported platforms). All I find on Google besides this post is the following:

    http://lists.trolltech.com/qt-intere...ad00445-0.html

    Almost right, freetypeFace is limited to X11 and QWS systems as those are the ones where Qt uses FreeType to render fonts. On Windows it naturally uses the native API for rendering fonts
    http://developer.qt.nokia.com/forums/viewthread/1916

    Features can be switchen on by configure. But freetype can only be switched on for Symbian or Qt Embedded.
    Btw, quality is not THAT bad, but there is definitely a difference between native Windows font rendering and what you see in a graphics application like Photoshop.

  11. #11
    Join Date
    Sep 2007
    Posts
    21
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to make font Smooth in QT?

    I have the same "problem". In the image below you can see the differences between my android device and qt app using font "Clockopia".
    Last edited by Kostanev; 21st April 2012 at 08:36.

Similar Threads

  1. Font Height and width based on font size
    By Ghufran in forum Qt Programming
    Replies: 1
    Last Post: 31st July 2010, 08:02
  2. Get a smooth curve
    By beekeep in forum Qwt
    Replies: 2
    Last Post: 7th January 2010, 17:49
  3. Change Font of QListWidget to Monospace Font
    By pospiech in forum Qt Programming
    Replies: 3
    Last Post: 25th July 2008, 18:23
  4. font incorrectly show - font break.
    By sgh in forum Qt Programming
    Replies: 9
    Last Post: 30th May 2008, 02:35
  5. setMask (smooth)
    By pakulo in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2007, 08:51

Tags for this Thread

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.