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 = forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
newForeignPtr FunPtr (Config_ -> IO ())
fcConfigDestroy forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall a. Ptr a -> Ptr a
throwNull forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO Config_
fcConfigCreate
foreign import ccall "FcConfigCreate" fcConfigCreate :: IO Config_
ptr2config :: Config_ -> IO Config
ptr2config = forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
newForeignPtr FunPtr (Config_ -> IO ())
fcConfigDestroy
foreign import ccall "&FcConfigDestroy" fcConfigDestroy :: FunPtr (Config_ -> IO ())
configSetCurrent :: Config -> IO ()
configSetCurrent :: Config -> IO ()
configSetCurrent Config
config = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ Config_ -> IO Bool
fcConfigSetCurrent)
foreign import ccall "FcConfigSetCurrent" fcConfigSetCurrent :: Config_ -> IO Bool
configGetCurrent :: IO Config
configGetCurrent :: IO Config
configGetCurrent = (forall a. Ptr a -> Ptr a
throwNull forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Config_ -> IO Config_
fcConfigReference forall a. Ptr a
nullPtr) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
newForeignPtr FunPtr (Config_ -> IO ())
fcConfigDestroy
foreign import ccall "FcConfigReference" fcConfigReference :: Config_ -> IO Config_
configUptoDate :: Config -> IO Bool
configUptoDate :: Config -> IO Bool
configUptoDate Config
config = forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ 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 forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing else forall a. a -> Maybe a
Just 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 = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ Config_ -> IO Bool
fcConfigBuildFonts)
configBuildFonts' :: IO ()
configBuildFonts' :: IO ()
configBuildFonts' = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Config_ -> IO Bool
fcConfigBuildFonts forall a. Ptr a
nullPtr
foreign import ccall "FcConfigBuildFonts" fcConfigBuildFonts :: Config_ -> IO Bool
configGetConfigDirs :: Config -> IO StrList
configGetConfigDirs :: Config -> IO StrList
configGetConfigDirs = (Config_ -> IO StrList_) -> Config -> IO StrList
configStrsFunc Config_ -> IO StrList_
fcConfigGetConfigDirs
configGetConfigDirs' :: IO StrList
configGetConfigDirs' :: IO StrList
configGetConfigDirs' = StrList_ -> IO StrList
thawStrList forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Config_ -> IO StrList_
fcConfigGetConfigDirs forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetConfigDirs" fcConfigGetConfigDirs :: Config_ -> IO StrList_
configGetFontDirs :: Config -> IO StrList
configGetFontDirs :: Config -> IO StrList
configGetFontDirs = (Config_ -> IO StrList_) -> Config -> IO StrList
configStrsFunc Config_ -> IO StrList_
fcConfigGetFontDirs
configGetFontDirs' :: IO StrList
configGetFontDirs' :: IO StrList
configGetFontDirs' = IO StrList_ -> IO StrList
thawStrList_ forall a b. (a -> b) -> a -> b
$ Config_ -> IO StrList_
fcConfigGetFontDirs forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetFontDirs" fcConfigGetFontDirs :: Config_ -> IO StrList_
configGetConfigFiles :: Config -> IO StrList
configGetConfigFiles :: Config -> IO StrList
configGetConfigFiles = (Config_ -> IO StrList_) -> Config -> IO StrList
configStrsFunc Config_ -> IO StrList_
fcConfigGetConfigFiles
configGetConfigFiles' :: IO StrList
configGetConfigFiles' :: IO StrList
configGetConfigFiles' = IO StrList_ -> IO StrList
thawStrList_ forall a b. (a -> b) -> a -> b
$ Config_ -> IO StrList_
fcConfigGetConfigFiles forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetConfigFiles" fcConfigGetConfigFiles :: Config_ -> IO StrList_
configGetCacheDirs :: Config -> IO StrList
configGetCacheDirs :: Config -> IO StrList
configGetCacheDirs = (Config_ -> IO StrList_) -> Config -> IO StrList
configStrsFunc Config_ -> IO StrList_
fcConfigGetCacheDirs
configGetCacheDirs' :: IO StrList
configGetCacheDirs' :: IO StrList
configGetCacheDirs' = IO StrList_ -> IO StrList
thawStrList_ forall a b. (a -> b) -> a -> b
$ Config_ -> IO StrList_
fcConfigGetCacheDirs 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]
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
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
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]
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 SetName
set = do
FontSet_
ret <- forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ forall a b c. (a -> b -> c) -> b -> a -> c
flip Config_ -> Int -> IO FontSet_
fcConfigGetFonts forall a b. (a -> b) -> a -> b
$ forall a. Enum a => a -> Int
fromEnum SetName
set
FontSet_ -> IO FontSet
thawFontSet forall a b. (a -> b) -> a -> b
$ forall a. Ptr a -> Ptr a
throwNull FontSet_
ret
configGetFonts' :: SetName -> IO FontSet
configGetFonts' :: SetName -> IO FontSet
configGetFonts' SetName
set = do
FontSet_
ret <- Config_ -> Int -> IO FontSet_
fcConfigGetFonts forall a. Ptr a
nullPtr forall a b. (a -> b) -> a -> b
$ forall a. Enum a => a -> Int
fromEnum SetName
set
FontSet_ -> IO FontSet
thawFontSet forall a b. (a -> b) -> a -> b
$ 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 = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr forall a b. (a -> b) -> a -> b
$ Config_ -> IO Int
fcConfigGetRescanInterval
configGetRescanInterval' :: IO Int
configGetRescanInterval' :: IO Int
configGetRescanInterval' = Config_ -> IO Int
fcConfigGetRescanInterval forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetRescanInterval" fcConfigGetRescanInterval ::
Config_ -> IO Int
configSetRescanInterval :: Config -> Int -> IO ()
configSetRescanInterval :: Config -> Int -> IO ()
configSetRescanInterval Config
config Int
val =
Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ forall a b c. (a -> b -> c) -> b -> a -> c
flip Config_ -> Int -> IO Bool
fcConfigSetRescanInterval Int
val)
configSetRescanInterval' :: Int -> IO ()
configSetRescanInterval' :: Int -> IO ()
configSetRescanInterval' Int
v = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Config_ -> Int -> IO Bool
fcConfigSetRescanInterval 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 String
file = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<
(forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' -> forall a. String -> (CString -> IO a) -> IO a
withCString String
file forall a b. (a -> b) -> a -> b
$ \CString
file' ->
Config_ -> CString -> IO Bool
fcConfigAppFontAddFile Config_
config' CString
file')
configAppFontAddFile' :: String -> IO ()
configAppFontAddFile' :: String -> IO ()
configAppFontAddFile' String
file =
Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall a. String -> (CString -> IO a) -> IO a
withCString String
file forall a b. (a -> b) -> a -> b
$ Config_ -> CString -> IO Bool
fcConfigAppFontAddFile 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 String
file = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<
(forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' -> forall a. String -> (CString -> IO a) -> IO a
withCString String
file forall a b. (a -> b) -> a -> b
$ Config_ -> CString -> IO Bool
fcConfigAppFontAddDir Config_
config')
configAppFontAddDir' :: String -> IO ()
configAppFontAddDir' :: String -> IO ()
configAppFontAddDir' String
v = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall a. String -> (CString -> IO a) -> IO a
withCString String
v forall a b. (a -> b) -> a -> b
$ Config_ -> CString -> IO Bool
fcConfigAppFontAddDir forall a. Ptr a
nullPtr)
foreign import ccall "FcConfigAppFontAddDir" fcConfigAppFontAddDir ::
Config_ -> CString -> IO Bool
configAppFontClear :: Config -> IO ()
configAppFontClear :: Config -> IO ()
configAppFontClear Config
config = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config Config_ -> IO Bool
fcConfigAppFontClear
configAppFontClear' :: IO ()
configAppFontClear' :: IO ()
configAppFontClear' = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Config_ -> IO Bool
fcConfigAppFontClear 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]
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 Pattern
p Pattern
p_pat MatchKind
kind = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' -> forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p forall a b. (a -> b) -> a -> b
$ \Pattern_
p' ->
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p_pat forall a b. (a -> b) -> a -> b
$ \Pattern_
p_pat' -> do
Bool
ok <- Config_ -> Pattern_ -> Pattern_ -> Int -> IO Bool
fcConfigSubstituteWithPat Config_
config' Pattern_
p' Pattern_
p_pat' forall a b. (a -> b) -> a -> b
$ 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' Pattern
p Pattern
p_pat MatchKind
kind = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p forall a b. (a -> b) -> a -> b
$ \Pattern_
p' -> forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p_pat forall a b. (a -> b) -> a -> b
$ \Pattern_
p_pat' -> do
Bool
ok <- Config_ -> Pattern_ -> Pattern_ -> Int -> IO Bool
fcConfigSubstituteWithPat forall a. Ptr a
nullPtr Pattern_
p' Pattern_
p_pat' forall a b. (a -> b) -> a -> b
$ 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 Pattern
p MatchKind
kind = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' -> forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p forall a b. (a -> b) -> a -> b
$ \Pattern_
p' -> do
Bool
ok <- Config_ -> Pattern_ -> Int -> IO Bool
fcConfigSubstitute Config_
config' Pattern_
p' forall a b. (a -> b) -> a -> b
$ 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' Pattern
p MatchKind
kind = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p forall a b. (a -> b) -> a -> b
$ \Pattern_
p' -> do
Bool
ok <- Config_ -> Pattern_ -> Int -> IO Bool
fcConfigSubstitute forall a. Ptr a
nullPtr Pattern_
p' forall a b. (a -> b) -> a -> b
$ 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 Pattern
pattern = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' ->
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern forall a b. (a -> b) -> a -> b
$ \Pattern_
pattern' -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr Word8
res' -> do
Pattern_
ret <- Config_ -> Pattern_ -> Ptr Word8 -> IO Pattern_
fcFontMatch Config_
config' Pattern_
pattern' Ptr Word8
res'
forall a. Ptr Word8 -> IO a -> IO (Maybe a)
throwPtr Ptr Word8
res' forall a b. (a -> b) -> a -> b
$ IO Pattern_ -> IO Pattern
thawPattern_ forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Applicative f => a -> f a
pure Pattern_
ret
fontMatch' :: Pattern -> Maybe Pattern
fontMatch' :: Pattern -> Maybe Pattern
fontMatch' Pattern
pattern = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern forall a b. (a -> b) -> a -> b
$ \Pattern_
pattern' -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr Word8
res' -> do
Pattern_
ret <- Config_ -> Pattern_ -> Ptr Word8 -> IO Pattern_
fcFontMatch forall a. Ptr a
nullPtr Pattern_
pattern' Ptr Word8
res'
forall a. Ptr Word8 -> IO a -> IO (Maybe a)
throwPtr Ptr Word8
res' forall a b. (a -> b) -> a -> b
$ IO Pattern_ -> IO Pattern
thawPattern_ forall a b. (a -> b) -> a -> b
$ 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 Pattern
pattern Bool
trim = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' ->
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern forall a b. (a -> b) -> a -> b
$ \Pattern_
pattern' -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr CharSet_
csp' -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr Word8
res' -> do
FontSet_
ret <- Config_
-> Pattern_ -> Bool -> Ptr CharSet_ -> Ptr Word8 -> IO FontSet_
fcFontSort Config_
config' Pattern_
pattern' Bool
trim Ptr CharSet_
csp' Ptr Word8
res'
forall a. Ptr Word8 -> IO a -> IO (Maybe a)
throwPtr Ptr Word8
res' forall a b. (a -> b) -> a -> b
$ do
FontSet
x <- IO FontSet_ -> IO FontSet
thawFontSet_ forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Applicative f => a -> f a
pure FontSet_
ret
CharSet
y <- Ptr CharSet_ -> IO CharSet
thawCharSet' Ptr CharSet_
csp'
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 Bool
trim = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern forall a b. (a -> b) -> a -> b
$ \Pattern_
pattern' ->
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr CharSet_
csp' -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr Word8
res' -> do
FontSet_
ret <- Config_
-> Pattern_ -> Bool -> Ptr CharSet_ -> Ptr Word8 -> IO FontSet_
fcFontSort forall a. Ptr a
nullPtr Pattern_
pattern' Bool
trim Ptr CharSet_
csp' Ptr Word8
res'
forall a. Ptr Word8 -> IO a -> IO (Maybe a)
throwPtr Ptr Word8
res' forall a b. (a -> b) -> a -> b
$ do
FontSet
x <- IO FontSet_ -> IO FontSet
thawFontSet_ forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Applicative f => a -> f a
pure FontSet_
ret
CharSet
y <- Ptr CharSet_ -> IO CharSet
thawCharSet' Ptr CharSet_
csp'
forall (m :: * -> *) a. Monad m => a -> m a
return (FontSet
x, CharSet
y)
foreign import ccall "FcFontSort" fcFontSort ::
Config_ -> Pattern_ -> Bool -> Ptr CharSet_ -> Ptr Word8 -> IO FontSet_
fontRenderPrepare :: Config -> Pattern -> Pattern -> Pattern
fontRenderPrepare :: Config -> Pattern -> Pattern -> Pattern
fontRenderPrepare Config
config Pattern
pat Pattern
font = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' ->
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pat forall a b. (a -> b) -> a -> b
$ \Pattern_
pat' -> forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
font forall a b. (a -> b) -> a -> b
$ \Pattern_
font' -> do
Pattern_
ret <- Config_ -> Pattern_ -> Pattern_ -> IO Pattern_
fcFontRenderPrepare Config_
config' Pattern_
pat' Pattern_
font'
IO Pattern_ -> IO Pattern
thawPattern_ forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. Ptr a -> Ptr a
throwNull Pattern_
ret
fontRenderPrepare' :: Pattern -> Pattern -> Pattern
fontRenderPrepare' :: Pattern -> Pattern -> Pattern
fontRenderPrepare' Pattern
pat Pattern
font = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pat forall a b. (a -> b) -> a -> b
$ \Pattern_
pat' ->
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
font forall a b. (a -> b) -> a -> b
$ \Pattern_
font' -> do
Pattern_
ret <- Config_ -> Pattern_ -> Pattern_ -> IO Pattern_
fcFontRenderPrepare forall a. Ptr a
nullPtr Pattern_
pat' Pattern_
font'
IO Pattern_ -> IO Pattern
thawPattern_ forall a b. (a -> b) -> a -> b
$ 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 Pattern
p StrList
os = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' ->
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p forall a b. (a -> b) -> a -> b
$ \Pattern_
p' -> forall a. StrList -> (ObjectSet_ -> IO a) -> IO a
withObjectSet StrList
os forall a b. (a -> b) -> a -> b
$ \ObjectSet_
os' -> do
FontSet_
ret <- Config_ -> Pattern_ -> ObjectSet_ -> IO FontSet_
fcFontList Config_
config' Pattern_
p' ObjectSet_
os'
IO FontSet_ -> IO FontSet
thawFontSet_ forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Applicative f => a -> f a
pure FontSet_
ret
fontList' :: Pattern -> ObjectSet -> FontSet
fontList' :: Pattern -> StrList -> FontSet
fontList' Pattern
p StrList
os = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p forall a b. (a -> b) -> a -> b
$ \Pattern_
p' -> forall a. StrList -> (ObjectSet_ -> IO a) -> IO a
withObjectSet StrList
os forall a b. (a -> b) -> a -> b
$ \ObjectSet_
os' -> do
FontSet_
ret <- Config_ -> Pattern_ -> ObjectSet_ -> IO FontSet_
fcFontList forall a. Ptr a
nullPtr Pattern_
p' ObjectSet_
os'
IO FontSet_ -> IO FontSet
thawFontSet_ forall a b. (a -> b) -> a -> b
$ 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 String
name Bool
complain = forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' ->
forall a. String -> (CString -> IO a) -> IO a
withCString String
name forall a b. (a -> b) -> a -> b
$ \CString
name' -> Config_ -> CString -> Bool -> IO Bool
fcConfigParseAndLoad Config_
config' CString
name' Bool
complain
configParseAndLoad' :: String -> Bool -> IO Bool
configParseAndLoad' :: String -> Bool -> IO Bool
configParseAndLoad' String
name Bool
complain =
forall a. String -> (CString -> IO a) -> IO a
withCString String
name forall a b. (a -> b) -> a -> b
$ \CString
name' -> Config_ -> CString -> Bool -> IO Bool
fcConfigParseAndLoad 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 String
buffer Bool
complain = forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' ->
forall a. String -> (CString -> IO a) -> IO a
withCString String
buffer forall a b. (a -> b) -> a -> b
$ \CString
buffer' ->
Config_ -> CString -> Bool -> IO Bool
fcConfigParseAndLoadFromMemory Config_
config' CString
buffer' Bool
complain
configParseAndLoadFromMemory' :: String -> Bool -> IO Bool
configParseAndLoadFromMemory' :: String -> Bool -> IO Bool
configParseAndLoadFromMemory' String
buffer Bool
complain = forall a. String -> (CString -> IO a) -> IO a
withCString String
buffer forall a b. (a -> b) -> a -> b
$ \CString
buffer' ->
Config_ -> CString -> Bool -> IO Bool
fcConfigParseAndLoadFromMemory 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 = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr forall a b. (a -> b) -> a -> b
$ \Config_
config' -> do
CString
ret <- Config_ -> IO CString
fcConfigGetSysRoot Config_
config'
CString -> IO String
peekCString forall a b. (a -> b) -> a -> b
$ forall a. Ptr a -> Ptr a
throwNull CString
ret
configGetSysRoot' :: IO String
configGetSysRoot' :: IO String
configGetSysRoot' = (CString -> IO String
peekCString forall b c a. (b -> c) -> (a -> b) -> a -> c
.forall a. Ptr a -> Ptr a
throwNull) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Config_ -> IO CString
fcConfigGetSysRoot forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetSysRoot" fcConfigGetSysRoot :: Config_ -> IO CString
configSetSysRoot :: Config -> String -> IO ()
configSetSysRoot :: Config -> String -> IO ()
configSetSysRoot Config
config String
val = forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' -> forall a. String -> (CString -> IO a) -> IO a
withCString String
val forall a b. (a -> b) -> a -> b
$
Config_ -> CString -> IO ()
fcConfigSetSysRoot Config_
config'
configSetSysRoot' :: String -> IO ()
configSetSysRoot' :: String -> IO ()
configSetSysRoot' String
val = forall a. String -> (CString -> IO a) -> IO a
withCString String
val forall a b. (a -> b) -> a -> b
$ Config_ -> CString -> IO ()
fcConfigSetSysRoot 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 =
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' -> forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
configFileInfoIter'Size forall a b. (a -> b) -> a -> b
$ \Ptr ConfigFileInfoIter'
iter' -> do
Config_ -> Ptr ConfigFileInfoIter' -> IO ()
fcConfigFileInfoIterInit Config_
config' Ptr ConfigFileInfoIter'
iter'
let readEnt :: IO (Maybe (String, String, Bool))
readEnt = forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr CString
name' -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr CString
description' -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr Bool
enabled' -> do {
Bool
ok <- Config_
-> Ptr ConfigFileInfoIter'
-> Ptr CString
-> Ptr CString
-> Ptr Bool
-> IO Bool
fcConfigFileInfoIterGet 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 forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall a. Storable a => Ptr a -> IO a
peek Ptr CString
name'
String
description <- CString -> IO String
peekCString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall a. Storable a => Ptr a -> IO a
peek Ptr CString
description'
Bool
enabled <- forall a. Storable a => Ptr a -> IO a
peek Ptr Bool
enabled'
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (String
name, String
description, Bool
enabled)
else forall (m :: * -> *) a. Monad m => a -> m a
return 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 (String, String, Bool)
ent -> do
Bool
ok <- Config_ -> Ptr ConfigFileInfoIter' -> IO Bool
fcConfigFileInfoIterNext Config_
config' Ptr ConfigFileInfoIter'
iter'
[(String, String, Bool)]
ents <- if Bool
ok then IO [(String, String, Bool)]
go else forall (m :: * -> *) a. Monad m => a -> m a
return []
forall (m :: * -> *) a. Monad m => a -> m a
return ((String, String, Bool)
ent forall a. a -> [a] -> [a]
: [(String, String, Bool)]
ents)
Maybe (String, String, Bool)
Nothing -> 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 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 :: (Config_ -> IO StrList_) -> Config -> IO StrList
configStrsFunc Config_ -> IO StrList_
cb Config
config = IO StrList_ -> IO StrList
thawStrList_ forall a b. (a -> b) -> a -> b
$ forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config Config_ -> IO StrList_
cb