NO

Author Topic: Blurry font  (Read 2317 times)

Offline kejster

  • Member
  • *
  • Posts: 9
Blurry font
« on: August 01, 2021, 06:44:19 pm »
Hi all.

Just downloaded Pelle's C today, and used the wizard to create the application that just outputs "Hello, Windows!".
However, the text looks very blurry in both the window, the menu, and the about-dialog (but not in the window-title).

I assume that it's some kind of high-DPI issue, since I am running it on my laptop-monitor that runs at 125% scale in Windows-settings.

Best regards.
Kenneth.

Offline kejster

  • Member
  • *
  • Posts: 9
Re: Blurry font
« Reply #1 on: August 01, 2021, 07:00:18 pm »
If I call the function SetProcessDPIAware(), the text looks better.
But the documentation mentions that I should use a manifest, instead of calling the function...
Guess I am getting closer to solving it...

Best regards.
Kenneth.

Offline John Z

  • Member
  • *
  • Posts: 533
Re: Blurry font
« Reply #2 on: August 01, 2021, 09:49:16 pm »
Hi Kenneth,

Not sure what is happening. Always good to include a screen shot and use Pelles zip to include the project files.  I run my HP laptop at 125 too and don’t see this. Can you provide more details including your system and OS particulars? 

John Z
« Last Edit: August 01, 2021, 09:58:29 pm by John Z »

Offline MrBcx

  • Global Moderator
  • Member
  • *****
  • Posts: 113
    • Bcx Basic to C/C++ Translator
Re: Blurry font
« Reply #3 on: August 02, 2021, 01:03:25 am »
If I call the function SetProcessDPIAware(), the text looks better.
But the documentation mentions that I should use a manifest, instead of calling the function...
Guess I am getting closer to solving it...

Best regards.
Kenneth.

Hi Kenneth,

I place the manifest below into a .res and routinely assign a resource id of 1 to it.

I attach that .res to everything I compile.  It mostly overcomes the
scaling blurriness that can occur, especially when you change the default
DPI for one or more monitors.  There are better ways but likely not
easier ways.  This section does the magic:

<asmv3:application>
    <asmv3:windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
     <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
   </asmv3:windowsSettings>
  </asmv3:application>

Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
  <assemblyIdentity version="1.0.0.0"
         processorArchitecture="*"
         name="Made With A Computer"
         type="win32"/>
  <description>DPI Awareness</description>
  <asmv3:application>
    <asmv3:windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
    </asmv3:windowsSettings>
  </asmv3:application>
  <!-- Compatibility section -->
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!--The ID below indicates application support for Windows Vista -->
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
      <!--The ID below indicates application support for Windows 7 -->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
      <!--This Id value indicates the application supports Windows 8 functionality-->
      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
      <!--This Id value indicates the application supports Windows 8.1 functionality-->
      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
      <!--This Id value indicates the application supports Windows 10 functionality-->
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
    </application>
  </compatibility>
  <!-- Trustinfo section -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
                  level="asInvoker"
                  uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
               type="win32"
               name="Microsoft.Windows.Common-Controls"
               version="6.0.0.0"
               processorArchitecture="*"
               publicKeyToken="6595b64144ccf1df"
               language="*" />
    </dependentAssembly>
  </dependency>
</assembly>
Bcx Basic to C/C++ Translator
https://www.BcxBasicCoders.com

Offline John Z

  • Member
  • *
  • Posts: 533
Re: Blurry font
« Reply #4 on: August 02, 2021, 12:28:17 pm »
Very interesting MrBcx, thanks!

My screen is capable of 3840x2160 but I set it to 2048x1152.  In Windows 10 "Scale and Layout" setup I use 125x.  Under the "Advanced scaling settings" turn on "Let Windows try to fix apps so they're not blurry"
I don't have a dual display though...

With the above settings I've never had this issue.  However I'll sure put this manifest into my toolbox!
I've never used manifest's before and don't know about them.

Thanks very much,

John Z

Offline kejster

  • Member
  • *
  • Posts: 9
Re: Blurry font
« Reply #5 on: August 02, 2021, 12:43:51 pm »
Thanks John Z and MrBcx for the answers.
I will try both suggestions, and see what the difference is.
Probably a good idea to have a manifest anyway.

BR. Kenneth.

