Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Disable Sub-Pixel-Antialiasing for Text component?
QtWS25 Last Chance

Disable Sub-Pixel-Antialiasing for Text component?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 2.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GPBeta
    wrote on 30 Nov 2017, 14:52 last edited by
    #1

    Hi, Qt specialists.
    Since the Sub-Pixel-Antialiasing performs bad on some transparent backgrounds especially when rendering small fonts, how could I disable this feature?

    sub-pixel-antialiasing enabled:
    0_1512053037120_3.png
    sub-pixel-antialiasing disabled:
    1_1512053037120_4.png

    I think setting QFont::NoSubpixelAntialias style strategy might help, but it seems that's impossible to do it with a Text component in QML.

    Environment: Windows 10 with Qt 5.9 x64

    Thank you for any ideas.

    \BAKA BAKA/

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on 30 Nov 2017, 17:40 last edited by
      #2

      Hi! Setting renderType to Text.NativeRendering usually yields better results than the default:

      Text { text: "Hello"; renderType: Text.NativeRendering; }
      
      1 Reply Last reply
      3
      • G Offline
        G Offline
        GPBeta
        wrote on 1 Dec 2017, 08:41 last edited by
        #3

        Thanks for your advice, Wieland.
        That doesn't remove the artificial colors completely, but the results now become acceptable.

        Thank you so much!

        \BAKA BAKA/

        1 Reply Last reply
        0
        • G Offline
          G Offline
          GPBeta
          wrote on 21 Dec 2017, 12:37 last edited by
          #4

          Finally, I found that using FreeType as Qt's font engine would get the best result when rendering over transparent background for both large and small font glyphs.
          This could be done using qt.conf:

          [Platforms]
          WindowsArguments = fontengine=freetype
          

          or using command line argument:

          <application> -platform windows:fontengine=freetype
          

          Note that this won't remove artificial colors for sub-pixel-antialiasing, to disable it, add these lines in your Text component:

              style: Text.Outline
              styleColor: "transparent"
          

          \BAKA BAKA/

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved