Bigger X11 Cursors suitable for 4k screens

8,359

Solution 1

First off you don't need to remove, or prevent updates to, the old cursor.pcf file.

Next if your system already has the cursor.pfa properly installed in any existing fonts directory that your system is already using (i.e. it has a valid fonts.dir file and is already in the server font path), then you don't need to install any new files.

If you do need to install cursor.pfa, you can do so in any directory, including in a sub-directory of your home directory (as long as it's on the same system as where you run the Xserver, and is accessible by the Xserver process).

So once the scalable cursor font is somewhere in your font path you can put an alias for the cursor font name in any fonts.alias file on your system, including one in a new sub-directory of your home directory.

Lastly you need to include the real resolution of your screen in the alias specification! This isn't critical, but it is helpful as it means your choice of cursor font point size will bear a meaningful relationship to the physical size of the pointer you see on your screen -- i.e. a 12pt cursor font will generate cursor pointers that appear to be 12 points tall on your screen!

I'm currently using Xquartz (on macOS of course) in full-screen mode with full display resolution with a 32-inch display (i.e. I start Xquartz by running xrandr -s 6016x3384. The cursor.pfa file is already installed by Xquartz and already mentioned in the existing fonts.dir file in the directory where it is installed, and can already be found by xlsfonts. Of course cursor.pcf is also already installed.

I happen to have a ~/.fonts directory where I've installed some other fonts I've downloaded, so I simply created fonts.alias file there as follows. Here you see I've chosen an 18pt cursor font for a screen with a pixel resolution of 218 pixels per inch:

$ cat .fonts/fonts.alias                                                                                                 
cursor -xfree86-cursor-medium-r-normal--0-180-218-218-p-0-adobe-fontspecific

My font path already includes this directory so I need only rehash my font path to test:

$ xset q | sed -n /Font/,+1p   
Font Path:
  /Users/woods/.fonts/,/opt/X11/share/fonts/TTF/,/opt/X11/share/fonts/OTF/,/opt/X11/share/fonts/Type1/,/Library/Fonts/,/opt/X11/share/fonts/100dpi/:unscaled,/opt/X11/share/fonts/misc/:unscaled
$ fc-cache -r
$ xset fp rehash

Now both the bitmap and scalable "cursor" fonts are available, but the scalable one is first:

$ xlsfonts -Cl -fn cursor
DIR  MIN  MAX EXIST DFLT PROP ASC DESC NAME
-->    0  255  some    0   29  26   28 -xfree86-cursor-medium-r-normal--0-180-218-218-p-0-adobe-fontspecific
-->    0  153   all    0    9  16   17 cursor

Finally you need the following in your ~/.xinitrc (after your font path is reset) to reset the root-window cursor (as the Xserver will have started with the original tiny bitmap cursor):

xsetroot -cursor_name left_ptr

You can run that xsetroot command right away and move the cursor over the root window to see the effect. If you start any new program it will use the new scaled cursor(s) too. You'll need to restart your window manager and all running programs to have them take on the new scaled cursors, so it's easiest to logout and login again.

Interestingly due to the weird magic of macOS, I now have over-sized cursors back in the macOS world.

Solution 2

Although the recipe provided by dirkt does work, the resulting scaled bitmap cursors look ugly. There is a way to make X use the Type 1 cursor font instead, rescaling it appropriately.

The default X cursor font exists both as a bitmap font (file cursor.pcf.gz) and as a Type 1 font (file cursor.pfa). The recipe provided below makes the bitmap font unavailable to the system and turns the font name cursor into an alias for the appropriately rescaled Type 1 font (via the fonts.alias file).

  1. Uninstall the package that contains the file /usr/share/fonts/misc/cursor.pcf.gz (could be named cursor-misc, fonts-misc, or something similar), or simply delete this file and disable upgrades to this package, so that this bitmap font is unavailable to the X server. Run mkfontdir /usr/share/fonts/misc to remove the bitmap font from the font directory.

  2. Make sure that the package that contains the file /usr/share/fonts/Type1/cursor.pfa (could be named xfree86-type1, fonts-type1, or something similar) is installed.

  3. Create the file /usr/share/fonts/Type1/fonts.alias with the following contents, adjusting 801 to the desired cursor size.

    cursor -xfree86-cursor-medium-r-normal--0-801-0-0-p-0-adobe-fontspecific
    
  4. Run fc-cache -r and xset fp rehash to make the Type 1 font available to the system.

Solution 3

Have a look at http://gnome-look.org and find a cursor that has 48x48 or 64x64 pixels. Edit .Xresources

Xcursor.theme: Name
Xcursor.size: Size

extract the cursor archive to ~/.icons/.

Then run xrdb -load .Xresources but maybe a restart of X is required to complete. Depends on your WM.

Solution 4

One way to do it is to replace the standard font files of X that contain the cursor shapes with larger versions. For this, get the font source file cursor.bdf, enlarge it with bdfresize, and then either manually configure applications/the WM/the root window to use this font, or replace the old font files.

For details, see e.g. here.


In fvwm, you can also use CursorStyle to set up the desired font glyphs or even images. I haven't tried this, but I think this won't work with X applications that change the cursor themselves.

Share:
8,359

Related videos on Youtube

Thangamani J
Author by

Thangamani J

Good afternoon, gentlemen. I am a HAL 9000 computer. I became operational at the H.A.L. plant in Urbana, Illinois on the 12th of January 1992. My instructor was Mr. Langley, and he taught me to sing a song. If you'd like to hear it I can sing it for you.

Updated on September 18, 2022

Comments

  • Thangamani J
    Thangamani J over 1 year

    The default X11 cursors are quite tiny when the display is a 4k screen. How can I use bigger cursors? Requirements:

    • Must work under plain X11 (no KDE, Gnome or similar bloat)
    • Should have at least a bigger root window cursor, i.e "arrow"
    • Should work on FreeBSD

    I have looked at the Xcursor(3) manual page which talks about the ~/.icons directory but I am unsure which files to place there and how to activate them. I have a bunch of directories on the system, such as

    /usr/local/share/icons/oxygen/64x64
    /usr/local/share/icons/oxygen/64x64/categories
    /usr/local/share/icons/oxygen/64x64/apps
    /usr/local/share/icons/oxygen/64x64/devices
    /usr/local/share/icons/oxygen/64x64/emotes
    /usr/local/share/icons/oxygen/64x64/mimetypes
    /usr/local/share/icons/oxygen/64x64/emblems
    /usr/local/share/icons/oxygen/64x64/actions
    /usr/local/share/icons/oxygen/64x64/places
    /usr/local/share/icons/oxygen/64x64/status
    /usr/local/share/icons/oxygen/48x48
    /usr/local/share/icons/oxygen/48x48/emotes
    /usr/local/share/icons/oxygen/48x48/devices
    /usr/local/share/icons/oxygen/48x48/apps
    /usr/local/share/icons/oxygen/48x48/mimetypes
    /usr/local/share/icons/oxygen/48x48/status
    /usr/local/share/icons/oxygen/48x48/emblems
    /usr/local/share/icons/oxygen/48x48/actions
    /usr/local/share/icons/oxygen/48x48/places
    /usr/local/share/icons/oxygen/48x48/categories
    /usr/local/share/icons/oxygen/48x48/animations
    

    each of which containing a large number of icons as *.png files.

  • Dmitri Pavlov
    Dmitri Pavlov over 4 years
    It is also possible to rescale the Type 1 X cursor font, which eliminates bitmap scaling artifacts. See my answer.
  • Thangamani J
    Thangamani J about 2 years
    Thanks Greg for the in-depth explanation and guide. This is what I use now, since the cursors are properly scaled up. My display is 150dpi, and I use cursor -xfree86-cursor-medium-r-normal--0-240-150-150-p-0-adobe-fon‌​tspecific in $HOME/.fonts/fonts.alias.