~alcinnz/fontconfig-pure

ref: 18b29da8fa2cc23650f2fd33c0917bcc2289a7b6 fontconfig-pure/lib/Graphics/Text/Font/Choose/Config.hs -rw-r--r-- 1.5 KiB
18b29da8 — Adrian Cochrane Expose font weight adjustments & correct current-config refcount. 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{-# LANGUAGE CApiFFI #-}
module Graphics.Text.Font.Choose.Config 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?

init :: IO ()
init = 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