Page 1 of 1

OSR can't change font size after DPI is changed

Posted: Tue Oct 13, 2020 4:22 am
by tad.chen
In OSR Demo program, it hasn't changed font size in web page after monitor DPI is changed.

It does have code to handle DPI changing in FormAfterMonitorDpiChanged function, in which it calls NotifyScreenInfoChanged and WasResized to repaint the web page.

But it has a bug, the value of GlobalCEFApp.DeviceScaleFactor will not be changed! Then, in the following chrmosrGetViewRect event and so on, it still repaints the web page in the way before DPI is changed.

Re: OSR can't change font size after DPI is changed

Posted: Tue Oct 13, 2020 8:37 am
by salvadordf
Please, check that you set GlobalCEFApp.EnableHighDPISupport to true before the GlobalCEFApp.StartMainProcess call in the DPR file.

The value of GlobalCEFApp.DeviceScaleFactor can be updated by calling GlobalCEFApp.UpdateDeviceScaleFactor if your application detects that the monitor DPI value has changed.

Re: OSR can't change font size after DPI is changed

Posted: Tue Oct 13, 2020 2:16 pm
by tad.chen
Yes, GlobalCEFApp.EnableHighDPISupport is set to true.

But, after I add GlobalCEFApp.UpdateDeviceScaleFactor in FormAfterMonitorDpiChanged function, the value of GlobalCEFApp.DeviceScaleFactor is still not changed.

Re: OSR can't change font size after DPI is changed

Posted: Tue Oct 13, 2020 5:22 pm
by salvadordf
Check that the manifest in the application options has "Per monitor" or "Per monitor v2" in the "DPI awareness" box.

Re: OSR can't change font size after DPI is changed

Posted: Tue Oct 13, 2020 11:46 pm
by tad.chen
I checked, It's "PerMonitor".

But, after I change it to "PerMonitorV2", it's the same. GlobalCEFApp.DeviceScaleFactor has no change when monitor DPI is changed.

Re: OSR can't change font size after DPI is changed

Posted: Wed Oct 14, 2020 8:40 am
by salvadordf
Thanks for reporting this issue!

I just tried this issue and I see that the function that reads the current monitor DPI value keeps getting the same value after a DPI change.
I'll fix it as soon as I can.

Re: OSR can't change font size after DPI is changed

Posted: Sat Oct 31, 2020 1:38 pm
by salvadordf
Please, download the latest CEF4Delphi version from GitHub to fix this issue.

Re: OSR can't change font size after DPI is changed

Posted: Tue Nov 03, 2020 1:20 am
by tad.chen
Thank you! I'll test it.

But I now use an old version which support chromium 7X.X.X.X. Is it possible to update it?

Re: OSR can't change font size after DPI is changed

Posted: Tue Nov 03, 2020 7:47 am
by salvadordf
Sorry but I don't keep separate branches for each Chromium version and I can't update old versions.

However, you can easily apply the changes manually. This is the commit with all the changes but you only have to apply 4 of them :
https://github.com/salvadordf/CEF4Delph ... f33f12910e
  • Add the RunningWindows10OrNewer and GetDPIForHandle functions in uCEFMiscFunctions.pas
  • Make UpdateDeviceScaleFactor virtual in uCEFApplicationCore.pas and override it in uCEFApplication.pas
  • Call GlobalCEFApp.UpdateDeviceScaleFactor; inside the TForm.OnAfterMonitorDpiChanged event as you can see in uSimpleOSRBrowser.pas
  • Modify GetScreenScale in uCEFBufferPanel.pas

Re: OSR can't change font size after DPI is changed

Posted: Tue Nov 03, 2020 8:50 am
by tad.chen
OK, I'll try it.

Thank you for your advice.