pharo icon indicating copy to clipboard operation
pharo copied to clipboard

Fonts are blurry under high resolution screen

Open VincentBlondeau opened this issue 3 years ago • 27 comments

Bug description Left ok. Right blurry image

The issue appears at the same time than fixing #10319 and likely to be related to #8688.

To Reproduce Steps to reproduce the behavior:

  1. Go to huge screen where the scale of the screen is more than 100%
  2. Open Pharo
  3. See that the font is blurry

Expected behavior No blurry font and scaling correct

Screenshots See above

Version information:

  • OS: Win10
  • Pharo Version Pharo 9.0.0 Build information: Pharo-9.0.0+build.1573.sha.0e09d756fc99383cbb498565200d9e5e9841ce11 (64 Bit)

Expected development cost High

Additional context Lifeware tagged

VincentBlondeau avatar Dec 13 '21 17:12 VincentBlondeau

@VincentBlondeau / @tesonep / @guillep

Yes - we had a solution originally:

  • ISSUE: Pharo 9 looked bad on Windows HiDPI Devices (Microsoft Surface) https://github.com/pharo-project/pharo/issues/9715
  • PR: it was fixed with a PR: https://github.com/pharo-project/pharo/pull/9716

Later it got reverted through

  • ISSUE: OSSDL2BackendWindow>>#fetchDPI seems broken https://github.com/pharo-project/pharo/issues/10319
  • PR: 10319-OSSDL2BackendWindowfetchDPI-seems-broken https://github.com/pharo-project/pharo/pull/10325

If you check the comments in https://github.com/pharo-project/pharo/pull/10325 I already pointed out that new proposed changes this will revert the original fix and @tesonep replied that there will be a setting. I guess this setting is still missing/pending.

astares avatar Dec 13 '21 23:12 astares

By looking quickly it seems Pharo can't support HiDPI because OSWorldRenderer>>actualScreenSize takes into account screen scale, on HiDPI devices it means OSWorldRenderer>>actualScreenSize will return a too low value. For example on my device OSWorldRenderer>>actualScreenSize returns (1920@1138) while the widow size (in pixels displayed on the physical screen) is (3840@2275) Then the too small extent goes to OSWindowFormRenderer, and all the morphs are computed based on this value. It's not that simple to fix it however, modifying OSWorldRenderer>>actualScreenSize to return the correct pixel number will break the mouse position and the scaling From Lifeware side it's already better to have a correct scale but blurry screen (after https://github.com/pharo-project/pharo/pull/10325), than having a too small scale and still a blurry screen after setting a custom scale in Pharo appearance settings (before https://github.com/pharo-project/pharo/pull/10325) The issue is that having a blurry screen is an incentive not to use Pharo

sonibla avatar Dec 23 '21 10:12 sonibla

I also think this is an important and sensitive issue: it gives a really bad first impression.

svenvc avatar Dec 23 '21 10:12 svenvc

May be adapting and providing a specific startup preferences can help. For the HDPI we need at least 6 months of work and we do not have them now.

Ducasse avatar Dec 23 '21 12:12 Ducasse

@VincentBlondeau how did you get the non blurry example on the left of your image?

This is pharo 7, 8, 9, 10, they all look the same for me blurry fonts

sonibla avatar Dec 23 '21 14:12 sonibla

The following patch works for me on 2K/1440p display as well as an older laptop with an 1080p FHD monitor: Not very well-versed in Pharo's code and I don't any Retina display to test with, so YMMV

--- orig/src/OSWindow-Core/OSWorldRenderer.class.st	2022-08-16 21:16:39.763266326 +0200
+++ src/OSWindow-Core/OSWorldRenderer.class.st	2022-08-16 21:20:33.905443917 +0200
@@ -278,7 +278,7 @@
 
 { #category : #'scale factor' }
 OSWorldRenderer >> windowScaleFactor [
-	^ osWindow ifNil: [ 1 ] ifNotNil: [ osWindow screenScaleFactor max: 1 ]
+	^ osWindow ifNil: [ 1 ] ifNotNil: [ osWindow screenScaleFactor min: 1 ]
 ]
 
 { #category : #accessing }

Screenshot

fmqa avatar Aug 16 '22 19:08 fmqa

We should really push the HPDI....

Ducasse avatar Aug 17 '22 04:08 Ducasse

Nothing would make me happier and more willing to give Pharo (or Squeak) a real serious go.

uchuugaka avatar Sep 11 '22 08:09 uchuugaka

Us too. Where can I find the code? Ok seriously this is not because we do not want that Pharo is not in HDPI. First this is a question of resources, second this is a question of resources and third this is a question of speed (because we have a running version but it is slow to move windows and we need to see how to optimise it). So the more the people help for other tasks the more chance we have that we can calmly have a look.

Ducasse avatar Sep 11 '22 08:09 Ducasse

Where in the code needs a look? I can look for macOS, but know nothing about for Windows or Linuxes or BSDs. I suspect the handling will be more or less branching along those lines (if it does not already).

uchuugaka avatar Sep 11 '22 09:09 uchuugaka

No we do not branch :) this is not like an case statement. Now we can ask Pablo and Carolina and you can try the version we have. @tesonep @carolahp

Ducasse avatar Sep 11 '22 10:09 Ducasse

hmm, seems like things rely on SDL2 which is in C and I am sure supports HiDPI for a long time now :) Is Pharo using an FFI to interact with SDL2 calls?

uchuugaka avatar Sep 11 '22 10:09 uchuugaka

Yes Pharo is using SDL2 as back-end. The key point is how to rerender an object trees fast enough so that you can move a window with animations inside and that animations are smooth.

