module Graphics.Text.Font.Choose.Config where
import Graphics.Text.Font.Choose.Strings
import Graphics.Text.Font.Choose.FontSet
import Graphics.Text.Font.Choose.CharSet
import Graphics.Text.Font.Choose.Pattern
import Graphics.Text.Font.Choose.ObjectSet
import Foreign.ForeignPtr
import Foreign.Ptr (Ptr, nullPtr, FunPtr)
import Foreign.Marshal.Alloc (alloca, allocaBytes, free)
import Foreign.Storable (Storable(..))
import Foreign.C.String (CString, peekCString, withCString)
import System.IO.Unsafe (unsafePerformIO)
import Data.Set (empty)
import Control.Exception (bracket)
import Graphics.Text.Font.Choose.Result (Word8, throwNull, throwFalse, throwPtr)
type Config = ForeignPtr Config'
data Config'
type Config_ = Ptr Config'
configCreate :: IO Config
configCreate :: IO Config
configCreate = FinalizerPtr Config' -> Ptr Config' -> IO Config
forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
newForeignPtr FinalizerPtr Config'
fcConfigDestroy (Ptr Config' -> IO Config) -> IO (Ptr Config') -> IO Config
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Config' -> Ptr Config'
forall a. Ptr a -> Ptr a
throwNull (Ptr Config' -> Ptr Config')
-> IO (Ptr Config') -> IO (Ptr Config')
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO (Ptr Config')
fcConfigCreate
foreign import ccall "FcConfigCreate" fcConfigCreate :: IO Config_
ptr2config :: Ptr Config' -> IO Config
ptr2config = FinalizerPtr Config' -> Ptr Config' -> IO Config
forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
newForeignPtr FinalizerPtr Config'
fcConfigDestroy
foreign import ccall "&FcConfigDestroy" fcConfigDestroy :: FunPtr (Config_ -> IO ())
configSetCurrent :: Config -> IO ()
configSetCurrent :: Config -> IO ()
configSetCurrent config :: Config
config = Bool -> IO ()
throwFalse (Bool -> IO ()) -> IO Bool -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (Config -> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO Bool) -> IO Bool)
-> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ Ptr Config' -> IO Bool
fcConfigSetCurrent)
foreign import ccall "FcConfigSetCurrent" fcConfigSetCurrent :: Config_ -> IO Bool
configGetCurrent :: IO Config
configGetCurrent :: IO Config
configGetCurrent = (Ptr Config' -> Ptr Config'
forall a. Ptr a -> Ptr a
throwNull (Ptr Config' -> Ptr Config')
-> IO (Ptr Config') -> IO (Ptr Config')
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Config' -> IO (Ptr Config')
fcConfigReference Ptr Config'
forall a. Ptr a
nullPtr) IO (Ptr Config') -> (Ptr Config' -> IO Config) -> IO Config
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
FinalizerPtr Config' -> Ptr Config' -> IO Config
forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
newForeignPtr FinalizerPtr Config'
fcConfigDestroy
foreign import ccall "FcConfigReference" fcConfigReference :: Config_ -> IO Config_
configUptoDate :: Config -> IO Bool
configUptoDate :: Config -> IO Bool
configUptoDate config :: Config
config = Config -> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO Bool) -> IO Bool)
-> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ Ptr Config' -> IO Bool
fcConfigUptoDate
foreign import ccall "FcConfigUptoDate" fcConfigUptoDate :: Config_ -> IO Bool
configHome :: IO (Maybe String)
configHome :: IO (Maybe String)
configHome = do
CString
ret <- IO CString
fcConfigHome
if CString
ret CString -> CString -> Bool
forall a. Eq a => a -> a -> Bool
== CString
forall a. Ptr a
nullPtr then Maybe String -> IO (Maybe String)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe String
forall a. Maybe a
Nothing else String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String) -> IO String -> IO (Maybe String)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CString -> IO String
peekCString CString
ret
foreign import ccall "FcConfigHome" fcConfigHome :: IO CString
foreign import ccall "FcConfigEnableHome" configEnableHome :: Bool -> IO Bool
configBuildFonts :: Config -> IO ()
configBuildFonts :: Config -> IO ()
configBuildFonts config :: Config
config = Bool -> IO ()
throwFalse (Bool -> IO ()) -> IO Bool -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (Config -> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO Bool) -> IO Bool)
-> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ Ptr Config' -> IO Bool
fcConfigBuildFonts)
configBuildFonts' :: IO ()
configBuildFonts' :: IO ()
configBuildFonts' = Bool -> IO ()
throwFalse (Bool -> IO ()) -> IO Bool -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Config' -> IO Bool
fcConfigBuildFonts Ptr Config'
forall a. Ptr a
nullPtr
foreign import ccall "FcConfigBuildFonts" fcConfigBuildFonts :: Config_ -> IO Bool
configGetConfigDirs :: Config -> IO StrList
configGetConfigDirs :: Config -> IO StrList
configGetConfigDirs = (Ptr Config' -> IO StrList_) -> Config -> IO StrList
configStrsFunc Ptr Config' -> IO StrList_
fcConfigGetConfigDirs
configGetConfigDirs' :: IO StrList
configGetConfigDirs' :: IO StrList
configGetConfigDirs' = StrList_ -> IO StrList
thawStrList (StrList_ -> IO StrList) -> IO StrList_ -> IO StrList
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Config' -> IO StrList_
fcConfigGetConfigDirs Ptr Config'
forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetConfigDirs" fcConfigGetConfigDirs :: Config_ -> IO StrList_
configGetFontDirs :: Config -> IO StrList
configGetFontDirs :: Config -> IO StrList
configGetFontDirs = (Ptr Config' -> IO StrList_) -> Config -> IO StrList
configStrsFunc Ptr Config' -> IO StrList_
fcConfigGetFontDirs
configGetFontDirs' :: IO StrList
configGetFontDirs' :: IO StrList
configGetFontDirs' = IO StrList_ -> IO StrList
thawStrList_ (IO StrList_ -> IO StrList) -> IO StrList_ -> IO StrList
forall a b. (a -> b) -> a -> b
$ Ptr Config' -> IO StrList_
fcConfigGetFontDirs Ptr Config'
forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetFontDirs" fcConfigGetFontDirs :: Config_ -> IO StrList_
configGetConfigFiles :: Config -> IO StrList
configGetConfigFiles :: Config -> IO StrList
configGetConfigFiles = (Ptr Config' -> IO StrList_) -> Config -> IO StrList
configStrsFunc Ptr Config' -> IO StrList_
fcConfigGetConfigFiles
configGetConfigFiles' :: IO StrList
configGetConfigFiles' :: IO StrList
configGetConfigFiles' = IO StrList_ -> IO StrList
thawStrList_ (IO StrList_ -> IO StrList) -> IO StrList_ -> IO StrList
forall a b. (a -> b) -> a -> b
$ Ptr Config' -> IO StrList_
fcConfigGetConfigFiles Ptr Config'
forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetConfigFiles" fcConfigGetConfigFiles :: Config_ -> IO StrList_
configGetCacheDirs :: Config -> IO StrList
configGetCacheDirs :: Config -> IO StrList
configGetCacheDirs = (Ptr Config' -> IO StrList_) -> Config -> IO StrList
configStrsFunc Ptr Config' -> IO StrList_
fcConfigGetCacheDirs
configGetCacheDirs' :: IO StrList
configGetCacheDirs' :: IO StrList
configGetCacheDirs' = IO StrList_ -> IO StrList
thawStrList_ (IO StrList_ -> IO StrList) -> IO StrList_ -> IO StrList
forall a b. (a -> b) -> a -> b
$ Ptr Config' -> IO StrList_
fcConfigGetCacheDirs Ptr Config'
forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetCacheDirs" fcConfigGetCacheDirs :: Config_ -> IO StrList_
data SetName = SetSystem | SetApplication deriving (Int -> SetName
SetName -> Int
SetName -> [SetName]
SetName -> SetName
SetName -> SetName -> [SetName]
SetName -> SetName -> SetName -> [SetName]
(SetName -> SetName)
-> (SetName -> SetName)
-> (Int -> SetName)
-> (SetName -> Int)
-> (SetName -> [SetName])
-> (SetName -> SetName -> [SetName])
-> (SetName -> SetName -> [SetName])
-> (SetName -> SetName -> SetName -> [SetName])
-> Enum SetName
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: SetName -> SetName -> SetName -> [SetName]
$cenumFromThenTo :: SetName -> SetName -> SetName -> [SetName]
enumFromTo :: SetName -> SetName -> [SetName]
$cenumFromTo :: SetName -> SetName -> [SetName]
enumFromThen :: SetName -> SetName -> [SetName]
$cenumFromThen :: SetName -> SetName -> [SetName]
enumFrom :: SetName -> [SetName]
$cenumFrom :: SetName -> [SetName]
fromEnum :: SetName -> Int
$cfromEnum :: SetName -> Int
toEnum :: Int -> SetName
$ctoEnum :: Int -> SetName
pred :: SetName -> SetName
$cpred :: SetName -> SetName
succ :: SetName -> SetName
$csucc :: SetName -> SetName
Enum, SetName -> SetName -> Bool
(SetName -> SetName -> Bool)
-> (SetName -> SetName -> Bool) -> Eq SetName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetName -> SetName -> Bool
$c/= :: SetName -> SetName -> Bool
== :: SetName -> SetName -> Bool
$c== :: SetName -> SetName -> Bool
Eq, Int -> SetName -> ShowS
[SetName] -> ShowS
SetName -> String
(Int -> SetName -> ShowS)
-> (SetName -> String) -> ([SetName] -> ShowS) -> Show SetName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetName] -> ShowS
$cshowList :: [SetName] -> ShowS
show :: SetName -> String
$cshow :: SetName -> String
showsPrec :: Int -> SetName -> ShowS
$cshowsPrec :: Int -> SetName -> ShowS
Show, ReadPrec [SetName]
ReadPrec SetName
Int -> ReadS SetName
ReadS [SetName]
(Int -> ReadS SetName)
-> ReadS [SetName]
-> ReadPrec SetName
-> ReadPrec [SetName]
-> Read SetName
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetName]
$creadListPrec :: ReadPrec [SetName]
readPrec :: ReadPrec SetName
$creadPrec :: ReadPrec SetName
readList :: ReadS [SetName]
$creadList :: ReadS [SetName]
readsPrec :: Int -> ReadS SetName
$creadsPrec :: Int -> ReadS SetName
Read)
configGetFonts :: Config -> SetName -> IO FontSet
configGetFonts :: Config -> SetName -> IO FontSet
configGetFonts config :: Config
config set :: SetName
set = do
FontSet_
ret <- Config -> (Ptr Config' -> IO FontSet_) -> IO FontSet_
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO FontSet_) -> IO FontSet_)
-> (Ptr Config' -> IO FontSet_) -> IO FontSet_
forall a b. (a -> b) -> a -> b
$ (Ptr Config' -> Int -> IO FontSet_)
-> Int -> Ptr Config' -> IO FontSet_
forall a b c. (a -> b -> c) -> b -> a -> c
flip Ptr Config' -> Int -> IO FontSet_
fcConfigGetFonts (Int -> Ptr Config' -> IO FontSet_)
-> Int -> Ptr Config' -> IO FontSet_
forall a b. (a -> b) -> a -> b
$ SetName -> Int
forall a. Enum a => a -> Int
fromEnum SetName
set
FontSet_ -> IO FontSet
thawFontSet (FontSet_ -> IO FontSet) -> FontSet_ -> IO FontSet
forall a b. (a -> b) -> a -> b
$ FontSet_ -> FontSet_
forall a. Ptr a -> Ptr a
throwNull FontSet_
ret
configGetFonts' :: SetName -> IO FontSet
configGetFonts' :: SetName -> IO FontSet
configGetFonts' set :: SetName
set = do
FontSet_
ret <- Ptr Config' -> Int -> IO FontSet_
fcConfigGetFonts Ptr Config'
forall a. Ptr a
nullPtr (Int -> IO FontSet_) -> Int -> IO FontSet_
forall a b. (a -> b) -> a -> b
$ SetName -> Int
forall a. Enum a => a -> Int
fromEnum SetName
set
FontSet_ -> IO FontSet
thawFontSet (FontSet_ -> IO FontSet) -> FontSet_ -> IO FontSet
forall a b. (a -> b) -> a -> b
$ FontSet_ -> FontSet_
forall a. Ptr a -> Ptr a
throwNull FontSet_
ret
foreign import ccall "FcConfigGetFonts" fcConfigGetFonts :: Config_ -> Int -> IO FontSet_
configGetRescanInterval :: Config -> IO Int
configGetRescanInterval :: Config -> IO Int
configGetRescanInterval = (Config -> (Ptr Config' -> IO Int) -> IO Int)
-> (Ptr Config' -> IO Int) -> Config -> IO Int
forall a b c. (a -> b -> c) -> b -> a -> c
flip Config -> (Ptr Config' -> IO Int) -> IO Int
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ((Ptr Config' -> IO Int) -> Config -> IO Int)
-> (Ptr Config' -> IO Int) -> Config -> IO Int
forall a b. (a -> b) -> a -> b
$ Ptr Config' -> IO Int
fcConfigGetRescanInterval
configGetRescanInterval' :: IO Int
configGetRescanInterval' :: IO Int
configGetRescanInterval' = Ptr Config' -> IO Int
fcConfigGetRescanInterval Ptr Config'
forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetRescanInterval" fcConfigGetRescanInterval ::
Config_ -> IO Int
configSetRescanInterval :: Config -> Int -> IO ()
configSetRescanInterval :: Config -> Int -> IO ()
configSetRescanInterval config :: Config
config val :: Int
val =
Bool -> IO ()
throwFalse (Bool -> IO ()) -> IO Bool -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (Config -> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO Bool) -> IO Bool)
-> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ (Ptr Config' -> Int -> IO Bool) -> Int -> Ptr Config' -> IO Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip Ptr Config' -> Int -> IO Bool
fcConfigSetRescanInterval Int
val)
configSetRescanInterval' :: Int -> IO ()
configSetRescanInterval' :: Int -> IO ()
configSetRescanInterval' v :: Int
v = Bool -> IO ()
throwFalse (Bool -> IO ()) -> IO Bool -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Config' -> Int -> IO Bool
fcConfigSetRescanInterval Ptr Config'
forall a. Ptr a
nullPtr Int
v
foreign import ccall "FcConfigSetRescanInterval" fcConfigSetRescanInterval ::
Config_ -> Int -> IO Bool
configAppFontAddFile :: Config -> String -> IO ()
configAppFontAddFile :: Config -> String -> IO ()
configAppFontAddFile config :: Config
config file :: String
file = Bool -> IO ()
throwFalse (Bool -> IO ()) -> IO Bool -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<
(Config -> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO Bool) -> IO Bool)
-> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ \config' :: Ptr Config'
config' -> String -> (CString -> IO Bool) -> IO Bool
forall a. String -> (CString -> IO a) -> IO a
withCString String
file ((CString -> IO Bool) -> IO Bool)
-> (CString -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ \file' :: CString
file' ->
Ptr Config' -> CString -> IO Bool
fcConfigAppFontAddFile Ptr Config'
config' CString
file')
configAppFontAddFile' :: String -> IO ()
configAppFontAddFile' :: String -> IO ()
configAppFontAddFile' file :: String
file =
Bool -> IO ()
throwFalse (Bool -> IO ()) -> IO Bool -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (String -> (CString -> IO Bool) -> IO Bool
forall a. String -> (CString -> IO a) -> IO a
withCString String
file ((CString -> IO Bool) -> IO Bool)
-> (CString -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ Ptr Config' -> CString -> IO Bool
fcConfigAppFontAddFile Ptr Config'
forall a. Ptr a
nullPtr)
foreign import ccall "FcConfigAppFontAddFile" fcConfigAppFontAddFile ::
Config_ -> CString -> IO Bool
configAppFontAddDir :: Config -> String -> IO ()
configAppFontAddDir :: Config -> String -> IO ()
configAppFontAddDir config :: Config
config file :: String
file = Bool -> IO ()
throwFalse (Bool -> IO ()) -> IO Bool -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<
(Config -> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO Bool) -> IO Bool)
-> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ \config' :: Ptr Config'
config' -> String -> (CString -> IO Bool) -> IO Bool
forall a. String -> (CString -> IO a) -> IO a
withCString String
file ((CString -> IO Bool) -> IO Bool)
-> (CString -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ Ptr Config' -> CString -> IO Bool
fcConfigAppFontAddDir Ptr Config'
config')
configAppFontAddDir' :: String -> IO ()
configAppFontAddDir' :: String -> IO ()
configAppFontAddDir' v :: String
v = Bool -> IO ()
throwFalse (Bool -> IO ()) -> IO Bool -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (String -> (CString -> IO Bool) -> IO Bool
forall a. String -> (CString -> IO a) -> IO a
withCString String
v ((CString -> IO Bool) -> IO Bool)
-> (CString -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ Ptr Config' -> CString -> IO Bool
fcConfigAppFontAddDir Ptr Config'
forall a. Ptr a
nullPtr)
foreign import ccall "FcConfigAppFontAddDir" fcConfigAppFontAddDir ::
Config_ -> CString -> IO Bool
configAppFontClear :: Config -> IO ()
configAppFontClear :: Config -> IO ()
configAppFontClear config :: Config
config = Bool -> IO ()
throwFalse (Bool -> IO ()) -> IO Bool -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Config -> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config Ptr Config' -> IO Bool
fcConfigAppFontClear
configAppFontClear' :: IO ()
configAppFontClear' :: IO ()
configAppFontClear' = Bool -> IO ()
throwFalse (Bool -> IO ()) -> IO Bool -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Config' -> IO Bool
fcConfigAppFontClear Ptr Config'
forall a. Ptr a
nullPtr
foreign import ccall "FcConfigAppFontClear" fcConfigAppFontClear :: Config_ -> IO Bool
data MatchKind = MatchPattern | MatchFont | MatchScan deriving Int -> MatchKind
MatchKind -> Int
MatchKind -> [MatchKind]
MatchKind -> MatchKind
MatchKind -> MatchKind -> [MatchKind]
MatchKind -> MatchKind -> MatchKind -> [MatchKind]
(MatchKind -> MatchKind)
-> (MatchKind -> MatchKind)
-> (Int -> MatchKind)
-> (MatchKind -> Int)
-> (MatchKind -> [MatchKind])
-> (MatchKind -> MatchKind -> [MatchKind])
-> (MatchKind -> MatchKind -> [MatchKind])
-> (MatchKind -> MatchKind -> MatchKind -> [MatchKind])
-> Enum MatchKind
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: MatchKind -> MatchKind -> MatchKind -> [MatchKind]
$cenumFromThenTo :: MatchKind -> MatchKind -> MatchKind -> [MatchKind]
enumFromTo :: MatchKind -> MatchKind -> [MatchKind]
$cenumFromTo :: MatchKind -> MatchKind -> [MatchKind]
enumFromThen :: MatchKind -> MatchKind -> [MatchKind]
$cenumFromThen :: MatchKind -> MatchKind -> [MatchKind]
enumFrom :: MatchKind -> [MatchKind]
$cenumFrom :: MatchKind -> [MatchKind]
fromEnum :: MatchKind -> Int
$cfromEnum :: MatchKind -> Int
toEnum :: Int -> MatchKind
$ctoEnum :: Int -> MatchKind
pred :: MatchKind -> MatchKind
$cpred :: MatchKind -> MatchKind
succ :: MatchKind -> MatchKind
$csucc :: MatchKind -> MatchKind
Enum
configSubstituteWithPat :: Config -> Pattern -> Pattern -> MatchKind -> Pattern
configSubstituteWithPat :: Config -> Pattern -> Pattern -> MatchKind -> Pattern
configSubstituteWithPat config :: Config
config p :: Pattern
p p_pat :: Pattern
p_pat kind :: MatchKind
kind = IO Pattern -> Pattern
forall a. IO a -> a
unsafePerformIO (IO Pattern -> Pattern) -> IO Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$
Config -> (Ptr Config' -> IO Pattern) -> IO Pattern
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO Pattern) -> IO Pattern)
-> (Ptr Config' -> IO Pattern) -> IO Pattern
forall a b. (a -> b) -> a -> b
$ \config' :: Ptr Config'
config' -> Pattern -> (Pattern_ -> IO Pattern) -> IO Pattern
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p ((Pattern_ -> IO Pattern) -> IO Pattern)
-> (Pattern_ -> IO Pattern) -> IO Pattern
forall a b. (a -> b) -> a -> b
$ \p' :: Pattern_
p' ->
Pattern -> (Pattern_ -> IO Pattern) -> IO Pattern
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p_pat ((Pattern_ -> IO Pattern) -> IO Pattern)
-> (Pattern_ -> IO Pattern) -> IO Pattern
forall a b. (a -> b) -> a -> b
$ \p_pat' :: Pattern_
p_pat' -> do
Bool
ok <- Ptr Config' -> Pattern_ -> Pattern_ -> Int -> IO Bool
fcConfigSubstituteWithPat Ptr Config'
config' Pattern_
p' Pattern_
p_pat' (Int -> IO Bool) -> Int -> IO Bool
forall a b. (a -> b) -> a -> b
$ MatchKind -> Int
forall a. Enum a => a -> Int
fromEnum MatchKind
kind
Bool -> IO ()
throwFalse Bool
ok
Pattern_ -> IO Pattern
thawPattern Pattern_
p'
configSubstituteWithPat' :: Pattern -> Pattern -> MatchKind -> Pattern
configSubstituteWithPat' :: Pattern -> Pattern -> MatchKind -> Pattern
configSubstituteWithPat' p :: Pattern
p p_pat :: Pattern
p_pat kind :: MatchKind
kind = IO Pattern -> Pattern
forall a. IO a -> a
unsafePerformIO (IO Pattern -> Pattern) -> IO Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$
Pattern -> (Pattern_ -> IO Pattern) -> IO Pattern
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p ((Pattern_ -> IO Pattern) -> IO Pattern)
-> (Pattern_ -> IO Pattern) -> IO Pattern
forall a b. (a -> b) -> a -> b
$ \p' :: Pattern_
p' -> Pattern -> (Pattern_ -> IO Pattern) -> IO Pattern
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p_pat ((Pattern_ -> IO Pattern) -> IO Pattern)
-> (Pattern_ -> IO Pattern) -> IO Pattern
forall a b. (a -> b) -> a -> b
$ \p_pat' :: Pattern_
p_pat' -> do
Bool
ok <- Ptr Config' -> Pattern_ -> Pattern_ -> Int -> IO Bool
fcConfigSubstituteWithPat Ptr Config'
forall a. Ptr a
nullPtr Pattern_
p' Pattern_
p_pat' (Int -> IO Bool) -> Int -> IO Bool
forall a b. (a -> b) -> a -> b
$ MatchKind -> Int
forall a. Enum a => a -> Int
fromEnum MatchKind
kind
Bool -> IO ()
throwFalse Bool
ok
Pattern_ -> IO Pattern
thawPattern Pattern_
p'
foreign import ccall "FcConfigSubstituteWithPat" fcConfigSubstituteWithPat ::
Config_ -> Pattern_ -> Pattern_ -> Int -> IO Bool
configSubstitute :: Config -> Pattern -> MatchKind -> Pattern
configSubstitute :: Config -> Pattern -> MatchKind -> Pattern
configSubstitute config :: Config
config p :: Pattern
p kind :: MatchKind
kind = IO Pattern -> Pattern
forall a. IO a -> a
unsafePerformIO (IO Pattern -> Pattern) -> IO Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$
Config -> (Ptr Config' -> IO Pattern) -> IO Pattern
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO Pattern) -> IO Pattern)
-> (Ptr Config' -> IO Pattern) -> IO Pattern
forall a b. (a -> b) -> a -> b
$ \config' :: Ptr Config'
config' -> Pattern -> (Pattern_ -> IO Pattern) -> IO Pattern
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p ((Pattern_ -> IO Pattern) -> IO Pattern)
-> (Pattern_ -> IO Pattern) -> IO Pattern
forall a b. (a -> b) -> a -> b
$ \p' :: Pattern_
p' -> do
Bool
ok <- Ptr Config' -> Pattern_ -> Int -> IO Bool
fcConfigSubstitute Ptr Config'
config' Pattern_
p' (Int -> IO Bool) -> Int -> IO Bool
forall a b. (a -> b) -> a -> b
$ MatchKind -> Int
forall a. Enum a => a -> Int
fromEnum MatchKind
kind
Bool -> IO ()
throwFalse Bool
ok
Pattern_ -> IO Pattern
thawPattern Pattern_
p'
configSubstitute' :: Pattern -> MatchKind -> Pattern
configSubstitute' :: Pattern -> MatchKind -> Pattern
configSubstitute' p :: Pattern
p kind :: MatchKind
kind = IO Pattern -> Pattern
forall a. IO a -> a
unsafePerformIO (IO Pattern -> Pattern) -> IO Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern -> (Pattern_ -> IO Pattern) -> IO Pattern
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p ((Pattern_ -> IO Pattern) -> IO Pattern)
-> (Pattern_ -> IO Pattern) -> IO Pattern
forall a b. (a -> b) -> a -> b
$ \p' :: Pattern_
p' -> do
Bool
ok <- Ptr Config' -> Pattern_ -> Int -> IO Bool
fcConfigSubstitute Ptr Config'
forall a. Ptr a
nullPtr Pattern_
p' (Int -> IO Bool) -> Int -> IO Bool
forall a b. (a -> b) -> a -> b
$ MatchKind -> Int
forall a. Enum a => a -> Int
fromEnum MatchKind
kind
Bool -> IO ()
throwFalse Bool
ok
Pattern_ -> IO Pattern
thawPattern Pattern_
p'
foreign import ccall "FcConfigSubstitute" fcConfigSubstitute ::
Config_ -> Pattern_ -> Int -> IO Bool
fontMatch :: Config -> Pattern -> Maybe Pattern
fontMatch :: Config -> Pattern -> Maybe Pattern
fontMatch config :: Config
config pattern :: Pattern
pattern = IO (Maybe Pattern) -> Maybe Pattern
forall a. IO a -> a
unsafePerformIO (IO (Maybe Pattern) -> Maybe Pattern)
-> IO (Maybe Pattern) -> Maybe Pattern
forall a b. (a -> b) -> a -> b
$ Config -> (Ptr Config' -> IO (Maybe Pattern)) -> IO (Maybe Pattern)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO (Maybe Pattern)) -> IO (Maybe Pattern))
-> (Ptr Config' -> IO (Maybe Pattern)) -> IO (Maybe Pattern)
forall a b. (a -> b) -> a -> b
$ \config' :: Ptr Config'
config' ->
Pattern -> (Pattern_ -> IO (Maybe Pattern)) -> IO (Maybe Pattern)
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern ((Pattern_ -> IO (Maybe Pattern)) -> IO (Maybe Pattern))
-> (Pattern_ -> IO (Maybe Pattern)) -> IO (Maybe Pattern)
forall a b. (a -> b) -> a -> b
$ \pattern' :: Pattern_
pattern' -> (Ptr Word8 -> IO (Maybe Pattern)) -> IO (Maybe Pattern)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (Maybe Pattern)) -> IO (Maybe Pattern))
-> (Ptr Word8 -> IO (Maybe Pattern)) -> IO (Maybe Pattern)
forall a b. (a -> b) -> a -> b
$ \res' :: Ptr Word8
res' -> do
Pattern_
ret <- Ptr Config' -> Pattern_ -> Ptr Word8 -> IO Pattern_
fcFontMatch Ptr Config'
config' Pattern_
pattern' Ptr Word8
res'
Ptr Word8 -> IO Pattern -> IO (Maybe Pattern)
forall a. Ptr Word8 -> IO a -> IO (Maybe a)
throwPtr Ptr Word8
res' (IO Pattern -> IO (Maybe Pattern))
-> IO Pattern -> IO (Maybe Pattern)
forall a b. (a -> b) -> a -> b
$ IO Pattern_ -> IO Pattern
thawPattern_ (IO Pattern_ -> IO Pattern) -> IO Pattern_ -> IO Pattern
forall a b. (a -> b) -> a -> b
$ Pattern_ -> IO Pattern_
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pattern_
ret
fontMatch' :: Pattern -> Maybe Pattern
fontMatch' :: Pattern -> Maybe Pattern
fontMatch' pattern :: Pattern
pattern = IO (Maybe Pattern) -> Maybe Pattern
forall a. IO a -> a
unsafePerformIO (IO (Maybe Pattern) -> Maybe Pattern)
-> IO (Maybe Pattern) -> Maybe Pattern
forall a b. (a -> b) -> a -> b
$ Pattern -> (Pattern_ -> IO (Maybe Pattern)) -> IO (Maybe Pattern)
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern ((Pattern_ -> IO (Maybe Pattern)) -> IO (Maybe Pattern))
-> (Pattern_ -> IO (Maybe Pattern)) -> IO (Maybe Pattern)
forall a b. (a -> b) -> a -> b
$ \pattern' :: Pattern_
pattern' -> (Ptr Word8 -> IO (Maybe Pattern)) -> IO (Maybe Pattern)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (Maybe Pattern)) -> IO (Maybe Pattern))
-> (Ptr Word8 -> IO (Maybe Pattern)) -> IO (Maybe Pattern)
forall a b. (a -> b) -> a -> b
$ \res' :: Ptr Word8
res' -> do
Pattern_
ret <- Ptr Config' -> Pattern_ -> Ptr Word8 -> IO Pattern_
fcFontMatch Ptr Config'
forall a. Ptr a
nullPtr Pattern_
pattern' Ptr Word8
res'
Ptr Word8 -> IO Pattern -> IO (Maybe Pattern)
forall a. Ptr Word8 -> IO a -> IO (Maybe a)
throwPtr Ptr Word8
res' (IO Pattern -> IO (Maybe Pattern))
-> IO Pattern -> IO (Maybe Pattern)
forall a b. (a -> b) -> a -> b
$ IO Pattern_ -> IO Pattern
thawPattern_ (IO Pattern_ -> IO Pattern) -> IO Pattern_ -> IO Pattern
forall a b. (a -> b) -> a -> b
$ Pattern_ -> IO Pattern_
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pattern_
ret
foreign import ccall "FcFontMatch" fcFontMatch ::
Config_ -> Pattern_ -> Ptr Word8 -> IO Pattern_
fontSort :: Config -> Pattern -> Bool -> Maybe (FontSet, CharSet)
fontSort :: Config -> Pattern -> Bool -> Maybe (FontSet, CharSet)
fontSort config :: Config
config pattern :: Pattern
pattern trim :: Bool
trim = IO (Maybe (FontSet, CharSet)) -> Maybe (FontSet, CharSet)
forall a. IO a -> a
unsafePerformIO (IO (Maybe (FontSet, CharSet)) -> Maybe (FontSet, CharSet))
-> IO (Maybe (FontSet, CharSet)) -> Maybe (FontSet, CharSet)
forall a b. (a -> b) -> a -> b
$ Config
-> (Ptr Config' -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet))
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet)))
-> (Ptr Config' -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet))
forall a b. (a -> b) -> a -> b
$ \config' :: Ptr Config'
config' ->
Pattern
-> (Pattern_ -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet))
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern ((Pattern_ -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet)))
-> (Pattern_ -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet))
forall a b. (a -> b) -> a -> b
$ \pattern' :: Pattern_
pattern' -> (CharSet_ -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet))
forall a. (CharSet_ -> IO a) -> IO a
withNewCharSet ((CharSet_ -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet)))
-> (CharSet_ -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet))
forall a b. (a -> b) -> a -> b
$ \csp' :: CharSet_
csp' -> (Ptr Word8 -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet))
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet)))
-> (Ptr Word8 -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet))
forall a b. (a -> b) -> a -> b
$ \res' :: Ptr Word8
res' -> do
FontSet_
ret <- Ptr Config'
-> Pattern_ -> Bool -> CharSet_ -> Ptr Word8 -> IO FontSet_
fcFontSort Ptr Config'
config' Pattern_
pattern' Bool
trim CharSet_
csp' Ptr Word8
res'
Ptr Word8 -> IO (FontSet, CharSet) -> IO (Maybe (FontSet, CharSet))
forall a. Ptr Word8 -> IO a -> IO (Maybe a)
throwPtr Ptr Word8
res' (IO (FontSet, CharSet) -> IO (Maybe (FontSet, CharSet)))
-> IO (FontSet, CharSet) -> IO (Maybe (FontSet, CharSet))
forall a b. (a -> b) -> a -> b
$ do
FontSet
x <- IO FontSet_ -> IO FontSet
thawFontSet_ (IO FontSet_ -> IO FontSet) -> IO FontSet_ -> IO FontSet
forall a b. (a -> b) -> a -> b
$ FontSet_ -> IO FontSet_
forall (f :: * -> *) a. Applicative f => a -> f a
pure (FontSet_ -> IO FontSet_) -> FontSet_ -> IO FontSet_
forall a b. (a -> b) -> a -> b
$ FontSet_ -> FontSet_
forall a. Ptr a -> Ptr a
throwNull FontSet_
ret
CharSet
y <- CharSet_ -> IO CharSet
thawCharSet (CharSet_ -> IO CharSet) -> CharSet_ -> IO CharSet
forall a b. (a -> b) -> a -> b
$ CharSet_ -> CharSet_
forall a. Ptr a -> Ptr a
throwNull CharSet_
csp'
(FontSet, CharSet) -> IO (FontSet, CharSet)
forall (m :: * -> *) a. Monad m => a -> m a
return (FontSet
x, CharSet
y)
fontSort' :: Pattern -> Bool -> Maybe (FontSet, CharSet)
fontSort' :: Pattern -> Bool -> Maybe (FontSet, CharSet)
fontSort' pattern :: Pattern
pattern trim :: Bool
trim = IO (Maybe (FontSet, CharSet)) -> Maybe (FontSet, CharSet)
forall a. IO a -> a
unsafePerformIO (IO (Maybe (FontSet, CharSet)) -> Maybe (FontSet, CharSet))
-> IO (Maybe (FontSet, CharSet)) -> Maybe (FontSet, CharSet)
forall a b. (a -> b) -> a -> b
$ Pattern
-> (Pattern_ -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet))
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern ((Pattern_ -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet)))
-> (Pattern_ -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet))
forall a b. (a -> b) -> a -> b
$ \pattern' :: Pattern_
pattern' ->
(CharSet_ -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet))
forall a. (CharSet_ -> IO a) -> IO a
withNewCharSet ((CharSet_ -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet)))
-> (CharSet_ -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet))
forall a b. (a -> b) -> a -> b
$ \csp' :: CharSet_
csp' -> (Ptr Word8 -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet))
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet)))
-> (Ptr Word8 -> IO (Maybe (FontSet, CharSet)))
-> IO (Maybe (FontSet, CharSet))
forall a b. (a -> b) -> a -> b
$ \res' :: Ptr Word8
res' -> do
FontSet_
ret <- Ptr Config'
-> Pattern_ -> Bool -> CharSet_ -> Ptr Word8 -> IO FontSet_
fcFontSort Ptr Config'
forall a. Ptr a
nullPtr Pattern_
pattern' Bool
trim CharSet_
csp' Ptr Word8
res'
Ptr Word8 -> IO (FontSet, CharSet) -> IO (Maybe (FontSet, CharSet))
forall a. Ptr Word8 -> IO a -> IO (Maybe a)
throwPtr Ptr Word8
res' (IO (FontSet, CharSet) -> IO (Maybe (FontSet, CharSet)))
-> IO (FontSet, CharSet) -> IO (Maybe (FontSet, CharSet))
forall a b. (a -> b) -> a -> b
$ do
FontSet
x <- IO FontSet_ -> IO FontSet
thawFontSet_ (IO FontSet_ -> IO FontSet) -> IO FontSet_ -> IO FontSet
forall a b. (a -> b) -> a -> b
$ FontSet_ -> IO FontSet_
forall (f :: * -> *) a. Applicative f => a -> f a
pure (FontSet_ -> IO FontSet_) -> FontSet_ -> IO FontSet_
forall a b. (a -> b) -> a -> b
$ FontSet_ -> FontSet_
forall a. Ptr a -> Ptr a
throwNull FontSet_
ret
CharSet
y <- CharSet_ -> IO CharSet
thawCharSet (CharSet_ -> IO CharSet) -> CharSet_ -> IO CharSet
forall a b. (a -> b) -> a -> b
$ CharSet_ -> CharSet_
forall a. Ptr a -> Ptr a
throwNull CharSet_
csp'
(FontSet, CharSet) -> IO (FontSet, CharSet)
forall (m :: * -> *) a. Monad m => a -> m a
return (FontSet
x, CharSet
y)
foreign import ccall "FcFontSort" fcFontSort ::
Config_ -> Pattern_ -> Bool -> CharSet_ -> Ptr Word8 -> IO FontSet_
fontRenderPrepare :: Config -> Pattern -> Pattern -> Pattern
fontRenderPrepare :: Config -> Pattern -> Pattern -> Pattern
fontRenderPrepare config :: Config
config pat :: Pattern
pat font :: Pattern
font = IO Pattern -> Pattern
forall a. IO a -> a
unsafePerformIO (IO Pattern -> Pattern) -> IO Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Config -> (Ptr Config' -> IO Pattern) -> IO Pattern
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO Pattern) -> IO Pattern)
-> (Ptr Config' -> IO Pattern) -> IO Pattern
forall a b. (a -> b) -> a -> b
$ \config' :: Ptr Config'
config' ->
Pattern -> (Pattern_ -> IO Pattern) -> IO Pattern
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pat ((Pattern_ -> IO Pattern) -> IO Pattern)
-> (Pattern_ -> IO Pattern) -> IO Pattern
forall a b. (a -> b) -> a -> b
$ \pat' :: Pattern_
pat' -> Pattern -> (Pattern_ -> IO Pattern) -> IO Pattern
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
font ((Pattern_ -> IO Pattern) -> IO Pattern)
-> (Pattern_ -> IO Pattern) -> IO Pattern
forall a b. (a -> b) -> a -> b
$ \font' :: Pattern_
font' -> do
Pattern_
ret <- Ptr Config' -> Pattern_ -> Pattern_ -> IO Pattern_
fcFontRenderPrepare Ptr Config'
config' Pattern_
pat' Pattern_
font'
IO Pattern_ -> IO Pattern
thawPattern_ (IO Pattern_ -> IO Pattern) -> IO Pattern_ -> IO Pattern
forall a b. (a -> b) -> a -> b
$ Pattern_ -> IO Pattern_
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pattern_ -> IO Pattern_) -> Pattern_ -> IO Pattern_
forall a b. (a -> b) -> a -> b
$ Pattern_ -> Pattern_
forall a. Ptr a -> Ptr a
throwNull Pattern_
ret
fontRenderPrepare' :: Pattern -> Pattern -> Pattern
fontRenderPrepare' :: Pattern -> Pattern -> Pattern
fontRenderPrepare' pat :: Pattern
pat font :: Pattern
font = IO Pattern -> Pattern
forall a. IO a -> a
unsafePerformIO (IO Pattern -> Pattern) -> IO Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern -> (Pattern_ -> IO Pattern) -> IO Pattern
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pat ((Pattern_ -> IO Pattern) -> IO Pattern)
-> (Pattern_ -> IO Pattern) -> IO Pattern
forall a b. (a -> b) -> a -> b
$ \pat' :: Pattern_
pat' ->
Pattern -> (Pattern_ -> IO Pattern) -> IO Pattern
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
font ((Pattern_ -> IO Pattern) -> IO Pattern)
-> (Pattern_ -> IO Pattern) -> IO Pattern
forall a b. (a -> b) -> a -> b
$ \font' :: Pattern_
font' -> do
Pattern_
ret <- Ptr Config' -> Pattern_ -> Pattern_ -> IO Pattern_
fcFontRenderPrepare Ptr Config'
forall a. Ptr a
nullPtr Pattern_
pat' Pattern_
font'
IO Pattern_ -> IO Pattern
thawPattern_ (IO Pattern_ -> IO Pattern) -> IO Pattern_ -> IO Pattern
forall a b. (a -> b) -> a -> b
$ Pattern_ -> IO Pattern_
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pattern_
ret
foreign import ccall "FcFontRenderPrepare" fcFontRenderPrepare ::
Config_ -> Pattern_ -> Pattern_ -> IO Pattern_
fontList :: Config -> Pattern -> ObjectSet -> FontSet
fontList :: Config -> Pattern -> StrList -> FontSet
fontList config :: Config
config p :: Pattern
p os :: StrList
os = IO FontSet -> FontSet
forall a. IO a -> a
unsafePerformIO (IO FontSet -> FontSet) -> IO FontSet -> FontSet
forall a b. (a -> b) -> a -> b
$ Config -> (Ptr Config' -> IO FontSet) -> IO FontSet
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO FontSet) -> IO FontSet)
-> (Ptr Config' -> IO FontSet) -> IO FontSet
forall a b. (a -> b) -> a -> b
$ \config' :: Ptr Config'
config' ->
Pattern -> (Pattern_ -> IO FontSet) -> IO FontSet
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p ((Pattern_ -> IO FontSet) -> IO FontSet)
-> (Pattern_ -> IO FontSet) -> IO FontSet
forall a b. (a -> b) -> a -> b
$ \p' :: Pattern_
p' -> StrList -> (ObjectSet_ -> IO FontSet) -> IO FontSet
forall a. StrList -> (ObjectSet_ -> IO a) -> IO a
withObjectSet StrList
os ((ObjectSet_ -> IO FontSet) -> IO FontSet)
-> (ObjectSet_ -> IO FontSet) -> IO FontSet
forall a b. (a -> b) -> a -> b
$ \os' :: ObjectSet_
os' -> do
FontSet_
ret <- Ptr Config' -> Pattern_ -> ObjectSet_ -> IO FontSet_
fcFontList Ptr Config'
config' Pattern_
p' ObjectSet_
os'
IO FontSet_ -> IO FontSet
thawFontSet_ (IO FontSet_ -> IO FontSet) -> IO FontSet_ -> IO FontSet
forall a b. (a -> b) -> a -> b
$ FontSet_ -> IO FontSet_
forall (f :: * -> *) a. Applicative f => a -> f a
pure FontSet_
ret
fontList' :: Pattern -> ObjectSet -> FontSet
fontList' :: Pattern -> StrList -> FontSet
fontList' p :: Pattern
p os :: StrList
os = IO FontSet -> FontSet
forall a. IO a -> a
unsafePerformIO (IO FontSet -> FontSet) -> IO FontSet -> FontSet
forall a b. (a -> b) -> a -> b
$ Pattern -> (Pattern_ -> IO FontSet) -> IO FontSet
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p ((Pattern_ -> IO FontSet) -> IO FontSet)
-> (Pattern_ -> IO FontSet) -> IO FontSet
forall a b. (a -> b) -> a -> b
$ \p' :: Pattern_
p' -> StrList -> (ObjectSet_ -> IO FontSet) -> IO FontSet
forall a. StrList -> (ObjectSet_ -> IO a) -> IO a
withObjectSet StrList
os ((ObjectSet_ -> IO FontSet) -> IO FontSet)
-> (ObjectSet_ -> IO FontSet) -> IO FontSet
forall a b. (a -> b) -> a -> b
$ \os' :: ObjectSet_
os' -> do
FontSet_
ret <- Ptr Config' -> Pattern_ -> ObjectSet_ -> IO FontSet_
fcFontList Ptr Config'
forall a. Ptr a
nullPtr Pattern_
p' ObjectSet_
os'
IO FontSet_ -> IO FontSet
thawFontSet_ (IO FontSet_ -> IO FontSet) -> IO FontSet_ -> IO FontSet
forall a b. (a -> b) -> a -> b
$ FontSet_ -> IO FontSet_
forall (f :: * -> *) a. Applicative f => a -> f a
pure FontSet_
ret
foreign import ccall "FcFontList" fcFontList ::
Config_ -> Pattern_ -> ObjectSet_ -> IO FontSet_
configParseAndLoad :: Config -> String -> Bool -> IO Bool
configParseAndLoad :: Config -> String -> Bool -> IO Bool
configParseAndLoad config :: Config
config name :: String
name complain :: Bool
complain = Config -> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO Bool) -> IO Bool)
-> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ \config' :: Ptr Config'
config' ->
String -> (CString -> IO Bool) -> IO Bool
forall a. String -> (CString -> IO a) -> IO a
withCString String
name ((CString -> IO Bool) -> IO Bool)
-> (CString -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ \name' :: CString
name' -> Ptr Config' -> CString -> Bool -> IO Bool
fcConfigParseAndLoad Ptr Config'
config' CString
name' Bool
complain
configParseAndLoad' :: String -> Bool -> IO Bool
configParseAndLoad' :: String -> Bool -> IO Bool
configParseAndLoad' name :: String
name complain :: Bool
complain =
String -> (CString -> IO Bool) -> IO Bool
forall a. String -> (CString -> IO a) -> IO a
withCString String
name ((CString -> IO Bool) -> IO Bool)
-> (CString -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ \name' :: CString
name' -> Ptr Config' -> CString -> Bool -> IO Bool
fcConfigParseAndLoad Ptr Config'
forall a. Ptr a
nullPtr CString
name' Bool
complain
foreign import ccall "FcConfigParseAndLoad" fcConfigParseAndLoad ::
Config_ -> CString -> Bool -> IO Bool
configParseAndLoadFromMemory :: Config -> String -> Bool -> IO Bool
configParseAndLoadFromMemory :: Config -> String -> Bool -> IO Bool
configParseAndLoadFromMemory config :: Config
config buffer :: String
buffer complain :: Bool
complain = Config -> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO Bool) -> IO Bool)
-> (Ptr Config' -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ \config' :: Ptr Config'
config' ->
String -> (CString -> IO Bool) -> IO Bool
forall a. String -> (CString -> IO a) -> IO a
withCString String
buffer ((CString -> IO Bool) -> IO Bool)
-> (CString -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ \buffer' :: CString
buffer' ->
Ptr Config' -> CString -> Bool -> IO Bool
fcConfigParseAndLoadFromMemory Ptr Config'
config' CString
buffer' Bool
complain
configParseAndLoadFromMemory' :: String -> Bool -> IO Bool
configParseAndLoadFromMemory' :: String -> Bool -> IO Bool
configParseAndLoadFromMemory' buffer :: String
buffer complain :: Bool
complain = String -> (CString -> IO Bool) -> IO Bool
forall a. String -> (CString -> IO a) -> IO a
withCString String
buffer ((CString -> IO Bool) -> IO Bool)
-> (CString -> IO Bool) -> IO Bool
forall a b. (a -> b) -> a -> b
$ \buffer' :: CString
buffer' ->
Ptr Config' -> CString -> Bool -> IO Bool
fcConfigParseAndLoadFromMemory Ptr Config'
forall a. Ptr a
nullPtr CString
buffer' Bool
complain
foreign import ccall "FcConfigParseAndLoadFromMemory" fcConfigParseAndLoadFromMemory ::
Config_ -> CString -> Bool -> IO Bool
configGetSysRoot :: Config -> IO String
configGetSysRoot :: Config -> IO String
configGetSysRoot = (Config -> (Ptr Config' -> IO String) -> IO String)
-> (Ptr Config' -> IO String) -> Config -> IO String
forall a b c. (a -> b -> c) -> b -> a -> c
flip Config -> (Ptr Config' -> IO String) -> IO String
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ((Ptr Config' -> IO String) -> Config -> IO String)
-> (Ptr Config' -> IO String) -> Config -> IO String
forall a b. (a -> b) -> a -> b
$ \config' :: Ptr Config'
config' -> do
CString
ret <- Ptr Config' -> IO CString
fcConfigGetSysRoot Ptr Config'
config'
CString -> IO String
peekCString (CString -> IO String) -> CString -> IO String
forall a b. (a -> b) -> a -> b
$ CString -> CString
forall a. Ptr a -> Ptr a
throwNull CString
ret
configGetSysRoot' :: IO String
configGetSysRoot' :: IO String
configGetSysRoot' = (CString -> IO String
peekCString (CString -> IO String)
-> (CString -> CString) -> CString -> IO String
forall b c a. (b -> c) -> (a -> b) -> a -> c
.CString -> CString
forall a. Ptr a -> Ptr a
throwNull) (CString -> IO String) -> IO CString -> IO String
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Config' -> IO CString
fcConfigGetSysRoot Ptr Config'
forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetSysRoot" fcConfigGetSysRoot :: Config_ -> IO CString
configSetSysRoot :: Config -> String -> IO ()
configSetSysRoot :: Config -> String -> IO ()
configSetSysRoot config :: Config
config val :: String
val = Config -> (Ptr Config' -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO ()) -> IO ())
-> (Ptr Config' -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \config' :: Ptr Config'
config' -> String -> (CString -> IO ()) -> IO ()
forall a. String -> (CString -> IO a) -> IO a
withCString String
val ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$
Ptr Config' -> CString -> IO ()
fcConfigSetSysRoot Ptr Config'
config'
configSetSysRoot' :: String -> IO ()
configSetSysRoot' :: String -> IO ()
configSetSysRoot' val :: String
val = String -> (CString -> IO ()) -> IO ()
forall a. String -> (CString -> IO a) -> IO a
withCString String
val ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ Ptr Config' -> CString -> IO ()
fcConfigSetSysRoot Ptr Config'
forall a. Ptr a
nullPtr
foreign import ccall "FcConfigSetSysRoot" fcConfigSetSysRoot :: Config_ -> CString -> IO ()
configGetFileInfo :: Config -> IO [(FilePath, String, Bool)]
configGetFileInfo :: Config -> IO [(String, String, Bool)]
configGetFileInfo config :: Config
config =
Config
-> (Ptr Config' -> IO [(String, String, Bool)])
-> IO [(String, String, Bool)]
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO [(String, String, Bool)])
-> IO [(String, String, Bool)])
-> (Ptr Config' -> IO [(String, String, Bool)])
-> IO [(String, String, Bool)]
forall a b. (a -> b) -> a -> b
$ \config' :: Ptr Config'
config' -> Int
-> (Ptr ConfigFileInfoIter' -> IO [(String, String, Bool)])
-> IO [(String, String, Bool)]
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
configFileInfoIter'Size ((Ptr ConfigFileInfoIter' -> IO [(String, String, Bool)])
-> IO [(String, String, Bool)])
-> (Ptr ConfigFileInfoIter' -> IO [(String, String, Bool)])
-> IO [(String, String, Bool)]
forall a b. (a -> b) -> a -> b
$ \iter' :: Ptr ConfigFileInfoIter'
iter' -> do
Ptr Config' -> Ptr ConfigFileInfoIter' -> IO ()
fcConfigFileInfoIterInit Ptr Config'
config' Ptr ConfigFileInfoIter'
iter'
let readEnt :: IO (Maybe (String, String, Bool))
readEnt = (Ptr CString -> IO (Maybe (String, String, Bool)))
-> IO (Maybe (String, String, Bool))
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CString -> IO (Maybe (String, String, Bool)))
-> IO (Maybe (String, String, Bool)))
-> (Ptr CString -> IO (Maybe (String, String, Bool)))
-> IO (Maybe (String, String, Bool))
forall a b. (a -> b) -> a -> b
$ \name' :: Ptr CString
name' -> (Ptr CString -> IO (Maybe (String, String, Bool)))
-> IO (Maybe (String, String, Bool))
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CString -> IO (Maybe (String, String, Bool)))
-> IO (Maybe (String, String, Bool)))
-> (Ptr CString -> IO (Maybe (String, String, Bool)))
-> IO (Maybe (String, String, Bool))
forall a b. (a -> b) -> a -> b
$ \description' :: Ptr CString
description' -> (Ptr Bool -> IO (Maybe (String, String, Bool)))
-> IO (Maybe (String, String, Bool))
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Bool -> IO (Maybe (String, String, Bool)))
-> IO (Maybe (String, String, Bool)))
-> (Ptr Bool -> IO (Maybe (String, String, Bool)))
-> IO (Maybe (String, String, Bool))
forall a b. (a -> b) -> a -> b
$ \enabled' :: Ptr Bool
enabled' -> do {
Bool
ok <- Ptr Config'
-> Ptr ConfigFileInfoIter'
-> Ptr CString
-> Ptr CString
-> Ptr Bool
-> IO Bool
fcConfigFileInfoIterGet Ptr Config'
config' Ptr ConfigFileInfoIter'
iter' Ptr CString
name' Ptr CString
description' Ptr Bool
enabled';
if Bool
ok then do
String
name <- CString -> IO String
peekCString (CString -> IO String) -> IO CString -> IO String
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
name'
String
description <- CString -> IO String
peekCString (CString -> IO String) -> IO CString -> IO String
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
description'
Bool
enabled <- Ptr Bool -> IO Bool
forall a. Storable a => Ptr a -> IO a
peek Ptr Bool
enabled'
Maybe (String, String, Bool) -> IO (Maybe (String, String, Bool))
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe (String, String, Bool) -> IO (Maybe (String, String, Bool)))
-> Maybe (String, String, Bool)
-> IO (Maybe (String, String, Bool))
forall a b. (a -> b) -> a -> b
$ (String, String, Bool) -> Maybe (String, String, Bool)
forall a. a -> Maybe a
Just (String
name, String
description, Bool
enabled)
else Maybe (String, String, Bool) -> IO (Maybe (String, String, Bool))
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (String, String, Bool)
forall a. Maybe a
Nothing}
let go :: IO [(String, String, Bool)]
go = do {
Maybe (String, String, Bool)
ent' <- IO (Maybe (String, String, Bool))
readEnt;
case Maybe (String, String, Bool)
ent' of
Just ent :: (String, String, Bool)
ent -> do
Bool
ok <- Ptr Config' -> Ptr ConfigFileInfoIter' -> IO Bool
fcConfigFileInfoIterNext Ptr Config'
config' Ptr ConfigFileInfoIter'
iter'
[(String, String, Bool)]
ents <- if Bool
ok then IO [(String, String, Bool)]
go else [(String, String, Bool)] -> IO [(String, String, Bool)]
forall (m :: * -> *) a. Monad m => a -> m a
return []
[(String, String, Bool)] -> IO [(String, String, Bool)]
forall (m :: * -> *) a. Monad m => a -> m a
return ((String, String, Bool)
ent (String, String, Bool)
-> [(String, String, Bool)] -> [(String, String, Bool)]
forall a. a -> [a] -> [a]
: [(String, String, Bool)]
ents)
Nothing -> [(String, String, Bool)] -> IO [(String, String, Bool)]
forall (m :: * -> *) a. Monad m => a -> m a
return []}
IO [(String, String, Bool)]
go
configGetFileInfo' :: IO [(FilePath, String, Bool)]
configGetFileInfo' :: IO [(String, String, Bool)]
configGetFileInfo' = IO Config
configGetCurrent IO Config
-> (Config -> IO [(String, String, Bool)])
-> IO [(String, String, Bool)]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Config -> IO [(String, String, Bool)]
configGetFileInfo
data ConfigFileInfoIter'
foreign import ccall "size_ConfigFileInfoIter" configFileInfoIter'Size :: Int
type ConfigFileInfoIter_ = Ptr ConfigFileInfoIter'
foreign import ccall "FcConfigFileInfoIterInit" fcConfigFileInfoIterInit ::
Config_ -> ConfigFileInfoIter_ -> IO ()
foreign import ccall "FcConfigFileInfoIterNext" fcConfigFileInfoIterNext ::
Config_ -> ConfigFileInfoIter_ -> IO Bool
foreign import ccall "FcConfigFileInfoIterGet" fcConfigFileInfoIterGet ::
Config_ -> ConfigFileInfoIter_ -> Ptr CString -> Ptr CString -> Ptr Bool -> IO Bool
configStrsFunc :: (Config_ -> IO StrList_) -> Config -> IO StrList
configStrsFunc :: (Ptr Config' -> IO StrList_) -> Config -> IO StrList
configStrsFunc cb :: Ptr Config' -> IO StrList_
cb config :: Config
config = IO StrList_ -> IO StrList
thawStrList_ (IO StrList_ -> IO StrList) -> IO StrList_ -> IO StrList
forall a b. (a -> b) -> a -> b
$ Config -> (Ptr Config' -> IO StrList_) -> IO StrList_
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config Ptr Config' -> IO StrList_
cb