Package: cairo

Function cairo:hairline

Lambda List

cairo:hairline (cr)

Syntax

(cairo:hairline cr) => setting
(setf (cairo:hairline cr) setting)

Arguments

cr -- a cairo:context-t instance
setting -- a boolean whether hairline mode is set

Details

The cairo:hairline function returns whether or not hairline mode is set within the Cairo context. The (setf cairo:hairline) functon sets lines to be hairlines. Hairlines are logically zero-width lines that are drawn at the thinnest renderable width possible in the current Cairo context.

On surfaces with native hairline support, the native hairline functionality will be used. Surfaces that support hairlines include:
pdf/ps
Encoded as 0-width line.
win32_printing
Rendered with the PS_COSMETIC pen.
svg
Encoded as 1 px non-scaling-stroke.
script
Encoded with the set-hairline function.
Cairo will always render hairlines at 1 device unit wide, even if an anisotropic scaling was applied to the stroke width. In the wild, handling of this situation is not well-defined. Some PDF, PS, and SVG renderers match the output of Cairo, but some very popular implementations (Acrobat, Chrome, rsvg) will scale the hairline unevenly. As such, best practice is to reset any anisotropic scaling before calling the cairo:stroke function. See Ellipses With Uniform Stroke Width for an example.

Since 1.18
 

See also

2025-1-2