rdmenezes / cefpython

Automatically exported from code.google.com/p/cefpython
1 stars 0 forks source link

Text size (DPI) issues on Windows #112

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When the text size (DPI) on Windows is set to Medium (125%) or Larger (150%), 
it will also enlarge the text size in the following examples:

example.py (pywin32)
wxpython.py
pygtk_.py

Though, the text looks fuzzy.

Is there a way to disable the automatic enlarging of texts in CEF browser 
windows? It would definitely give better results if the DPI setting was 
detected manually, and then Browser.`SetZoomLevel()` was called to enlarge 
text. The text fonts wouldn't look fuzzy then.

In the following examples, the text size is not enlarged automatically, thus on 
high resolutions everything is so small:

pyqt.py
pyside.py

Investigate the Qt API whether there is some function to use the system DPI 
setting for the embedded window.

Original issue reported on code.google.com by czarek.t...@gmail.com on 18 Jan 2014 at 12:12

GoogleCodeExporter commented 9 years ago
The Browser.`SetZoomLevel()` method should probably be called in 
LifespanHandler.`OnAfterCreated()` (callback not yet ported to cefpython) or in 
LoadHandler.`OnLoadStart()`.

Original comment by czarek.t...@gmail.com on 18 Jan 2014 at 12:14

GoogleCodeExporter commented 9 years ago
On Windows application can embed a DPI aware manifest in the executable, to let 
know OS that it will handle DPI resizing itself. The manifest looks like this:

  <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
    <asmv3:application>
      <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
        <dpiAware>true</dpiAware>
      </asmv3:windowsSettings>
    </asmv3:application>
  </assembly>

Is there a way to programmatically tell the OS that app will handle the DPI 
sizing itself? So that SetZoomLevel can be used which gives better non-fuzzy 
fonts?

Regarding where should SetZoomLevel() be called. The zoom level needs to be 
checked constantly, as it is required to set it again when the url changes to a 
different domain. And when url changes a new renderer process is handling the 
new site. Calling SetZoomLevel() in `OnLoadStart` or `OnAfterCreated` does not 
work. It needs to be called during loading of a page or after it is loaded. 
Calling it after all content was loaded does not give good UI experience, as 
the whole page kind of "jumps" when resizing the content. An interval timer 
should be used. This can be accomplished by using the CefPostDelayedTask() 
function. For an example see the SetBrowserDpiSettings() function in the PHP 
Desktop project:

https://code.google.com/p/phpdesktop/source/browse/phpdesktop-chrome/dpi_aware.c
pp?r=a09cf1528699

Original comment by czarek.t...@gmail.com on 27 Jan 2014 at 3:52

GoogleCodeExporter commented 9 years ago
If patch from the issue below gets accepted then it might be easier to 
implement zooming by using the zoom handler:
https://code.google.com/p/chromiumembedded/issues/detail?id=1314

Original comment by czarek.t...@gmail.com on 14 Jun 2014 at 5:58

GoogleCodeExporter commented 9 years ago
In branch 1650 and earlier there is the --high-dpi-support switch available. 
Does it affect zooming, or is this dpi support for the controls outside the 
browser view? And does it work with CEF? 

That switch was removed in branch 1750 or later, see:
https://groups.google.com/a/chromium.org/d/topic/chromium-dev/U_K1NHuMLic/discus
sion

Original comment by czarek.t...@gmail.com on 14 Jun 2014 at 9:41

GoogleCodeExporter commented 9 years ago
Branch 1750 is supposed to support high DPI natively without the need for 
zooming. Including the dpiAware manifest or calling SetProcessDPIAware (Vista 
or later) should be enough. See:
http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=11948

Original comment by czarek.t...@gmail.com on 15 Jul 2014 at 5:53

GoogleCodeExporter commented 9 years ago

Original comment by czarek.t...@gmail.com on 29 Jul 2014 at 3:32

GoogleCodeExporter commented 9 years ago
The --high-dpi-support flag started working only after applying a patch to CEF 
sources. See the BuildOnWindows wiki page.

That flag was removed in Chromium revision r256811 (probably branch 1750). So 
when we upgrade to a newer CEF we will need to work on a new patch (and 
probably use the old functions from dpi.cc).

See dpi.cc in branch 1650. EnableHighDPISupport calls win32 function 
SetProcessDPIAware.
http://src.chromium.org/viewvc/chrome/trunk/src/ui/gfx/win/dpi.cc?revision=24164
1

In later revisions the DPI awareness is set through Windows Registry, see:
http://src.chromium.org/viewvc/chrome/trunk/src/ui/gfx/win/dpi.cc?revision=25681
1&pathrev=256811

On how to enable High DPI support see the CommandLineSwitches wiki page.

Original comment by czarek.t...@gmail.com on 8 Aug 2014 at 4:22

GoogleCodeExporter commented 9 years ago
There were some problems with Chrome UI on Win 8.1 when calling 
SetProcessDPIAware. On MSDN [1] you can find that out that this function is not 
reliable, thus it's better to set dpi awareness by embedding a manifest in 
executable, or by using Windows registry.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms633543(v=vs.85).aspx

Original comment by czarek.t...@gmail.com on 8 Aug 2014 at 4:29

GoogleCodeExporter commented 9 years ago
Fixed in revision a07c898cb1df.

See the ApplicationSettings.`auto_zooming` option and the DpiAware wiki page. 
Example usage is in the wxpython.py example.

Original comment by czarek.t...@gmail.com on 9 Aug 2014 at 4:22