Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
OSR can't change font size after DPI is changed
OSR can't change font size after DPI is changed
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.
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.
- salvadordf
- Posts: 4086
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: OSR can't change font size after DPI is changed
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.
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
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.
But, after I add GlobalCEFApp.UpdateDeviceScaleFactor in FormAfterMonitorDpiChanged function, the value of GlobalCEFApp.DeviceScaleFactor is still not changed.
- salvadordf
- Posts: 4086
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: OSR can't change font size after DPI is changed
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
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.
But, after I change it to "PerMonitorV2", it's the same. GlobalCEFApp.DeviceScaleFactor has no change when monitor DPI is changed.
- salvadordf
- Posts: 4086
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: OSR can't change font size after DPI is changed
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.
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.
- salvadordf
- Posts: 4086
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: OSR can't change font size after DPI is changed
Please, download the latest CEF4Delphi version from GitHub to fix this issue.
Re: OSR can't change font size after DPI is changed
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?
But I now use an old version which support chromium 7X.X.X.X. Is it possible to update it?
- salvadordf
- Posts: 4086
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: OSR can't change font size after DPI is changed
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
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
OK, I'll try it.
Thank you for your advice.
Thank you for your advice.