Copyright | (c) 2015 Diagrams-cairo team (see LICENSE) |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | diagrams-discuss@googlegroups.com |
Safe Haskell | None |
Language | Haskell2010 |
This module provides convenience functions for querying information
from cairo. In particular, this provides utilities for information
about fonts, and creating text primitives with bounds based on the
font being used. To render text with automatically determined
envelopes, use textLineBounded
, textLineBoundedIO
,
textVisualBounded
, or textVisualBoundedIO
.
Many of these functions take a Style
V2
Double
parameter,
determining the style to apply to the text before rendering /
querying information about the text. These Style
V2
Double
parameters can be created a variety of ways, but the most direct
will likely be by applying style-transforming functions such as
font
, fontSize
, fontSlant
, and fontWeight
to mempty
.
This works because there are instances of HasStyle
and Monoid
for
.Style
v
Documentation
These create diagrams instantiated with extent-based envelopes.
textLineBoundedIO :: Style V2 Double -> Text Double -> IO (Diagram Cairo) Source #
Creates text diagrams with their envelopes set such that using
stacks them in the way that
the font designer intended. Pango refers to this as logical extents.vcat
. map (textLineBounded
style)
textVisualBoundedIO :: Style V2 Double -> Text Double -> IO (Diagram Cairo) Source #
Creates a text diagram with its envelope set to enclose the glyphs of the text, including leading (though not trailing) whitespace.
Utilities
queryCairo :: Render a -> IO a Source #
Executes a cairo action on a dummy, zero-size image surface, in order to query things like font information.
unsafeCairo :: Render a -> a Source #
Unsafely invokes queryCairo
using unsafePerformIO
.