SVG Cursors

From Inkscape Wiki
Revision as of 09:26, 20 October 2020 by Tavmjong (talk | contribs) (Created page with " <div style="width:80ch"> =A Primer to SVG Cursors= ==Introduction== Inkscape 1.1 uses SVG cursors, replacing the previously used bitmaps. This allows more detailed cursors...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A Primer to SVG Cursors

Introduction

Inkscape 1.1 uses SVG cursors, replacing the previously used bitmaps. This allows more detailed cursors that scale better on HiDPI screens.[1][2] The supplied default cursors can be overridden via the normal GTK theming mechanism.

GTK does not directly support SVG cursors. We render cursors at the scale needed ourselves and then enable them via the existing GTK method for adding custom bitmap cursors. This also allows us to change some of the cursor colors to match, for example, the currently selected fill and stroke colors.

Creating SVG Cursors

Any SVG file can work as a cursor, but keeping a few things in mind will probably lead to better results.

  1. The default GTK cursor size is 32x32 pixels.
  2. Keep vertical and horizontal lines on the grid (which means snapping lines to the half pixel).
  3. By default, the hot spot (the point in the cursor that is active) is located at the upper left corner. This can be moved by specifying the custom attributes inkscape:hotspot_x and inkscape:hotspot_y in the SVG root element.
  4. The shape tools show the current fill and stroke colors in the cursor while the Dropper tool shows the color that will be dropped or picked in the cursor. This is done by overwriting the fill and stroke properties in the root SVG element. Any child elements with undefined fill and stroke properties will then inherit these colors following the normal CSS cascade rules.

Using SVG Cursors

The easiest way to use your new cursors is to drop them in your local (user) inkscape/icon/hicolor/cursor directory. Inkscape will search there first before using the default cursors installed with Inkscape. You can also put them in the cursor directory in another theme but then you must explicitly select that theme, either system wide or in Inkscape. Note, not all themes include a cursor directory so you may need to create it.

[1] Due to GTK issues, cursors on OSX do not currently benefit from better scaling.
[2] With GTK's experimental fractional scaling, cursors are rendered too large at scaling above 1.