Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Rendering problems with DirectWrite

Rendering problems with DirectWrite

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++visual-studiocomquestion
12 Posts 3 Posters 7 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.
  • P paul1167

    As a warmup for a more complex project in C#, I have started to code a C++/CLI library to allow simple access of C# applications to features of DirectWrite. (I am aware that there are such helper libraries already out there but I was not able yet to get them to work with in Visual Studio 2015 and with Windows 10.) So far so good. A first test run showed the text in the target window but not as I would have expected for ClearType display. A screenshot of the displayed text can be found here. My understanding of the relating MSDN documentation is that ClearType is enabled by default. The title bar text of the window is obviously set up with text in ClearType. I guess I missed a setting in the DWrite factory but I do not know which. Does anybody have an advice for me?

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #2

    It looks like your coordinates are being calculated incorrectly and you are not leaving enough space between lines of text.

    P 1 Reply Last reply
    0
    • L Lost User

      It looks like your coordinates are being calculated incorrectly and you are not leaving enough space between lines of text.

      P Offline
      P Offline
      paul1167
      wrote on last edited by
      #3

      Thank you for your response. You had indeed a good idea but I am afraid that this is not likely the reason: * You can see from the screenshot, the character 'g' is shown completely where other characters like the adjacent are not shown completely. * The text has been sent to DX as one single block, without the explicit specification of leading. I would assume then that DX selects a sufficient leading. Meanwhile, I have made several more tests with my application but I have not found a way yet to improve the text display. However, I do not give up. ClearType works well on my computer; any application - except mine - is using it successfully. I have collected my little test in a ZIP file which can be loaded from this location. I am currently using Windows 10 and Visual Studio Community 2015.

      L J 3 Replies Last reply
      0
      • P paul1167

        Thank you for your response. You had indeed a good idea but I am afraid that this is not likely the reason: * You can see from the screenshot, the character 'g' is shown completely where other characters like the adjacent are not shown completely. * The text has been sent to DX as one single block, without the explicit specification of leading. I would assume then that DX selects a sufficient leading. Meanwhile, I have made several more tests with my application but I have not found a way yet to improve the text display. However, I do not give up. ClearType works well on my computer; any application - except mine - is using it successfully. I have collected my little test in a ZIP file which can be loaded from this location. I am currently using Windows 10 and Visual Studio Community 2015.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #4

        paul1167 wrote:

        I am afraid that this is not likely the reason

        Well I am no expert in DirectX, but that is certainly what it looks like. I would suggest you take a look at https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/DWriteLineSpacingModes[^] to see how Microsoft does it.

        P 1 Reply Last reply
        0
        • P paul1167

          Thank you for your response. You had indeed a good idea but I am afraid that this is not likely the reason: * You can see from the screenshot, the character 'g' is shown completely where other characters like the adjacent are not shown completely. * The text has been sent to DX as one single block, without the explicit specification of leading. I would assume then that DX selects a sufficient leading. Meanwhile, I have made several more tests with my application but I have not found a way yet to improve the text display. However, I do not give up. ClearType works well on my computer; any application - except mine - is using it successfully. I have collected my little test in a ZIP file which can be loaded from this location. I am currently using Windows 10 and Visual Studio Community 2015.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #5

          I have had a look at your code (I am not able to build it). I wonder if you need to adjust your line spacing based on the actual size of the created font, rather than the requested size.

          1 Reply Last reply
          0
          • P paul1167

            Thank you for your response. You had indeed a good idea but I am afraid that this is not likely the reason: * You can see from the screenshot, the character 'g' is shown completely where other characters like the adjacent are not shown completely. * The text has been sent to DX as one single block, without the explicit specification of leading. I would assume then that DX selects a sufficient leading. Meanwhile, I have made several more tests with my application but I have not found a way yet to improve the text display. However, I do not give up. ClearType works well on my computer; any application - except mine - is using it successfully. I have collected my little test in a ZIP file which can be loaded from this location. I am currently using Windows 10 and Visual Studio Community 2015.

            J Offline
            J Offline
            John Schroedl
            wrote on last edited by
            #6

            I built your project and played with it a bit but was not able to eliminate the issue. I consulted some of our DX code and things are very similar. We do create a DC render target instead of an HWND render target and set the flags to be GDI compatible but everything else looks similar. Our content is hosted within a WPF window so that's another difference. Is this a high-DPI issue by chance? I run at 125% and didn't try your app at 100% (96 dpi). Perhaps some sizes need to be scaled differently. I see that things stretch as the window is resized. So perhaps the drawing is extra compressed which causes the bitmap to be resampled? Sorry I'm not much more help. I certainly feel your pain though. John

            P 2 Replies Last reply
            0
            • J John Schroedl

              I built your project and played with it a bit but was not able to eliminate the issue. I consulted some of our DX code and things are very similar. We do create a DC render target instead of an HWND render target and set the flags to be GDI compatible but everything else looks similar. Our content is hosted within a WPF window so that's another difference. Is this a high-DPI issue by chance? I run at 125% and didn't try your app at 100% (96 dpi). Perhaps some sizes need to be scaled differently. I see that things stretch as the window is resized. So perhaps the drawing is extra compressed which causes the bitmap to be resampled? Sorry I'm not much more help. I certainly feel your pain though. John

              P Offline
              P Offline
              paul1167
              wrote on last edited by
              #7

              I have now tested with several different font sizes. Looks ok at 36pt. Real bad result at 12pt: Even the two lines of text (rendered as one single text block) seem to have different sizes, see screenshot. This is definitively not ClearType. I guess now I missed somewhere to enable ClearType and will give a close look to the sample Richard MacCutchan indicated to me. Stretching of the text block upon resizing of the window is an undesired effect caused by the very simple design of the test, should be done better in a 'real' application.

              1 Reply Last reply
              0
              • J John Schroedl

                I built your project and played with it a bit but was not able to eliminate the issue. I consulted some of our DX code and things are very similar. We do create a DC render target instead of an HWND render target and set the flags to be GDI compatible but everything else looks similar. Our content is hosted within a WPF window so that's another difference. Is this a high-DPI issue by chance? I run at 125% and didn't try your app at 100% (96 dpi). Perhaps some sizes need to be scaled differently. I see that things stretch as the window is resized. So perhaps the drawing is extra compressed which causes the bitmap to be resampled? Sorry I'm not much more help. I certainly feel your pain though. John

                P Offline
                P Offline
                paul1167
                wrote on last edited by
                #8

                I have also tried to switch from 100% to 125% -- same result (25% larger than in previous test, and my desktop got 'reorganized' by Windows). Gone back to 100%

                1 Reply Last reply
                0
                • L Lost User

                  paul1167 wrote:

                  I am afraid that this is not likely the reason

                  Well I am no expert in DirectX, but that is certainly what it looks like. I would suggest you take a look at https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/DWriteLineSpacingModes[^] to see how Microsoft does it.

                  P Offline
                  P Offline
                  paul1167
                  wrote on last edited by
                  #9

                  I had downloaded that example yesterday - It's really HUGE! And - unfortunately - it fails to build. I am receiving error message "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2048,5): error MSB3774: Could not find SDK "Microsoft.VCLibs, Version=14.0".". There are several comments about this issue in the net but only very few solution proposals. I tried one and ran the repair of my Visual Studio but the building problem remained. I will now start to work myself through the code and try to find answers to my specific problem. That will take a while since I do not know if the problem is caused by any System or VS settings or just by my code.

                  L 1 Reply Last reply
                  0
                  • P paul1167

                    I had downloaded that example yesterday - It's really HUGE! And - unfortunately - it fails to build. I am receiving error message "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2048,5): error MSB3774: Could not find SDK "Microsoft.VCLibs, Version=14.0".". There are several comments about this issue in the net but only very few solution proposals. I tried one and ran the repair of my Visual Studio but the building problem remained. I will now start to work myself through the code and try to find answers to my specific problem. That will take a while since I do not know if the problem is caused by any System or VS settings or just by my code.

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #10

                    Some of the members here are quite selective about which forums they visit, and it's quite possible that the people who would maybe know the answer never come here. Your problem has nothing to do with C++/CLI but is about DirectX, so a question in the Graphics forum may catch someone's eye. You could also try a search of the Articles section to see if anyone has written about it.

                    P 1 Reply Last reply
                    0
                    • L Lost User

                      Some of the members here are quite selective about which forums they visit, and it's quite possible that the people who would maybe know the answer never come here. Your problem has nothing to do with C++/CLI but is about DirectX, so a question in the Graphics forum may catch someone's eye. You could also try a search of the Articles section to see if anyone has written about it.

                      P Offline
                      P Offline
                      paul1167
                      wrote on last edited by
                      #11

                      Hi Richard, That is a real good point. You are right: DirectWrite is much more a matter of Graphics. The C++/CLI issues in my problem are secondary. Thank you for this advice.

                      1 Reply Last reply
                      0
                      • P paul1167

                        As a warmup for a more complex project in C#, I have started to code a C++/CLI library to allow simple access of C# applications to features of DirectWrite. (I am aware that there are such helper libraries already out there but I was not able yet to get them to work with in Visual Studio 2015 and with Windows 10.) So far so good. A first test run showed the text in the target window but not as I would have expected for ClearType display. A screenshot of the displayed text can be found here. My understanding of the relating MSDN documentation is that ClearType is enabled by default. The title bar text of the window is obviously set up with text in ClearType. I guess I missed a setting in the DWrite factory but I do not know which. Does anybody have an advice for me?

                        P Offline
                        P Offline
                        paul1167
                        wrote on last edited by
                        #12

                        Meanwhile, I have modified the test to a sole C++ application, and Ido still get the same (non-ClearType like) result. I am reposting this in the Graphics forum.

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups