{-# LINE 2 "./Graphics/Rendering/Pango/Context.chs" #-}
module Graphics.Rendering.Pango.Context (
PangoContext,
PangoContextClass,
contextListFamilies,
contextGetMetrics,
contextSetFontDescription,
contextGetFontDescription,
Language,
emptyLanguage,
languageFromString,
contextSetLanguage,
contextGetLanguage,
contextSetTextDir,
contextGetTextDir,
contextSetTextGravity,
contextGetTextGravity,
contextSetTextGravityHint,
contextGetTextGravityHint,
contextGetMatrix,
contextSetMatrix,
) where
import Control.Monad (liftM)
import System.Glib.FFI
import Graphics.Rendering.Pango.Enums
import Graphics.Rendering.Pango.Structs
import System.Glib.GObject (makeNewGObject)
import Graphics.Rendering.Pango.Types
{-# LINE 82 "./Graphics/Rendering/Pango/Context.chs" #-}
import Graphics.Rendering.Pango.BasicTypes
{-# LINE 83 "./Graphics/Rendering/Pango/Context.chs" #-}
import Graphics.Rendering.Pango.Enums ( FontMetrics(..) )
import Graphics.Rendering.Cairo.Matrix
{-# LINE 85 "./Graphics/Rendering/Pango/Context.chs" #-}
{-# LINE 88 "./Graphics/Rendering/Pango/Context.chs" #-}
contextListFamilies :: PangoContext -> IO [FontFamily]
contextListFamilies c = alloca $ \sizePtr -> alloca $ \ptrPtr -> do
(\(PangoContext arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->pango_context_list_families argPtr1 arg2 arg3) c ptrPtr sizePtr
ptr <- peek ptrPtr
size <- peek sizePtr
familyPtrs <- peekArray (fromIntegral size) (castPtr ptr)
fams <- mapM (makeNewGObject mkFontFamily . return) familyPtrs
g_free (castPtr ptr)
return fams
contextGetMetrics :: PangoContext -> FontDescription -> Language ->
IO FontMetrics
contextGetMetrics pc fd l = do
mPtr <- (\(PangoContext arg1) (FontDescription arg2) (Language arg3) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->pango_context_get_metrics argPtr1 argPtr2 arg3) pc fd l
ascent <- pango_font_metrics_get_ascent mPtr
descent <- pango_font_metrics_get_descent mPtr
approximate_char_width <-
pango_font_metrics_get_approximate_char_width mPtr
approximate_digit_width <-
pango_font_metrics_get_approximate_digit_width mPtr
underline_position <-
pango_font_metrics_get_underline_position mPtr
underline_thickness <-
pango_font_metrics_get_underline_thickness mPtr
strikethrough_position <-
pango_font_metrics_get_strikethrough_position mPtr
strikethrough_thickness <-
pango_font_metrics_get_strikethrough_thickness mPtr
return (FontMetrics
(intToPu ascent)
(intToPu descent)
(intToPu approximate_char_width)
(intToPu approximate_digit_width)
(intToPu underline_thickness)
(intToPu underline_position)
(intToPu strikethrough_thickness)
(intToPu strikethrough_position)
)
contextSetFontDescription :: PangoContext -> FontDescription -> IO ()
contextSetFontDescription pc fd =
(\(PangoContext arg1) (FontDescription arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->pango_context_set_font_description argPtr1 argPtr2) pc fd
contextGetFontDescription :: PangoContext -> IO FontDescription
contextGetFontDescription pc = do
fdPtrConst <- (\(PangoContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_context_get_font_description argPtr1) pc
fdPtr <- pango_font_description_copy fdPtrConst
makeNewFontDescription fdPtr
foreign import ccall unsafe "pango_font_description_copy"
pango_font_description_copy :: Ptr FontDescription ->
IO (Ptr FontDescription)
contextSetLanguage :: PangoContext -> Language -> IO ()
contextSetLanguage = (\(PangoContext arg1) (Language arg2) -> withForeignPtr arg1 $ \argPtr1 ->pango_context_set_language argPtr1 arg2)
{-# LINE 163 "./Graphics/Rendering/Pango/Context.chs" #-}
contextGetLanguage :: PangoContext -> IO Language
contextGetLanguage pc = liftM Language $
(\(PangoContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_context_get_language argPtr1) pc
contextSetTextDir :: PangoContext -> PangoDirection -> IO ()
contextSetTextDir pc dir =
(\(PangoContext arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_context_set_base_dir argPtr1 arg2) pc (fromIntegral (fromEnum dir))
contextGetTextDir :: PangoContext -> IO PangoDirection
contextGetTextDir pc = liftM (toEnum . fromIntegral) $
(\(PangoContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_context_get_base_dir argPtr1) pc
contextSetTextGravity :: PangoContext -> PangoGravity -> IO ()
contextSetTextGravity pc gravity =
(\(PangoContext arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_context_set_base_gravity argPtr1 arg2) pc (fromIntegral (fromEnum gravity))
contextGetTextGravity :: PangoContext -> IO PangoGravity
contextGetTextGravity pc = liftM (toEnum . fromIntegral) $
(\(PangoContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_context_get_base_gravity argPtr1) pc
contextSetTextGravityHint :: PangoContext -> PangoGravityHint -> IO ()
contextSetTextGravityHint pc gravity =
(\(PangoContext arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_context_set_gravity_hint argPtr1 arg2) pc (fromIntegral (fromEnum gravity))
contextGetTextGravityHint :: PangoContext -> IO PangoGravityHint
contextGetTextGravityHint pc = liftM (toEnum . fromIntegral) $
(\(PangoContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_context_get_gravity_hint argPtr1) pc
contextGetMatrix :: PangoContext -> IO Matrix
contextGetMatrix pc = do
matPtr <- (\(PangoContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_context_get_matrix argPtr1) pc
if matPtr==nullPtr then return identity else peek (castPtr matPtr)
contextSetMatrix :: PangoContext -> Matrix -> IO ()
contextSetMatrix pc mat
| mat==identity = (\(PangoContext arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_context_set_matrix argPtr1 arg2) pc nullPtr
| otherwise = with mat $ \matPtr ->
(\(PangoContext arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_context_set_matrix argPtr1 arg2) pc (castPtr matPtr)
foreign import ccall unsafe "pango_context_list_families"
pango_context_list_families :: ((Ptr PangoContext) -> ((Ptr (Ptr FontFamily)) -> ((Ptr CInt) -> (IO ()))))
foreign import ccall unsafe "g_free"
g_free :: ((Ptr ()) -> (IO ()))
foreign import ccall unsafe "pango_context_get_metrics"
pango_context_get_metrics :: ((Ptr PangoContext) -> ((Ptr FontDescription) -> ((Ptr Language) -> (IO (Ptr ())))))
foreign import ccall unsafe "pango_font_metrics_get_ascent"
pango_font_metrics_get_ascent :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_font_metrics_get_descent"
pango_font_metrics_get_descent :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_font_metrics_get_approximate_char_width"
pango_font_metrics_get_approximate_char_width :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_font_metrics_get_approximate_digit_width"
pango_font_metrics_get_approximate_digit_width :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_font_metrics_get_underline_position"
pango_font_metrics_get_underline_position :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_font_metrics_get_underline_thickness"
pango_font_metrics_get_underline_thickness :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_font_metrics_get_strikethrough_position"
pango_font_metrics_get_strikethrough_position :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_font_metrics_get_strikethrough_thickness"
pango_font_metrics_get_strikethrough_thickness :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_context_set_font_description"
pango_context_set_font_description :: ((Ptr PangoContext) -> ((Ptr FontDescription) -> (IO ())))
foreign import ccall unsafe "pango_context_get_font_description"
pango_context_get_font_description :: ((Ptr PangoContext) -> (IO (Ptr FontDescription)))
foreign import ccall unsafe "pango_context_set_language"
pango_context_set_language :: ((Ptr PangoContext) -> ((Ptr Language) -> (IO ())))
foreign import ccall unsafe "pango_context_get_language"
pango_context_get_language :: ((Ptr PangoContext) -> (IO (Ptr Language)))
foreign import ccall unsafe "pango_context_set_base_dir"
pango_context_set_base_dir :: ((Ptr PangoContext) -> (CInt -> (IO ())))
foreign import ccall unsafe "pango_context_get_base_dir"
pango_context_get_base_dir :: ((Ptr PangoContext) -> (IO CInt))
foreign import ccall unsafe "pango_context_set_base_gravity"
pango_context_set_base_gravity :: ((Ptr PangoContext) -> (CInt -> (IO ())))
foreign import ccall unsafe "pango_context_get_base_gravity"
pango_context_get_base_gravity :: ((Ptr PangoContext) -> (IO CInt))
foreign import ccall unsafe "pango_context_set_gravity_hint"
pango_context_set_gravity_hint :: ((Ptr PangoContext) -> (CInt -> (IO ())))
foreign import ccall unsafe "pango_context_get_gravity_hint"
pango_context_get_gravity_hint :: ((Ptr PangoContext) -> (IO CInt))
foreign import ccall unsafe "pango_context_get_matrix"
pango_context_get_matrix :: ((Ptr PangoContext) -> (IO (Ptr ())))
foreign import ccall unsafe "pango_context_set_matrix"
pango_context_set_matrix :: ((Ptr PangoContext) -> ((Ptr ()) -> (IO ())))