{-# LANGUAGE CApiFFI #-}
module Graphics.Text.Font.Choose.Config(Config', fini, version,
initLoadConfig, initLoadConfigAndFonts, initFonts, reinit, bringUptoDate,
-- For the sake of Graphics.Font.Choose.Config.Accessors
Config, fcConfigDestroy) where
import Foreign.Ptr (Ptr, FunPtr)
import Foreign.ForeignPtr (ForeignPtr, newForeignPtr)
import Graphics.Text.Font.Choose.Result (throwBool, throwNull)
data Config'
type Config = ForeignPtr Config'
initLoadConfig :: IO Config
initLoadConfig = newForeignPtr fcConfigDestroy =<< throwNull =<< fcInitLoadConfig -- FIXME: What's proper memory-management here?
initLoadConfigAndFonts :: IO Config
initLoadConfigAndFonts = newForeignPtr fcConfigDestroy =<< throwNull =<< fcInitLoadConfigAndFonts -- FIXME: What's proper memory-management here?
initFonts :: IO ()
initFonts = throwBool =<< fcInit
foreign import capi "fontconfig/fontconfig.h FcFini" fini :: IO ()
foreign import capi "fontconfig/fontconfig.h FcGetVersion" version :: Int
reinit :: IO ()
reinit = throwBool =<< fcInitReinitialize
bringUptoDate :: IO ()
bringUptoDate = throwBool =<< fcInitBringUptoDate
foreign import capi "fontconfig/fontconfig.h FcInitLoadConfig" fcInitLoadConfig :: IO (Ptr Config')
foreign import capi "fontconfig/fontconfig.h FcInitLoadConfigAndFonts" fcInitLoadConfigAndFonts :: IO (Ptr Config')
foreign import capi "fontconfig/fontconfig.h FcInit" fcInit :: IO Bool
foreign import capi "fontconfig/fontconfig.h &FcConfigDestroy" fcConfigDestroy :: FunPtr (Ptr Config' -> IO ())
foreign import capi "fontconfig/fontconfig.h FcInitReinitialize" fcInitReinitialize :: IO Bool
foreign import capi "fontconfig/fontconfig.h FcInitBringUptoDate" fcInitBringUptoDate :: IO Bool