Ducasse avatar Sep 11 '22 10:09 Ducasse

This is just oh let us do a simple FFI call. We are not that stupid.

Ducasse avatar Sep 11 '22 10:09 Ducasse

Let us wait that Pablo and Carolina tell us where the code is.

Ducasse avatar Sep 11 '22 10:09 Ducasse

Makes sense. part of me wonders if the abstraction layering is where some trouble is. Like if it were a true VM, all major OS platforms have hypervisor APIs today… that would streamline a lot be also limit other things and literally be an OS. If the classic SmallTalk image were not used but rather became more of a cross platform API using like Qt or Tk or something similar, it could also be a very powerful thing. but that’s me thinking out loud. Neither of those would be simple and really solve different problems.

uchuugaka avatar Sep 11 '22 11:09 uchuugaka

indeed and doing is often more demanding :) You have to have an execution engine and this is what we are doing. And Pharo should be versatile.

Ducasse avatar Sep 11 '22 12:09 Ducasse

Hello, I tried opening Pharo on a 3840x2160 screen with Windows scaling set to 150% and found out everything was blurry :

Exemple

I don't open a new issue as I think this is related to this one, has a solution been found since then @Ducasse or should I switch to another screen for now ?

PierreLouisPAUGAM avatar Jan 30 '23 14:01 PierreLouisPAUGAM

what is the status of this? I'm using Pharo 11 with 4K display and suffering blurry text.

hernandp avatar Nov 26 '23 03:11 hernandp

We have the same problems. You can check and report two projects Rinzwind and form-scene-graph see below

Rinzwind

You can check the following check @Rinzwind

https://github.com/pharo-project/pharo/pull/15561 parts pasted below

I updated, and made two small improvements to, the ‘Retina display’ scaling experiment from earlier pull requests: commits 1cdeaf1, 0ff236a and 139a5bb (which are not included in this pull request).

If you want to try it out:

  • Create an image in Pharo Launcher using Pharo 12 build 1128 as the template
  • Close the ‘Welcome’ window
  • Repair the repository ‘pharo’ by cloning from GitHub using ‘Rinzwind’ as the ‘Owner name’ and ‘pharo’ as the ‘Project name’
  • Check out the branch ‘scaling-canvas-tryout-14’ from ‘origin’
  • Close the ‘Repositories’ window (its icons will be broken at this point, but just click the usual location of the closing button)
  • Open the extra world by doing OSWorldRendererScalingCanvas example; or, to use ScalingCanvas for drawing the main world:

-Do OSWorldRendererScalingCanvas isApplicable: true, and save and quit the image -Open the image again and do World scaleFactor: 0.5

To revert, do World scaleFactor: 1 and OSWorldRendererScalingCanvas isApplicable: false, then save and reopen the image

Ducasse avatar Nov 26 '23 17:11 Ducasse

Form-scene-graph

You can also check the code of

  • https://github.com/carolahp/form-scene-graph
  • Check the comment of the original forked project https://github.com/desromech/form-scene-graph and report if it is working for you.

So we are concerned about it and the form-scene-graph was already a long effort that we paid with our team money.

Now if people want to put money on the table to change our effort we are all ears open.

GitHub
A Gtk Scene Graph inspired rendering framework for Pharo - GitHub - carolahp/form-scene-graph: A Gtk Scene Graph inspired rendering framework for Pharo
GitHub
A Gtk Scene Graph inspired rendering framework for Pharo - GitHub - desromech/form-scene-graph: A Gtk Scene Graph inspired rendering framework for Pharo

Ducasse avatar Nov 26 '23 17:11 Ducasse

Instead of following the instructions from pull request #15561 pasted above, in the latest Pharo 12 builds, in which pull request #15647 was merged, you can just set the ‘canvas scale factor’ setting:

287102659-d08cb129-9fec-4e70-9c49-e2d17c36459d

Note that I use a MacBook and don’t have a Windows or Linux machine, except virtual ones, so I’m not entirely sure what the effect is on those platforms, but please do try it out!

Rinzwind avatar Dec 04 '23 09:12 Rinzwind

There’s a setting now to let the canvas scale factor be set automatically (since Pharo 12 build 1494):

As mentioned in pull request #16479, it may need some further testing, especially on Windows and Linux, so please do leave some feedback when you’ve given it a try!

Rinzwind avatar Apr 23 '24 18:04 Rinzwind

Trying to find that 1494 build to no avail. Not here yet right?: https://pharo.org/download

ccfontes avatar Apr 28 '24 03:04 ccfontes

If you want to try build 1494 specifically, you can get ‘Pharo12.0-SNAPSHOT.build.1494.sha.6e47d25.arch.64bit.zip’ from the directory ‘120’ within ‘image’ on ‘files.pharo.org’. Later Pharo 12 builds include the setting as well, so you can also just get the latest one through Pharo Launcher using the template ‘Pharo 12.0 - 64bit (stable)’.

The link ‘64bit (default)’ for ‘Pharo image’ in the section ‘Pharo standalone’ on the website’s ‘Download’ page is currently broken, I have opened pharo-website pull request #71 to fix that.

Rinzwind avatar Apr 28 '24 08:04 Rinzwind

Thanks! Also, ended up fetching the image using the New icon in the launcher. Btw, total newbie here. Anyways, font issue is fixed (macOS Sonoma here). Now I can get started with Pharo without my eyes hurting. 💯

ccfontes avatar Apr 28 '24 09:04 ccfontes

Can this be closed now? There is a setting in Pharo 12 under - World renderer canvas scaling - Canvas Scale Factor.

Setting this to 2 on my mac with a retina screen makes it clear (and the same on a large screen).

image

macta avatar May 27 '24 13:05 macta