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?
Forum Updated to NodeBB v4.3 + New Features

Disable Sub-Pixel-Antialiasing for Text component?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 2.8k Views 1 Watching
  • 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.
  • GPBetaG Offline
    GPBetaG Offline
    GPBeta
    wrote on 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 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
      • GPBetaG Offline
        GPBetaG Offline
        GPBeta
        wrote on 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
        • GPBetaG Offline
          GPBetaG Offline
          GPBeta
          wrote on 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