cpbotha / nvpy

Simplenote syncing note-taking application, inspired by Notational Velocity and ResophNotes, but uglier and cross-platformerer.
Other
846 stars 114 forks source link

HiDPI in Linux #141

Open bk opened 7 years ago

bk commented 7 years ago

On my Debian stretch system with a HiDPI monitor, nvPY v0.9.7 comes up with tiny fonts in menus and other visible interface elements. Message text in dialogue boxes has normal size, but the font size of buttons inside the dialogue boxes is tiny as well.

cpbotha commented 7 years ago

Very strange. Could you post a screenshot?

I'm using nvpy on 2560x1440 monitors in Linux and it all works perfectly. Could you give me steps to reproduce the issue?

bk commented 7 years ago

screenshot_20161202_090535

I expected interface elements such as menus and status line to match the size of the font in the window title. As you can see from the screenshot, this is not the case.

I am currently using KDE Plasma 5.8, but have seen the same issue under XFCE and Gnome (on the same computer). My screen is a Dell P2815Q (3840x2160).

It should be said that am not using "standard" 2:1 HiDPI scaling. In KDE, for instance, I have set window scaling to 1.5 and font DPI to 144. In Gnome I used a xrandr-based scaling method to get a resolution suiting my tastes. In XFCE I used the font DPI setting along with a custom theme. Most programs work well with all three methods.

cpbotha commented 7 years ago

I assume you're happy with the font and font size in your notes list and editor window: Those are configurable following https://github.com/cpbotha/nvpy#making-nvpy-slightly-less-ugly-on-linux

With regard to the font size in the controls vs the fonts in your titlebar: I had a quick look, it's probably not going to be straight-forward to fix.

I can change the scaling of non-default fonts: http://stackoverflow.com/questions/34132203/scaling-of-tkinter-python-tk-gui-in-4k-38402160-resolution -- this will only help us partially.

A better solution would be to change the code so that ALL controls use custom fonts, and then make the custom font scaling configurable. At least users will be able to tweak their nvpy until it looks right on their displays. See: http://stackoverflow.com/questions/4072150/how-to-change-a-widgets-font-style-without-knowing-the-widgets-font-family-siz/4073037#4073037

In the bit of nvpy time I am able to chew off from other projects, I first need to focus on the sqlite backend (SPEED!). Let's keep this issue here for later, or until someone else steps up to the task.

bk commented 7 years ago

It seems inefficient that any tkinter program must solve such issues on its own. Is there no way to globally change the defaults for tkinter (or Tk more generally) via configuration files or themes?

cpbotha commented 7 years ago

I have not been able to find such an approach. If you do, please let me know!

bk commented 7 years ago

I found such a way, though it is not very clean. I simply changed the file /usr/share/tcltk/tk8.6/ttk/fonts.tcl on my system:

--- fonts.tcl.bk        2016-12-02 10:40:58.313926142 +0000
+++ fonts.tcl   2016-12-02 10:44:23.591285739 +0000
@@ -131,10 +131,10 @@
            set F(family) "Helvetica"
            set F(fixed)  "courier"
        }
-       set F(size) -12
-       set F(ttsize) -10
-       set F(capsize) -14
-       set F(fixedsize) -12
+       set F(size) 10
+       set F(ttsize) 9
+       set F(capsize) 12
+       set F(fixedsize) 10

        font configure TkDefaultFont -family $F(family) -size $F(size)
        font configure TkTextFont    -family $F(family) -size $F(size)

It seems that the defaults for X are given in pixels (negative numbers) rather than points (positive numbers), which is the root of the problem.