-- GENERATED by C->Haskell Compiler, version 0.13.13 (gtk2hs branch) "Bin IO", 27 May 2012 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "./Graphics/Rendering/Cairo/Internal/Drawing/Text.chs" #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Graphics.Rendering.Cairo.Internal.Drawing.Text
-- Copyright   :  (c) Paolo Martini 2005
-- License     :  BSD-style (see cairo/COPYRIGHT)
--
-- Maintainer  :  p.martini@neuralnoise.com
-- Stability   :  experimental
-- Portability :  portable
--
-- Rendering text.
-----------------------------------------------------------------------------

module Graphics.Rendering.Cairo.Internal.Drawing.Text where

import Graphics.Rendering.Cairo.Types
{-# LINE 16 "./Graphics/Rendering/Cairo/Internal/Drawing/Text.chs" #-}

import Graphics.Rendering.Cairo.Internal.Utilities (CairoString(..))

import Foreign
import Foreign.C


{-# LINE 23 "./Graphics/Rendering/Cairo/Internal/Drawing/Text.chs" #-}

selectFontFace :: CairoString string => Cairo -> string -> FontSlant -> FontWeight -> IO ()
selectFontFace c string slant weight =
    withUTFString string $ \string' ->
    (\(Cairo arg1) arg2 arg3 arg4 -> cairo_select_font_face arg1 arg2 arg3 arg4)
{-# LINE 28 "./Graphics/Rendering/Cairo/Internal/Drawing/Text.chs" #-}
        c string' (cFromEnum slant) (cFromEnum weight)

setFontSize :: Cairo -> Double -> IO ()
setFontSize a1 a2 =
  let {a1' = unCairo a1} in 
  let {a2' = cFloatConv a2} in 
  setFontSize'_ a1' a2' >>= \res ->
  return ()
{-# LINE 31 "./Graphics/Rendering/Cairo/Internal/Drawing/Text.chs" #-}
setFontMatrix :: Cairo -> Matrix -> IO ()
setFontMatrix a1 a2 =
  let {a1' = unCairo a1} in 
  with a2 $ \a2' -> 
  setFontMatrix'_ a1' a2' >>= \res ->
  return ()
{-# LINE 32 "./Graphics/Rendering/Cairo/Internal/Drawing/Text.chs" #-}
getFontMatrix :: Cairo -> IO (Matrix)
getFontMatrix a1 =
  let {a1' = unCairo a1} in 
  alloca $ \a2' -> 
  getFontMatrix'_ a1' a2' >>= \res ->
  peek a2'>>= \a2'' -> 
  return (a2'')
{-# LINE 33 "./Graphics/Rendering/Cairo/Internal/Drawing/Text.chs" #-}
setFontOptions :: Cairo -> FontOptions -> IO ()
setFontOptions a1 a2 =
  let {a1' = unCairo a1} in 
  withFontOptions a2 $ \a2' -> 
  setFontOptions'_ a1' a2' >>= \res ->
  return ()
{-# LINE 34 "./Graphics/Rendering/Cairo/Internal/Drawing/Text.chs" #-}

showText :: CairoString string => Cairo -> string -> IO ()
showText c string =
    withUTFString string $ \string' ->
    (\(Cairo arg1) arg2 -> cairo_show_text arg1 arg2)
{-# LINE 39 "./Graphics/Rendering/Cairo/Internal/Drawing/Text.chs" #-}
        c string'

fontExtents :: Cairo -> IO (FontExtents)
fontExtents a1 =
  let {a1' = unCairo a1} in 
  alloca $ \a2' -> 
  fontExtents'_ a1' a2' >>= \res ->
  peek a2'>>= \a2'' -> 
  return (a2'')
{-# LINE 42 "./Graphics/Rendering/Cairo/Internal/Drawing/Text.chs" #-}

textExtents :: CairoString string => Cairo -> string -> IO TextExtents
textExtents c string =
    withUTFString string $ \string' ->
    alloca $ \result -> do
        (\(Cairo arg1) arg2 arg3 -> cairo_text_extents arg1 arg2 arg3)
{-# LINE 48 "./Graphics/Rendering/Cairo/Internal/Drawing/Text.chs" #-}
            c string' result
        peek result


foreign import ccall safe "cairo_select_font_face"
  cairo_select_font_face :: ((Ptr Cairo) -> ((Ptr CChar) -> (CInt -> (CInt -> (IO ())))))

foreign import ccall safe "cairo_set_font_size"
  setFontSize'_ :: ((Ptr Cairo) -> (CDouble -> (IO ())))

foreign import ccall safe "cairo_set_font_matrix"
  setFontMatrix'_ :: ((Ptr Cairo) -> ((Ptr Matrix) -> (IO ())))

foreign import ccall safe "cairo_get_font_matrix"
  getFontMatrix'_ :: ((Ptr Cairo) -> ((Ptr Matrix) -> (IO ())))

foreign import ccall safe "cairo_set_font_options"
  setFontOptions'_ :: ((Ptr Cairo) -> ((Ptr FontOptions) -> (IO ())))

foreign import ccall safe "cairo_show_text"
  cairo_show_text :: ((Ptr Cairo) -> ((Ptr CChar) -> (IO ())))

foreign import ccall safe "cairo_font_extents"
  fontExtents'_ :: ((Ptr Cairo) -> ((Ptr FontExtents) -> (IO ())))

foreign import ccall safe "cairo_text_extents"
  cairo_text_extents :: ((Ptr Cairo) -> ((Ptr CChar) -> ((Ptr TextExtents) -> (IO ()))))