    {-# LINE 2 "./Graphics/Rendering/Pango/Cairo.chs" #-}
    -- -*-haskell-*-
    -- GIMP Toolkit (GTK) Cair Pango integration
    --
    -- Author : Duncan Coutts, Axel Simon
    --
    -- Created: 17 August 2005
    --
    -- Copyright (C) 2005 Duncan Coutts
    --
    -- This library is free software; you can redistribute it and/or
    -- modify it under the terms of the GNU Lesser General Public
    -- License as published by the Free Software Foundation; either
    -- version 2.1 of the License, or (at your option) any later version.
    --
    -- This library is distributed in the hope that it will be useful,
    -- but WITHOUT ANY WARRANTY; without even the implied warranty of
    -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    -- Lesser General Public License for more details.
    --
    -- |
    -- Maintainer : gtk2hs-users@lists.sourceforge.net
    -- Stability : provisional
    -- Portability : portable (depends on GHC)
    --
    --
    -- Pango specific functions for redering with Cairo.
    --
    -- Cairo is a graphics library that supports vector graphics and image
    -- compositing that can be used with Pango. The functions in this module provide
    -- ways of rendering text in Cairo using Pango.
    --
    module Graphics.Rendering.Pango.Cairo (
      -- * Global Cairo settings.
      cairoFontMapGetDefault,
      cairoFontMapSetResolution,
      cairoFontMapGetResolution,
      cairoCreateContext,
      cairoContextSetResolution,
      cairoContextGetResolution,
      cairoContextSetFontOptions,
      cairoContextGetFontOptions,
      -- * Functions for the 'Render' monad.
      setSourceColor,
      updateContext,
      createLayout,
      updateLayout,
      showGlyphString,
      showLayoutLine,
      showLayout,
      glyphStringPath,
      layoutLinePath,
      layoutPath
      ) where

    import Control.Exception (bracket)

    import System.Glib.FFI
    import System.Glib.UTFString
    import System.Glib.GObject (wrapNewGObject, makeNewGObject,
      objectRef, objectUnref)
    import Graphics.Rendering.Pango.Types
    {-# LINE 63 "./Graphics/Rendering/Pango/Cairo.chs" #-}
    import Graphics.Rendering.Pango.BasicTypes
    {-# LINE 64 "./Graphics/Rendering/Pango/Cairo.chs" #-}
    import Graphics.Rendering.Pango.Structs ( pangoItemGetFont, Color(..) )
    import Graphics.Rendering.Pango.Layout ( layoutSetText )
    import Data.IORef

    import Graphics.Rendering.Cairo.Types as Cairo
    import qualified Graphics.Rendering.Cairo.Internal as Cairo.Internal
    import qualified Graphics.Rendering.Cairo as Cairo
    import Graphics.Rendering.Cairo.Internal (Render(Render))
    import Control.Monad.Reader
    import Control.Monad (liftM)

    {-# LINE 76 "./Graphics/Rendering/Pango/Cairo.chs" #-}

    --------------------
    -- Methods

    -- | Sets the specified 'Color' as the source color of the 'Render' context.
    --
    setSourceColor :: Color -> Render ()
    setSourceColor :: Color -> Render ()
    setSourceColor (Color Word16
    red Word16
    green Word16
    blue) =
      Double -> Double -> Double -> Render ()
    Cairo.setSourceRGB
        (Word16 -> Double
    forall a b. (Real a, Fractional b) => a -> b
    realToFrac Word16
    red Double -> Double -> Double
    forall a. Fractional a => a -> a -> a
    / Double
    65535.0)
        (Word16 -> Double
    forall a b. (Real a, Fractional b) => a -> b
    realToFrac Word16
    green Double -> Double -> Double
    forall a. Fractional a => a -> a -> a
    / Double
    65535.0)
        (Word16 -> Double
    forall a b. (Real a, Fractional b) => a -> b
    realToFrac Word16
    blue Double -> Double -> Double
    forall a. Fractional a => a -> a -> a
    / Double
    65535.0)

    -- cairo_font_map_new cannot be bound due to incorrect memory management
    -- in functions like font_map_list_families that create new structures
    -- that store the font map without referencing them

    -- | Retrieve the default 'Graphics.Rendering.Pango.FontMap' that contains a
    -- list of available fonts.
    --
    -- * One purpose of creating an explicit
    -- 'Graphics.Rendering.Pango.Font.FontMap' is to set
    -- a different scaling factor between font sizes (in points, pt) and
    -- Cairo units (in pixels). The default is 96dpi (dots per inch) which
    -- corresponds to an average screen as output medium. A 10pt font will
    -- therefore scale to
    -- @10pt * (1\/72 pt\/inch) * (96 pixel\/inch) = 13.3 pixel@.
    --
    cairoFontMapGetDefault :: IO FontMap
    cairoFontMapGetDefault :: IO FontMap
    cairoFontMapGetDefault =
      (ForeignPtr FontMap -> FontMap, FinalizerPtr FontMap)
    -> IO (Ptr FontMap) -> IO FontMap
    forall obj.
    GObjectClass obj =>
    (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
    makeNewGObject (ForeignPtr FontMap -> FontMap, FinalizerPtr FontMap)
    forall {a}. (ForeignPtr FontMap -> FontMap, FinalizerPtr a)
    mkFontMap (IO (Ptr FontMap) -> IO FontMap) -> IO (Ptr FontMap) -> IO FontMap
    forall a b. (a -> b) -> a -> b
    $ IO (Ptr FontMap)
    pango_cairo_font_map_get_default
    {-# LINE 107 "./Graphics/Rendering/Pango/Cairo.chs" #-}

    -- | Set the scaling factor between font size and Cairo units.
    --
    -- * Value is in dots per inch (dpi). See 'cairoFontMapGetDefault'.
    --
    cairoFontMapSetResolution :: FontMap -> Double -> IO ()
    cairoFontMapSetResolution :: FontMap -> Double -> IO ()
    cairoFontMapSetResolution (FontMap ForeignPtr FontMap
    fm) Double
    dpi =
      ForeignPtr FontMap -> (Ptr FontMap -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr FontMap
    fm ((Ptr FontMap -> IO ()) -> IO ())
    -> (Ptr FontMap -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr FontMap
    fmPtr ->
      Ptr () -> CDouble -> IO ()
    pango_cairo_font_map_set_resolution
    {-# LINE 116 "./Graphics/Rendering/Pango/Cairo.chs" #-}
        (castPtr fmPtr) (Double -> CDouble
    forall a b. (Real a, Fractional b) => a -> b
    realToFrac Double
    dpi)

    -- | Ask for the scaling factor between font size and Cairo units.
    --
    -- * Value is in dots per inch (dpi). See 'cairoFontMapGetDefault'.
    --
    cairoFontMapGetResolution :: FontMap -> IO Double
    cairoFontMapGetResolution :: FontMap -> IO Double
    cairoFontMapGetResolution (FontMap ForeignPtr FontMap
    fm) = (CDouble -> Double) -> IO CDouble -> IO Double
    forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
    liftM CDouble -> Double
    forall a b. (Real a, Fractional b) => a -> b
    realToFrac (IO CDouble -> IO Double) -> IO CDouble -> IO Double
    forall a b. (a -> b) -> a -> b
    $
      ForeignPtr FontMap -> (Ptr FontMap -> IO CDouble) -> IO CDouble
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr FontMap
    fm ((Ptr FontMap -> IO CDouble) -> IO CDouble)
    -> (Ptr FontMap -> IO CDouble) -> IO CDouble
    forall a b. (a -> b) -> a -> b
    $ \Ptr FontMap
    fmPtr ->
      Ptr () -> IO CDouble
    pango_cairo_font_map_get_resolution (Ptr FontMap -> Ptr ()
    forall a b. Ptr a -> Ptr b
    castPtr Ptr FontMap
    fmPtr)

    -- | Create a 'PangoContext'.
    --
    -- * If no 'FontMap' is specified, it uses the default 'FontMap' that
    -- has a scaling factor of 96 dpi. See 'cairoFontMapGetDefault'.
    --
    cairoCreateContext :: Maybe FontMap -> IO PangoContext
    cairoCreateContext :: Maybe FontMap -> IO PangoContext
    cairoCreateContext (Just (FontMap ForeignPtr FontMap
    fm)) = (ForeignPtr PangoContext -> PangoContext,
     FinalizerPtr PangoContext)
    -> IO (Ptr PangoContext) -> IO PangoContext
    forall obj.
    GObjectClass obj =>
    (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
    wrapNewGObject (ForeignPtr PangoContext -> PangoContext,
     FinalizerPtr PangoContext)
    forall {a}.
    (ForeignPtr PangoContext -> PangoContext, FinalizerPtr a)
    mkPangoContext (IO (Ptr PangoContext) -> IO PangoContext)
    -> IO (Ptr PangoContext) -> IO PangoContext
    forall a b. (a -> b) -> a -> b
    $
      ForeignPtr FontMap
    -> (Ptr FontMap -> IO (Ptr PangoContext)) -> IO (Ptr PangoContext)
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr FontMap
    fm ((Ptr FontMap -> IO (Ptr PangoContext)) -> IO (Ptr PangoContext))
    -> (Ptr FontMap -> IO (Ptr PangoContext)) -> IO (Ptr PangoContext)
    forall a b. (a -> b) -> a -> b
    $ \Ptr FontMap
    fmPtr -> -- PangoCairoFontMap /= PangoFontMap
      Ptr () -> IO (Ptr PangoContext)
    pango_cairo_font_map_create_context (Ptr FontMap -> Ptr ()
    forall a b. Ptr a -> Ptr b
    castPtr Ptr FontMap
    fmPtr)
    cairoCreateContext Maybe FontMap
    Nothing = do
      fmPtr <- IO (Ptr FontMap)
    pango_cairo_font_map_get_default
    {-# LINE 138 "./Graphics/Rendering/Pango/Cairo.chs" #-}
      wrapNewGObject mkPangoContext $
        pango_cairo_font_map_create_context (castPtr fmPtr)

    -- | Set the scaling factor of the 'PangoContext'.
    --
    -- * Supplying zero or a negative value will result in the resolution value
    -- of the underlying 'FontMap' to be used. See also 'cairoFontMapGetDefault'.
    --
    cairoContextSetResolution :: PangoContext -> Double -> IO ()
    cairoContextSetResolution :: PangoContext -> Double -> IO ()
    cairoContextSetResolution PangoContext
    pc Double
    dpi =
      (\(PangoContext ForeignPtr PangoContext
    arg1) CDouble
    arg2 -> ForeignPtr PangoContext -> (Ptr PangoContext -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr PangoContext
    arg1 ((Ptr PangoContext -> IO ()) -> IO ())
    -> (Ptr PangoContext -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr PangoContext
    argPtr1 ->Ptr PangoContext -> CDouble -> IO ()
    pango_cairo_context_set_resolution Ptr PangoContext
    argPtr1 CDouble
    arg2) PangoContext
    pc (Double -> CDouble
    forall a b. (Real a, Fractional b) => a -> b
    realToFrac Double
    dpi)

    -- | Ask for the scaling factor of the 'PangoContext'.
    --
    -- * A negative value will be returned if no resolution has been set.
    -- See 'cairoContextSetResolution'.
    --
    cairoContextGetResolution :: PangoContext -> IO Double
    cairoContextGetResolution :: PangoContext -> IO Double
    cairoContextGetResolution PangoContext
    pc = (CDouble -> Double) -> IO CDouble -> IO Double
    forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
    liftM CDouble -> Double
    forall a b. (Real a, Fractional b) => a -> b
    realToFrac (IO CDouble -> IO Double) -> IO CDouble -> IO Double
    forall a b. (a -> b) -> a -> b
    $
      (\(PangoContext ForeignPtr PangoContext
    arg1) -> ForeignPtr PangoContext
    -> (Ptr PangoContext -> IO CDouble) -> IO CDouble
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr PangoContext
    arg1 ((Ptr PangoContext -> IO CDouble) -> IO CDouble)
    -> (Ptr PangoContext -> IO CDouble) -> IO CDouble
    forall a b. (a -> b) -> a -> b
    $ \Ptr PangoContext
    argPtr1 ->Ptr PangoContext -> IO CDouble
    pango_cairo_context_get_resolution Ptr PangoContext
    argPtr1) PangoContext
    pc

    -- | Set Cairo font options.
    --
    -- * Apply the given font options to the context. Values set through this
    -- functions override those that are set by 'updateContext'.
    --
    cairoContextSetFontOptions :: PangoContext -> FontOptions -> IO ()
    cairoContextSetFontOptions :: PangoContext -> FontOptions -> IO ()
    cairoContextSetFontOptions PangoContext
    pc FontOptions
    fo =
      (\(PangoContext ForeignPtr PangoContext
    arg1) (FontOptions ForeignPtr FontOptions
    arg2) -> ForeignPtr PangoContext -> (Ptr PangoContext -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr PangoContext
    arg1 ((Ptr PangoContext -> IO ()) -> IO ())
    -> (Ptr PangoContext -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr PangoContext
    argPtr1 ->ForeignPtr FontOptions -> (Ptr FontOptions -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr FontOptions
    arg2 ((Ptr FontOptions -> IO ()) -> IO ())
    -> (Ptr FontOptions -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr FontOptions
    argPtr2 ->Ptr PangoContext -> Ptr FontOptions -> IO ()
    pango_cairo_context_set_font_options Ptr PangoContext
    argPtr1 Ptr FontOptions
    argPtr2) PangoContext
    pc FontOptions
    fo

    -- | Reset Cairo font options.
    --
    cairoContextResetFontOptions :: PangoContext -> IO ()
    cairoContextResetFontOptions :: PangoContext -> IO ()
    cairoContextResetFontOptions PangoContext
    pc =
      (\(PangoContext ForeignPtr PangoContext
    arg1) (FontOptions ForeignPtr FontOptions
    arg2) -> ForeignPtr PangoContext -> (Ptr PangoContext -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr PangoContext
    arg1 ((Ptr PangoContext -> IO ()) -> IO ())
    -> (Ptr PangoContext -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr PangoContext
    argPtr1 ->ForeignPtr FontOptions -> (Ptr FontOptions -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr FontOptions
    arg2 ((Ptr FontOptions -> IO ()) -> IO ())
    -> (Ptr FontOptions -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr FontOptions
    argPtr2 ->Ptr PangoContext -> Ptr FontOptions -> IO ()
    pango_cairo_context_set_font_options Ptr PangoContext
    argPtr1 Ptr FontOptions
    argPtr2) PangoContext
    pc
        (ForeignPtr FontOptions -> FontOptions
    Cairo.Internal.FontOptions ForeignPtr FontOptions
    forall a. ForeignPtr a
    nullForeignPtr)

    -- | Retrieve Cairo font options.
    --
    cairoContextGetFontOptions :: PangoContext -> IO FontOptions
    cairoContextGetFontOptions :: PangoContext -> IO FontOptions
    cairoContextGetFontOptions PangoContext
    pc = do
      foPtr <- (\(PangoContext ForeignPtr PangoContext
    arg1) -> ForeignPtr PangoContext
    -> (Ptr PangoContext -> IO (Ptr FontOptions))
    -> IO (Ptr FontOptions)
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr PangoContext
    arg1 ((Ptr PangoContext -> IO (Ptr FontOptions))
     -> IO (Ptr FontOptions))
    -> (Ptr PangoContext -> IO (Ptr FontOptions))
    -> IO (Ptr FontOptions)
    forall a b. (a -> b) -> a -> b
    $ \Ptr PangoContext
    argPtr1 ->Ptr PangoContext -> IO (Ptr FontOptions)
    pango_cairo_context_get_font_options Ptr PangoContext
    argPtr1) PangoContext
    pc
      Cairo.Internal.mkFontOptions foPtr

    -- | Update a 'PangoContext' with respect to changes in a 'Render'
    -- environment.
    --
    -- * The 'PangoContext' must have been created with
    -- 'cairoCreateContext'. Any 'PangoLayout's that have been
    -- previously created with this context have to be update using
    -- 'Graphics.Rendering.Pango.Layout.layoutContextChanged'.
    --
    updateContext :: PangoContext -> Render ()
    updateContext :: PangoContext -> Render ()
    updateContext PangoContext
    pc = ReaderT Cairo IO () -> Render ()
    forall m. ReaderT Cairo IO m -> Render m
    Render (ReaderT Cairo IO () -> Render ())
    -> ReaderT Cairo IO () -> Render ()
    forall a b. (a -> b) -> a -> b
    $ do
      cr <- ReaderT Cairo IO Cairo
    forall r (m :: * -> *). MonadReader r m => m r
    ask
      liftIO $ (\(Cairo Ptr Cairo
    arg1) (PangoContext ForeignPtr PangoContext
    arg2) -> ForeignPtr PangoContext -> (Ptr PangoContext -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr PangoContext
    arg2 ((Ptr PangoContext -> IO ()) -> IO ())
    -> (Ptr PangoContext -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr PangoContext
    argPtr2 ->Ptr Cairo -> Ptr PangoContext -> IO ()
    pango_cairo_update_context Ptr Cairo
    arg1 Ptr PangoContext
    argPtr2) cr pc

    -- | Create a 'PangoLayout' within a 'Render' context.
    --
    -- * This is a convenience function that creates a new 'PangoContext'
    -- within this 'Render' context and creates a new 'PangoLayout'.
    -- If the transformation or target surface of the 'Render' context
    -- change, 'updateLayout' has to be called on this layout.
    --
    createLayout :: GlibString string => string -> Render PangoLayout
    createLayout :: forall string. GlibString string => string -> Render PangoLayout
    createLayout string
    text = ReaderT Cairo IO PangoLayout -> Render PangoLayout
    forall m. ReaderT Cairo IO m -> Render m
    Render (ReaderT Cairo IO PangoLayout -> Render PangoLayout)
    -> ReaderT Cairo IO PangoLayout -> Render PangoLayout
    forall a b. (a -> b) -> a -> b
    $ do
      cr <- ReaderT Cairo IO Cairo
    forall r (m :: * -> *). MonadReader r m => m r
    ask
      liftIO $ do
        layRaw <- wrapNewGObject mkPangoLayoutRaw $
                  (\(Cairo Ptr Cairo
    arg1) -> Ptr Cairo -> IO (Ptr PangoLayoutRaw)
    pango_cairo_create_layout Ptr Cairo
    arg1) cr
        textRef <- newIORef undefined
        let pl = (IORef PangoString -> PangoLayoutRaw -> PangoLayout
    PangoLayout IORef PangoString
    textRef PangoLayoutRaw
    layRaw)
        layoutSetText pl text
        return pl

    -- | Propagate changed to the 'Render' context to a 'PangoLayout'.
    --
    -- * This is a convenience function that calls 'updateContext' on the
    -- (private) 'PangoContext' of the given layout to propagate changes
    -- from the 'Render' context to the 'PangoContext' and then calls
    -- 'Graphics.Rendering.Pango.Layout.layoutContextChanged' on the layout.
    -- This function is necessary for
    -- 'createLayout' since a private 'PangoContext' is created that is
    -- not visible to the user.
    --
    updateLayout :: PangoLayout -> Render ()
    updateLayout :: PangoLayout -> Render ()
    updateLayout (PangoLayout IORef PangoString
    _ PangoLayoutRaw
    lay) = ReaderT Cairo IO () -> Render ()
    forall m. ReaderT Cairo IO m -> Render m
    Render (ReaderT Cairo IO () -> Render ())
    -> ReaderT Cairo IO () -> Render ()
    forall a b. (a -> b) -> a -> b
    $ do
      cr <- ReaderT Cairo IO Cairo
    forall r (m :: * -> *). MonadReader r m => m r
    ask
      liftIO $ (\(Cairo Ptr Cairo
    arg1) (PangoLayoutRaw ForeignPtr PangoLayoutRaw
    arg2) -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr PangoLayoutRaw
    arg2 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
    -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr PangoLayoutRaw
    argPtr2 ->Ptr Cairo -> Ptr PangoLayoutRaw -> IO ()
    pango_cairo_update_layout Ptr Cairo
    arg1 Ptr PangoLayoutRaw
    argPtr2) cr lay

    -- | Draw a glyph string.
    --
    -- * The origin of the glyphs (the left edge of the baseline) will be drawn
    -- at the current point of the cairo context.
    --
    showGlyphString :: GlyphItem -> Render ()
    showGlyphString :: GlyphItem -> Render ()
    showGlyphString (GlyphItem PangoItem
    pi GlyphStringRaw
    gs) = ReaderT Cairo IO () -> Render ()
    forall m. ReaderT Cairo IO m -> Render m
    Render (ReaderT Cairo IO () -> Render ())
    -> ReaderT Cairo IO () -> Render ()
    forall a b. (a -> b) -> a -> b
    $ do
      cr <- ReaderT Cairo IO Cairo
    forall r (m :: * -> *). MonadReader r m => m r
    ask
      font <- liftIO $ pangoItemGetFont pi
      liftIO $ (\(Cairo Ptr Cairo
    arg1) (Font ForeignPtr Font
    arg2) (GlyphStringRaw ForeignPtr GlyphStringRaw
    arg3) -> ForeignPtr Font -> (Ptr Font -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr Font
    arg2 ((Ptr Font -> IO ()) -> IO ()) -> (Ptr Font -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr Font
    argPtr2 ->ForeignPtr GlyphStringRaw -> (Ptr GlyphStringRaw -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr GlyphStringRaw
    arg3 ((Ptr GlyphStringRaw -> IO ()) -> IO ())
    -> (Ptr GlyphStringRaw -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr GlyphStringRaw
    argPtr3 ->Ptr Cairo -> Ptr Font -> Ptr GlyphStringRaw -> IO ()
    pango_cairo_show_glyph_string Ptr Cairo
    arg1 Ptr Font
    argPtr2 Ptr GlyphStringRaw
    argPtr3) cr font gs

    -- | Draw a 'LayoutLine'.
    --
    -- * The origin of the glyphs (the left edge of the baseline) will be drawn
    -- at the current point of the cairo context.
    --
    showLayoutLine :: LayoutLine -> Render ()
    showLayoutLine :: LayoutLine -> Render ()
    showLayoutLine (LayoutLine IORef PangoString
    _ LayoutLineRaw
    ll) = ReaderT Cairo IO () -> Render ()
    forall m. ReaderT Cairo IO m -> Render m
    Render (ReaderT Cairo IO () -> Render ())
    -> ReaderT Cairo IO () -> Render ()
    forall a b. (a -> b) -> a -> b
    $ do
      cr <- ReaderT Cairo IO Cairo
    forall r (m :: * -> *). MonadReader r m => m r
    ask
      liftIO $ (\(Cairo Ptr Cairo
    arg1) (LayoutLineRaw ForeignPtr LayoutLineRaw
    arg2) -> ForeignPtr LayoutLineRaw -> (Ptr LayoutLineRaw -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr LayoutLineRaw
    arg2 ((Ptr LayoutLineRaw -> IO ()) -> IO ())
    -> (Ptr LayoutLineRaw -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr LayoutLineRaw
    argPtr2 ->Ptr Cairo -> Ptr LayoutLineRaw -> IO ()
    pango_cairo_show_layout_line Ptr Cairo
    arg1 Ptr LayoutLineRaw
    argPtr2) cr ll

    -- | Draw a 'PangoLayout'.
    --
    -- * The top-left corner of the 'PangoLayout' will be drawn at the current
    -- point of the cairo context.
    --
    showLayout :: PangoLayout -> Render ()
    showLayout :: PangoLayout -> Render ()
    showLayout (PangoLayout IORef PangoString
    _ PangoLayoutRaw
    lay) = ReaderT Cairo IO () -> Render ()
    forall m. ReaderT Cairo IO m -> Render m
    Render (ReaderT Cairo IO () -> Render ())
    -> ReaderT Cairo IO () -> Render ()
    forall a b. (a -> b) -> a -> b
    $ do
      cr <- ReaderT Cairo IO Cairo
    forall r (m :: * -> *). MonadReader r m => m r
    ask
      liftIO $ (\(Cairo Ptr Cairo
    arg1) (PangoLayoutRaw ForeignPtr PangoLayoutRaw
    arg2) -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr PangoLayoutRaw
    arg2 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
    -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr PangoLayoutRaw
    argPtr2 ->Ptr Cairo -> Ptr PangoLayoutRaw -> IO ()
    pango_cairo_show_layout Ptr Cairo
    arg1 Ptr PangoLayoutRaw
    argPtr2) cr lay

    -- | Add the extent of a glyph string to the current path.
    --
    -- * The origin of the glyphs (the left edge of the line) will be at the
    -- current point of the cairo context.
    --
    glyphStringPath :: GlyphItem -> Render ()
    glyphStringPath :: GlyphItem -> Render ()
    glyphStringPath (GlyphItem PangoItem
    pi GlyphStringRaw
    gs) = ReaderT Cairo IO () -> Render ()
    forall m. ReaderT Cairo IO m -> Render m
    Render (ReaderT Cairo IO () -> Render ())
    -> ReaderT Cairo IO () -> Render ()
    forall a b. (a -> b) -> a -> b
    $ do
      cr <- ReaderT Cairo IO Cairo
    forall r (m :: * -> *). MonadReader r m => m r
    ask
      font <- liftIO $ pangoItemGetFont pi
      liftIO $ (\(Cairo Ptr Cairo
    arg1) (Font ForeignPtr Font
    arg2) (GlyphStringRaw ForeignPtr GlyphStringRaw
    arg3) -> ForeignPtr Font -> (Ptr Font -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr Font
    arg2 ((Ptr Font -> IO ()) -> IO ()) -> (Ptr Font -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr Font
    argPtr2 ->ForeignPtr GlyphStringRaw -> (Ptr GlyphStringRaw -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr GlyphStringRaw
    arg3 ((Ptr GlyphStringRaw -> IO ()) -> IO ())
    -> (Ptr GlyphStringRaw -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr GlyphStringRaw
    argPtr3 ->Ptr Cairo -> Ptr Font -> Ptr GlyphStringRaw -> IO ()
    pango_cairo_glyph_string_path Ptr Cairo
    arg1 Ptr Font
    argPtr2 Ptr GlyphStringRaw
    argPtr3) cr font gs

    -- | Add the extent of a layout line to the current path.
    --
    -- * The origin of the glyphs (the left edge of the line) will be at the
    -- current point of the cairo context.
    --
    layoutLinePath :: LayoutLine -> Render ()
    layoutLinePath :: LayoutLine -> Render ()
    layoutLinePath (LayoutLine IORef PangoString
    _ LayoutLineRaw
    ll) = ReaderT Cairo IO () -> Render ()
    forall m. ReaderT Cairo IO m -> Render m
    Render (ReaderT Cairo IO () -> Render ())
    -> ReaderT Cairo IO () -> Render ()
    forall a b. (a -> b) -> a -> b
    $ do
      cr <- ReaderT Cairo IO Cairo
    forall r (m :: * -> *). MonadReader r m => m r
    ask
      liftIO $ (\(Cairo Ptr Cairo
    arg1) (LayoutLineRaw ForeignPtr LayoutLineRaw
    arg2) -> ForeignPtr LayoutLineRaw -> (Ptr LayoutLineRaw -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr LayoutLineRaw
    arg2 ((Ptr LayoutLineRaw -> IO ()) -> IO ())
    -> (Ptr LayoutLineRaw -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr LayoutLineRaw
    argPtr2 ->Ptr Cairo -> Ptr LayoutLineRaw -> IO ()
    pango_cairo_layout_line_path Ptr Cairo
    arg1 Ptr LayoutLineRaw
    argPtr2) cr ll

    -- | Add the layout to the current path.
    --
    -- * Adds the top-left corner of the text to the current path. Afterwards,
    -- the path position is at the bottom-right corner of the 'PangoLayout'.
    --
    layoutPath :: PangoLayout -> Render ()
    layoutPath :: PangoLayout -> Render ()
    layoutPath (PangoLayout IORef PangoString
    _ PangoLayoutRaw
    lay) = ReaderT Cairo IO () -> Render ()
    forall m. ReaderT Cairo IO m -> Render m
    Render (ReaderT Cairo IO () -> Render ())
    -> ReaderT Cairo IO () -> Render ()
    forall a b. (a -> b) -> a -> b
    $ do
      cr <- ReaderT Cairo IO Cairo
    forall r (m :: * -> *). MonadReader r m => m r
    ask
      liftIO $ (\(Cairo Ptr Cairo
    arg1) (PangoLayoutRaw ForeignPtr PangoLayoutRaw
    arg2) -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr PangoLayoutRaw
    arg2 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
    -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr PangoLayoutRaw
    argPtr2 ->Ptr Cairo -> Ptr PangoLayoutRaw -> IO ()
    pango_cairo_layout_path Ptr Cairo
    arg1 Ptr PangoLayoutRaw
    argPtr2) cr lay

    foreign import ccall unsafe "pango_cairo_font_map_get_default"
      pango_cairo_font_map_get_default :: (IO (Ptr FontMap))

    foreign import ccall unsafe "pango_cairo_font_map_set_resolution"
      pango_cairo_font_map_set_resolution :: ((Ptr ()) -> (CDouble -> (IO ())))

    foreign import ccall unsafe "pango_cairo_font_map_get_resolution"
      pango_cairo_font_map_get_resolution :: ((Ptr ()) -> (IO CDouble))

    foreign import ccall unsafe "pango_cairo_font_map_create_context"
      pango_cairo_font_map_create_context :: ((Ptr ()) -> (IO (Ptr PangoContext)))

    foreign import ccall unsafe "pango_cairo_context_set_resolution"
      pango_cairo_context_set_resolution :: ((Ptr PangoContext) -> (CDouble -> (IO ())))

    foreign import ccall unsafe "pango_cairo_context_get_resolution"
      pango_cairo_context_get_resolution :: ((Ptr PangoContext) -> (IO CDouble))

    foreign import ccall unsafe "pango_cairo_context_set_font_options"
      pango_cairo_context_set_font_options :: ((Ptr PangoContext) -> ((Ptr FontOptions) -> (IO ())))

    foreign import ccall unsafe "pango_cairo_context_get_font_options"
      pango_cairo_context_get_font_options :: ((Ptr PangoContext) -> (IO (Ptr FontOptions)))

    foreign import ccall unsafe "pango_cairo_update_context"
      pango_cairo_update_context :: ((Ptr Cairo) -> ((Ptr PangoContext) -> (IO ())))

    foreign import ccall unsafe "pango_cairo_create_layout"
      pango_cairo_create_layout :: ((Ptr Cairo) -> (IO (Ptr PangoLayoutRaw)))

    foreign import ccall unsafe "pango_cairo_update_layout"
      pango_cairo_update_layout :: ((Ptr Cairo) -> ((Ptr PangoLayoutRaw) -> (IO ())))

    foreign import ccall unsafe "pango_cairo_show_glyph_string"
      pango_cairo_show_glyph_string :: ((Ptr Cairo) -> ((Ptr Font) -> ((Ptr GlyphStringRaw) -> (IO ()))))

    foreign import ccall unsafe "pango_cairo_show_layout_line"
      pango_cairo_show_layout_line :: ((Ptr Cairo) -> ((Ptr LayoutLineRaw) -> (IO ())))

    foreign import ccall unsafe "pango_cairo_show_layout"
      pango_cairo_show_layout :: ((Ptr Cairo) -> ((Ptr PangoLayoutRaw) -> (IO ())))

    foreign import ccall unsafe "pango_cairo_glyph_string_path"
      pango_cairo_glyph_string_path :: ((Ptr Cairo) -> ((Ptr Font) -> ((Ptr GlyphStringRaw) -> (IO ()))))

    foreign import ccall unsafe "pango_cairo_layout_line_path"
      pango_cairo_layout_line_path :: ((Ptr Cairo) -> ((Ptr LayoutLineRaw) -> (IO ())))

    foreign import ccall unsafe "pango_cairo_layout_path"
      pango_cairo_layout_path :: ((Ptr Cairo) -> ((Ptr PangoLayoutRaw) -> (IO ())))