pharo-project / pharo

Pharo is a dynamic reflective pure object-oriented language supporting live programming inspired by Smalltalk.
http://pharo.org
Other
1.19k stars 351 forks source link

Fonts are blurry under high resolution screen #10656

Closed VincentBlondeau closed 1 month ago

VincentBlondeau commented 2 years ago

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:

Expected development cost High

Additional context Lifeware tagged

astares commented 2 years ago

@VincentBlondeau / @tesonep / @guillep

Yes - we had a solution originally:

Later it got reverted through

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.

sonibla commented 2 years ago

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

svenvc commented 2 years ago

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

Ducasse commented 2 years ago

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.

sonibla commented 2 years ago

@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

fmqa commented 2 years ago

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

Ducasse commented 2 years ago

We should really push the HPDI....

uchuugaka commented 1 year ago

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

Ducasse commented 1 year ago

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.

uchuugaka commented 1 year ago

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).

Ducasse commented 1 year ago

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

uchuugaka commented 1 year ago

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?

Ducasse commented 1 year ago

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 commented 1 year ago

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

Ducasse commented 1 year ago

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

uchuugaka commented 1 year ago

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.

Ducasse commented 1 year ago

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.

PierreLouisPAUGAM commented 1 year ago

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 ?

hernandp commented 9 months ago

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

Ducasse commented 9 months ago

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:

-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 commented 9 months ago

Form-scene-graph

You can also check the code of

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
GitHub - carolahp/form-scene-graph: A Gtk Scene Graph inspired rendering framework for Pharo
A Gtk Scene Graph inspired rendering framework for Pharo - GitHub - carolahp/form-scene-graph: A Gtk Scene Graph inspired rendering framework for Pharo
GitHub
GitHub - desromech/form-scene-graph: A Gtk Scene Graph inspired rendering framework for Pharo
A Gtk Scene Graph inspired rendering framework for Pharo - GitHub - desromech/form-scene-graph: A Gtk Scene Graph inspired rendering framework for Pharo
Rinzwind commented 9 months ago

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 commented 4 months ago

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!

ccfontes commented 4 months ago

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

Pharo - Download
Rinzwind commented 4 months ago

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.

ccfontes commented 4 months ago

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. 💯

macta commented 3 months ago

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