webview_rust icon indicating copy to clipboard operation
webview_rust copied to clipboard

Fractional / HIDPI support (Windows)

Open Miaourt opened this issue 3 years ago • 0 comments

Follow-up of https://github.com/webview/webview/issues/54

In short, on Windows 10 (maybe 8 and 7, can't check), there is an option to use fractional resolutions for the interface (and all application), meaning that you can pick 100%, 125%, 150% 175%, 200% and so on.

The thing is, fractional pixels doesn't exists, where 100% and 200% are simple to implement since you just have to double the pixel's size (2x2 instead of 1x1), in-between values are more tricky.

Windows seems to rely on two different tricks to support those :

  1. Displaying properly "fractional" pixels using (unknown to me) wizardry .
  2. A fallback that render the software at a "normal" scaling (100%) and then upscale the output to the desired scaling (125%) resulting in blurry renders.

Tauri, per default, is using the 2nd trick, resulting in blurry applications : Screenshot of the issue, with a top Windows which is Firefox displaying the application properly, and Tauri being blurred Screenshot of the issue, with a top window which is Firefox displaying the application properly, and the bottom window a Tauri app being blurred

Steps to reproduce this behaviour:

  1. In the Windows 10's system settings, set the scaling to a fractional one.
  2. Start a Tauri project
  3. Build / Run dev
  4. See the blurriness

Thankfully, thanks to @Ciantic works, it seems to be pretty trivial to fix this issue, here is the solution provided by them : https://github.com/webview/webview/issues/54#issuecomment-667666668

Miaourt avatar Aug 15 '20 14:08 Miaourt