8

RStudio is great IDE for R development. I wonder if there is any way for nice support HiDPI resolution?
I currently have 13 inch display and 3200x1800 resolution, it is even hard to read RStudio options to adjust more appropriate setting.
This is of course not an RStudio issue but general issue related to high resolution display which requires HiDPI support to make it reasonably usable.
Posting it here as question because RStudio still doesn't allow to fill questions/issues on github.

3
  • Why it's have to be on GH? What's wrong with their current support? I've got replies there in the past... Commented Jun 14, 2015 at 10:31
  • To make it most accessible, easier to find and traceable in terms of commit-feature. But I agree this is a vendor decision.
    – jangorecki
    Commented Jun 14, 2015 at 10:36
  • Current workaround may be to setup a constant zoom to 150%-200% in global options - appearance menu.
    – jangorecki
    Commented Jun 14, 2015 at 22:18

3 Answers 3

12

RStudio is a Qt application. I've solved this by setting a scaling factor in Qt with this environment variable (note it must be an integer):

export QT_DEVICE_PIXEL_RATIO=2

The Arch wiki has some excellent advice on getting HiDPI working.

4
  • 1
    Note that this might not work on all desktop environments. An alternative that worked for me on GNOME is to launch RStudio with a custom QT_SCALE_FACTOR environment variable. You can make this the default by editing the following line of usr/share/applications/rstudio.desktop: "Exec=env QT_SCALE_FACTOR=0.75 /usr/bin/rstudio-bin %F". (The 0.75 scaling here is just what worked well on my system.)
    – Grant
    Commented Oct 18, 2019 at 22:54
  • This answer should be improved by explaining how to do what it suggests doing. The current description is extremely cursory and inaccessible to anyone who is not extremely informed.
    – randy
    Commented Jun 22, 2022 at 22:17
  • @randy you could try e.g. QT_DEVICE_PIXEL_RATIO=2 rstudio in your console. There are of course a dozen ways to set an environment variable and I think explaining all that is beyond the scope of this question. The answer describes it as an "environment variable" and I think that's enough to help people search for more information themselves.
    – RobinGower
    Commented Jun 23, 2022 at 8:20
  • I see your point, but I still think there are multiple difficult concepts a user would need to go learn about before using this answer. I, for instance, have no idea what setting QT_DEVICE_PIXEL_RATIO=2 actually does and so do not know whether using the recommended code would cause problems in other Qt applications (and, thus, whether I need to instead set this variable just for RStudio). Nor do I have any way of knowing which integers would be helpful. Also, my previous comment sounds rude. Sorry for being an internet person.
    – randy
    Commented Jun 23, 2022 at 20:26
9

UPDATE: This solution is only for WINDOWS!

There is a simple solution for you, it comes from the option "Compatibility" of the execute file.

  1. Close all current RStudio windows.
  2. Right click on the shortcut of RStudio (or the original exe file) and choose Properties
  3. In the RStudio Properties pop-up windows, choose the tab Compatibility
  4. Tick on option Override hide DPI scaling... and then choose System from the drop-down list.
  5. Apply > OK.
  6. (Re)open Rstudio to see the change

Note that, on the HiDPI screen, resolution of modified RStudio is not so good but it really solved the bad scale problem.

You can also apply this technique to other apps without supporting HiDPI.

3
  • I don't have exe files in my open source OS.
    – jangorecki
    Commented Apr 16, 2018 at 15:07
  • 2
    @jangorecki: it's only for Windows users, I have just updated my answer. Commented Apr 17, 2018 at 10:08
  • 1
    Still applicable two years later. But still resolution is unsatisfactory, in my case for both screens. Happy to know about this workaround. Thanks.
    – Diego-MX
    Commented Oct 15, 2020 at 18:10
2

I use the following bash script to determine the current screen resolution and substitute the scaling factor by 1 (normal resolution) or 1.75 (high resolution) in the RStudio desktop file:

#!/bin/bash

# Determine resolution
width=$(xdpyinfo | grep 'dimensions:' | grep -o -E '[0-9]+' | head -1 | sed -e 's/^0\+//')

echo "Screen width is $width pixels"

if [ $width -gt 3000 ]; then
        echo "High resolution detected -> setting zoom level to 1.75"
        sed -i 's/view.zoomLevel.*/view.zoomLevel=1.75/' ~/.config/RStudio/desktop.ini
else
        echo "Normal resolution detected -> setting zoom level to 1.0"
        sed -i 's/view.zoomLevel.*/view.zoomLevel=1/' ~/.config/RStudio/desktop.ini
fi

QT_QPA_PLATFORMTHEME=gtk2 /usr/lib/rstudio/bin/rstudio %F

I am on Ubuntu 17.10. If I want to use the GTK theme, I have to set the QT_QPA_PLATFORMTHEME environment variable.

1
  • What does "substitute the scaling factor by 1" mean? How would I know what number to use? How does this help?
    – randy
    Commented Jun 22, 2022 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.