Offline MrBcx

  • Global Moderator
  • Member
  • *****
  • Posts: 113
    • Bcx Basic to C/C++ Translator
Re: Blurry font
« Reply #6 on: August 02, 2021, 07:53:34 pm »
Kenneth,

Not knowing your experience level, I've attached main.res with the manifest embedded it.

Tell the linker (polink.exe) to link this along with your object and library files.  That way, the
manifest is built-into your .exe

You are free to rename main.res to whatever turns you on. 

You are also free to add additional resources to it that your program(s) may need.

I have the .res filetype associated with the Pelles IDE, so double clicking on any .res opens
it in Pelles IDE which I believe is the easiest and fastest way to create and edit resource files,
be they .rc scripts or .res binary.

Hope that helps ...
Bcx Basic to C/C++ Translator
https://www.BcxBasicCoders.com

Offline John Z

  • Member
  • *
  • Posts: 533
Re: Blurry font
« Reply #7 on: August 02, 2021, 10:58:14 pm »
Thanks very much MrBcx!  I've grabbed it too.  Always more to learn.

John Z

Offline kejster

  • Member
  • *
  • Posts: 9
Re: Blurry font
« Reply #8 on: August 04, 2021, 05:38:01 pm »
Kenneth,

Not knowing your experience level, I've attached main.res with the manifest embedded it.

Tell the linker (polink.exe) to link this along with your object and library files.  That way, the
manifest is built-into your .exe

You are free to rename main.res to whatever turns you on. 

You are also free to add additional resources to it that your program(s) may need.

I have the .res filetype associated with the Pelles IDE, so double clicking on any .res opens
it in Pelles IDE which I believe is the easiest and fastest way to create and edit resource files,
be they .rc scripts or .res binary.

Hope that helps ...

Thanks, MrBcX.

I guess that my experience level is somewhat limited.

I used to do C programming in the 90s, but then got sidetracked by Delphi, then Java, then .NET and JavaScript.

So I have been doing programming professionally for 25 years, but am only just now returning to C programming.

Mostly because of Casey Muratori's "Handmade hero" videos, which I love.

I have also started collecting and reading some C-books "just for fun".

I plan on doing much more C programming in the near future, but sadly only in my spare time, since we use C# at my employer.

Best regards.
Kenneth.

Offline kejster

  • Member
  • *
  • Posts: 9
Re: Blurry font
« Reply #9 on: August 05, 2021, 08:39:44 am »
I have now tried the manifest, and it works great!
Attached are screenshots of the application running without, and with the manifest.
Funny thing is, on my Windows machine at home, it looks great in both cases, but on my Lenovo at work, it clearly looks better with the manifest.
Also, on the Lenovo, if I start Pelles Process Viewer from the Tools menu, it also looks fuzzy :-)

I will have to investigate the differences in scaling etc. on the two Windows machines, but for now the manifest does exactly what I want, and the text looks good on both machines.

Best regards.
Kenneth.

Offline MrBcx

  • Global Moderator
  • Member
  • *****
  • Posts: 113
    • Bcx Basic to C/C++ Translator
Re: Blurry font
« Reply #10 on: August 06, 2021, 12:00:16 am »
Assuming Windows 10 ...

If your Display Resolution is set to Recommended and Scale and Layout
is set to 100%, you should not be seeing any blurriness. 

To check on those, open SETTINGS | DISPLAY



Bcx Basic to C/C++ Translator
https://www.BcxBasicCoders.com

Offline John Z

  • Member
  • *
  • Posts: 533
Re: Blurry font
« Reply #11 on: August 06, 2021, 02:00:22 pm »
Full disclosure - I wear glasses :)

I could see a difference in your two examples but only because of close scrutiny.  Without the pre-knowledge  I probably would have said no difference …

Assuming Windows 10 ...

If your Display Resolution is set to Recommended and Scale and Layout
is set to 100%, you should not be seeing any blurriness. 

In addition if you use a different resolution than recommended, the scale that is recommended will be different and that should be used to minimize any blurriness.  As mentioned previously my recommended screen setting is 3840x2160 but I set it to 2048x1152, Windows 10 then recommends "Scale and Layout" use 125x.

IMO the bigger purpose of using DPI awareness is so that a drawn 1" box on a screen using 3840x2160 will also be a 1" box on a 2048x1152 screen or a 1440x900 screen.  This can be especially important if the program does not allow user drag resizing.

John Z