Friday, November 13, 2015

Running i3 under HiDPI display

I recently got a MacbookPro (early 2015) with retina display for work.  I installed a fresh Slackware64-current on to it with rEFInd as the boot loader.  The process was quite smooth, I used a USB boot image then network install (with a thunderbolt gigabyte adapter).  Some devices/functions are not fully functional but usable for me. Console font is using the kernel built in SUN12x22 font with kernel option "fbcon:font=SUN12x22".

Since this laptop has a 2560x1600 on a 13" display, roughly 227DI, my old setting for i3 did not work well, although I already using xft font for status bar display.  After a few search, I found out xorg server always set DPI 96, that is a bad move in my opinion, as it makes previous valid DPI calculation wrong and still wrong for those cases that the calculation do not fit.  And I have to add a line
xrandr --fbmm 286x179
in .xinitrc file in order to let i3 pick up the correct DPI setting.  OK, now the i3 status bar display fine.  The default dmenu I initially installed does not support xft font, so it looks really small.  Luckily there is a dmenu2 which merged the xft patched.  Remove the old dmenu package and install the dmenu2 package, then add the font parameter to the dmenu_run command in i3's config Latest dmenu works with xft font now. Everything works fine.

I have the following settings in my .Xresources file.
Xft.dpi : 227
Xft.antialias: false
Xft.rgba: rgb

URxvt.scrollstyle: xterm
URxvt.background: black
URxvt.foreground: gray
URxvt.preeditType: Root
URxvt.scrollBar_right: true
URxvt.jumpScroll: true
URxvt.perl-ext-common:  tabbed
URxvt.tabbed.tabbar-fg: 2
URxvt.tabbed.tabbar-bg: 0
URxvt.tabbed.tab-fg:    3
URxvt.tabbed.tab-bg:    0
URxvt.termName: rxvt
URxvt.geometry: 83x27
urxvt.font: xft:DejaVuSansMono:size=8

Xpdf*fontList: -adobe-helvetica-bold-r-normal--0-0-0-0-p-0-iso8859-1
Xpdf.initialZoom: 200

Xcursor.size: 64

With the following, the width should be $((11*COLUMNS+13)) pixels;
! in contrast, the fixed = 6x13 bitmap font is typically used on a
! low-definition screen, giving a width of $((6*COLUMNS+13)) pixels.
XTerm*faceName:  Monospace
XTerm*faceSize:  10
! For xterm menus. This font is large enough, but a bit ugly.
XTerm*font:  -adobe-helvetica-bold-r-normal--0-0-0-0-p-0-iso8859-1
My default terminal is rxvt-unicode, so it works fine. You may notice I have turn antialias off, the font looks sharp, you may see zigzag when looking really close, but for 227DPI, it's very clear without it already.  Most of the document on line regarding GTK+3's HiDPI support is by setting
export GDK_SCALE=2
export GDK_DPI_SCALE=05
I found the program behave a little strange when this kind of scaling in effect.  Font is a little blur than none scale one. For the Gnat Programing Studio (GPS), with the scaling effect, the menu display strangely:
compare with the one without scaling:
I am not sure whether its GTK3' fault or GPS's fault.  I would hope for a GDK_IMAGE_SCALE and only scale image, maybe that will work better.


P.S. After upgrade to kernel 4.4, all the special keys (fn+Fx) works as expected (with pommed-light)