module Graphics.Text.Font.Choose.FontSet.API where
import Graphics.Text.Font.Choose.FontSet
import Graphics.Text.Font.Choose.Pattern
import Graphics.Text.Font.Choose.Config
import Graphics.Text.Font.Choose.ObjectSet
import Graphics.Text.Font.Choose.CharSet
import Graphics.Text.Font.Choose.Result (Word8, throwPtr)
import Foreign.Ptr (Ptr, castPtr, nullPtr)
import Foreign.ForeignPtr (withForeignPtr)
import Foreign.Marshal.Alloc (alloca)
import System.IO.Unsafe (unsafePerformIO)
fontSetList :: Config -> [FontSet] -> Pattern -> ObjectSet -> FontSet
fontSetList :: Config -> [FontSet] -> Pattern -> ObjectSet -> FontSet
fontSetList config :: Config
config fontss :: [FontSet]
fontss pattern :: Pattern
pattern objs :: ObjectSet
objs = 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' ->
[FontSet] -> (Ptr FontSet_ -> Int -> IO FontSet) -> IO FontSet
forall a. [FontSet] -> (Ptr FontSet_ -> Int -> IO a) -> IO a
withFontSets [FontSet]
fontss ((Ptr FontSet_ -> Int -> IO FontSet) -> IO FontSet)
-> (Ptr FontSet_ -> Int -> IO FontSet) -> IO FontSet
forall a b. (a -> b) -> a -> b
$ \fontss' :: Ptr FontSet_
fontss' n :: Int
n -> Pattern -> (Pattern_ -> IO FontSet) -> IO FontSet
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern ((Pattern_ -> IO FontSet) -> IO FontSet)
-> (Pattern_ -> IO FontSet) -> IO FontSet
forall a b. (a -> b) -> a -> b
$ \pattern' :: Pattern_
pattern' ->
ObjectSet -> (ObjectSet_ -> IO FontSet) -> IO FontSet
forall a. ObjectSet -> (ObjectSet_ -> IO a) -> IO a
withObjectSet ObjectSet
objs ((ObjectSet_ -> IO FontSet) -> IO FontSet)
-> (ObjectSet_ -> IO FontSet) -> IO FontSet
forall a b. (a -> b) -> a -> b
$ \objs' :: ObjectSet_
objs' ->
IO FontSet_ -> IO FontSet
thawFontSet_ (IO FontSet_ -> IO FontSet) -> IO FontSet_ -> IO FontSet
forall a b. (a -> b) -> a -> b
$ Ptr Config'
-> Ptr FontSet_ -> Int -> Pattern_ -> ObjectSet_ -> IO FontSet_
fcFontSetList Ptr Config'
config' Ptr FontSet_
fontss' Int
n Pattern_
pattern' ObjectSet_
objs'
fontSetList' :: [FontSet] -> Pattern -> ObjectSet -> FontSet
fontSetList' :: [FontSet] -> Pattern -> ObjectSet -> FontSet
fontSetList' fontss :: [FontSet]
fontss pattern :: Pattern
pattern objs :: ObjectSet
objs = IO FontSet -> FontSet
forall a. IO a -> a
unsafePerformIO (IO FontSet -> FontSet) -> IO FontSet -> FontSet
forall a b. (a -> b) -> a -> b
$ [FontSet] -> (Ptr FontSet_ -> Int -> IO FontSet) -> IO FontSet
forall a. [FontSet] -> (Ptr FontSet_ -> Int -> IO a) -> IO a
withFontSets [FontSet]
fontss ((Ptr FontSet_ -> Int -> IO FontSet) -> IO FontSet)
-> (Ptr FontSet_ -> Int -> IO FontSet) -> IO FontSet
forall a b. (a -> b) -> a -> b
$ \fontss' :: Ptr FontSet_
fontss' n :: Int
n ->
Pattern -> (Pattern_ -> IO FontSet) -> IO FontSet
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern ((Pattern_ -> IO FontSet) -> IO FontSet)
-> (Pattern_ -> IO FontSet) -> IO FontSet
forall a b. (a -> b) -> a -> b
$ \pattern' :: Pattern_
pattern' -> ObjectSet -> (ObjectSet_ -> IO FontSet) -> IO FontSet
forall a. ObjectSet -> (ObjectSet_ -> IO a) -> IO a
withObjectSet ObjectSet
objs ((ObjectSet_ -> IO FontSet) -> IO FontSet)
-> (ObjectSet_ -> IO FontSet) -> IO FontSet
forall a b. (a -> b) -> a -> b
$ \objs' :: ObjectSet_
objs' ->
IO FontSet_ -> IO FontSet
thawFontSet_ (IO FontSet_ -> IO FontSet) -> IO FontSet_ -> IO FontSet
forall a b. (a -> b) -> a -> b
$ Ptr Config'
-> Ptr FontSet_ -> Int -> Pattern_ -> ObjectSet_ -> IO FontSet_
fcFontSetList Ptr Config'
forall a. Ptr a
nullPtr Ptr FontSet_
fontss' Int
n Pattern_
pattern' ObjectSet_
objs'
foreign import ccall "FcFontSetList" fcFontSetList ::
Config_ -> Ptr FontSet_ -> Int -> Pattern_ -> ObjectSet_ -> IO FontSet_
fontSetMatch :: Config -> [FontSet] -> Pattern -> Maybe Pattern
fontSetMatch :: Config -> [FontSet] -> Pattern -> Maybe Pattern
fontSetMatch config :: Config
config fontss :: [FontSet]
fontss 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' ->
[FontSet]
-> (Ptr FontSet_ -> Int -> IO (Maybe Pattern))
-> IO (Maybe Pattern)
forall a. [FontSet] -> (Ptr FontSet_ -> Int -> IO a) -> IO a
withFontSets [FontSet]
fontss ((Ptr FontSet_ -> Int -> IO (Maybe Pattern)) -> IO (Maybe Pattern))
-> (Ptr FontSet_ -> Int -> IO (Maybe Pattern))
-> IO (Maybe Pattern)
forall a b. (a -> b) -> a -> b
$ \fontss' :: Ptr FontSet_
fontss' n :: Int
n -> 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'
-> Ptr FontSet_ -> Int -> Pattern_ -> Ptr Word8 -> IO Pattern_
fcFontSetMatch Ptr Config'
config' Ptr FontSet_
fontss' Int
n 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
fontSetMatch' :: [FontSet] -> Pattern -> Maybe Pattern
fontSetMatch' :: [FontSet] -> Pattern -> Maybe Pattern
fontSetMatch' fontss :: [FontSet]
fontss 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
$ [FontSet]
-> (Ptr FontSet_ -> Int -> IO (Maybe Pattern))
-> IO (Maybe Pattern)
forall a. [FontSet] -> (Ptr FontSet_ -> Int -> IO a) -> IO a
withFontSets [FontSet]
fontss ((Ptr FontSet_ -> Int -> IO (Maybe Pattern)) -> IO (Maybe Pattern))
-> (Ptr FontSet_ -> Int -> IO (Maybe Pattern))
-> IO (Maybe Pattern)
forall a b. (a -> b) -> a -> b
$ \fontss' :: Ptr FontSet_
fontss' n :: Int
n ->
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'
-> Ptr FontSet_ -> Int -> Pattern_ -> Ptr Word8 -> IO Pattern_
fcFontSetMatch Ptr Config'
forall a. Ptr a
nullPtr Ptr FontSet_
fontss' Int
n 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 "FcFontSetMatch" fcFontSetMatch ::
Config_ -> Ptr FontSet_ -> Int -> Pattern_ -> Ptr Word8 -> IO Pattern_
fontSetSort :: Config -> [FontSet] -> Pattern -> Bool -> CharSet -> Maybe FontSet
fontSetSort :: Config -> [FontSet] -> Pattern -> Bool -> CharSet -> Maybe FontSet
fontSetSort config :: Config
config fontss :: [FontSet]
fontss pattern :: Pattern
pattern trim :: Bool
trim csp :: CharSet
csp = IO (Maybe FontSet) -> Maybe FontSet
forall a. IO a -> a
unsafePerformIO (IO (Maybe FontSet) -> Maybe FontSet)
-> IO (Maybe FontSet) -> Maybe FontSet
forall a b. (a -> b) -> a -> b
$
Config -> (Ptr Config' -> IO (Maybe FontSet)) -> IO (Maybe FontSet)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config ((Ptr Config' -> IO (Maybe FontSet)) -> IO (Maybe FontSet))
-> (Ptr Config' -> IO (Maybe FontSet)) -> IO (Maybe FontSet)
forall a b. (a -> b) -> a -> b
$ \config' :: Ptr Config'
config' -> [FontSet]
-> (Ptr FontSet_ -> Int -> IO (Maybe FontSet))
-> IO (Maybe FontSet)
forall a. [FontSet] -> (Ptr FontSet_ -> Int -> IO a) -> IO a
withFontSets [FontSet]
fontss ((Ptr FontSet_ -> Int -> IO (Maybe FontSet)) -> IO (Maybe FontSet))
-> (Ptr FontSet_ -> Int -> IO (Maybe FontSet))
-> IO (Maybe FontSet)
forall a b. (a -> b) -> a -> b
$ \fontss' :: Ptr FontSet_
fontss' n :: Int
n ->
Pattern -> (Pattern_ -> IO (Maybe FontSet)) -> IO (Maybe FontSet)
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern ((Pattern_ -> IO (Maybe FontSet)) -> IO (Maybe FontSet))
-> (Pattern_ -> IO (Maybe FontSet)) -> IO (Maybe FontSet)
forall a b. (a -> b) -> a -> b
$ \pattern' :: Pattern_
pattern' -> CharSet -> (CharSet_ -> IO (Maybe FontSet)) -> IO (Maybe FontSet)
forall a. CharSet -> (CharSet_ -> IO a) -> IO a
withCharSet CharSet
csp ((CharSet_ -> IO (Maybe FontSet)) -> IO (Maybe FontSet))
-> (CharSet_ -> IO (Maybe FontSet)) -> IO (Maybe FontSet)
forall a b. (a -> b) -> a -> b
$ \csp' :: CharSet_
csp' -> (Ptr Word8 -> IO (Maybe FontSet)) -> IO (Maybe FontSet)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (Maybe FontSet)) -> IO (Maybe FontSet))
-> (Ptr Word8 -> IO (Maybe FontSet)) -> IO (Maybe FontSet)
forall a b. (a -> b) -> a -> b
$ \res' :: Ptr Word8
res' -> do
FontSet_
ret' <- Ptr Config'
-> Ptr FontSet_
-> Int
-> Pattern_
-> Bool
-> CharSet_
-> Ptr Word8
-> IO FontSet_
fcFontSetSort Ptr Config'
config' Ptr FontSet_
fontss' Int
n Pattern_
pattern' Bool
trim CharSet_
csp' Ptr Word8
res'
Ptr Word8 -> IO FontSet -> IO (Maybe FontSet)
forall a. Ptr Word8 -> IO a -> IO (Maybe a)
throwPtr Ptr Word8
res' (IO FontSet -> IO (Maybe FontSet))
-> IO FontSet -> IO (Maybe FontSet)
forall a b. (a -> b) -> a -> b
$ 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'
fontSetSort' :: [FontSet] -> Pattern -> Bool -> CharSet -> Maybe FontSet
fontSetSort' :: [FontSet] -> Pattern -> Bool -> CharSet -> Maybe FontSet
fontSetSort' fontss :: [FontSet]
fontss pattern :: Pattern
pattern trim :: Bool
trim csp :: CharSet
csp = IO (Maybe FontSet) -> Maybe FontSet
forall a. IO a -> a
unsafePerformIO (IO (Maybe FontSet) -> Maybe FontSet)
-> IO (Maybe FontSet) -> Maybe FontSet
forall a b. (a -> b) -> a -> b
$
[FontSet]
-> (Ptr FontSet_ -> Int -> IO (Maybe FontSet))
-> IO (Maybe FontSet)
forall a. [FontSet] -> (Ptr FontSet_ -> Int -> IO a) -> IO a
withFontSets [FontSet]
fontss ((Ptr FontSet_ -> Int -> IO (Maybe FontSet)) -> IO (Maybe FontSet))
-> (Ptr FontSet_ -> Int -> IO (Maybe FontSet))
-> IO (Maybe FontSet)
forall a b. (a -> b) -> a -> b
$ \fontss' :: Ptr FontSet_
fontss' n :: Int
n -> Pattern -> (Pattern_ -> IO (Maybe FontSet)) -> IO (Maybe FontSet)
forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern ((Pattern_ -> IO (Maybe FontSet)) -> IO (Maybe FontSet))
-> (Pattern_ -> IO (Maybe FontSet)) -> IO (Maybe FontSet)
forall a b. (a -> b) -> a -> b
$ \pattern' :: Pattern_
pattern' ->
CharSet -> (CharSet_ -> IO (Maybe FontSet)) -> IO (Maybe FontSet)
forall a. CharSet -> (CharSet_ -> IO a) -> IO a
withCharSet CharSet
csp ((CharSet_ -> IO (Maybe FontSet)) -> IO (Maybe FontSet))
-> (CharSet_ -> IO (Maybe FontSet)) -> IO (Maybe FontSet)
forall a b. (a -> b) -> a -> b
$ \csp' :: CharSet_
csp' -> (Ptr Word8 -> IO (Maybe FontSet)) -> IO (Maybe FontSet)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Word8 -> IO (Maybe FontSet)) -> IO (Maybe FontSet))
-> (Ptr Word8 -> IO (Maybe FontSet)) -> IO (Maybe FontSet)
forall a b. (a -> b) -> a -> b
$ \res' :: Ptr Word8
res' -> do
FontSet_
ret' <- Ptr Config'
-> Ptr FontSet_
-> Int
-> Pattern_
-> Bool
-> CharSet_
-> Ptr Word8
-> IO FontSet_
fcFontSetSort Ptr Config'
forall a. Ptr a
nullPtr Ptr FontSet_
fontss' Int
n Pattern_
pattern' Bool
trim CharSet_
csp' Ptr Word8
res'
Ptr Word8 -> IO FontSet -> IO (Maybe FontSet)
forall a. Ptr Word8 -> IO a -> IO (Maybe a)
throwPtr Ptr Word8
res' (IO FontSet -> IO (Maybe FontSet))
-> IO FontSet -> IO (Maybe FontSet)
forall a b. (a -> b) -> a -> b
$ 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 "FcFontSetSort" fcFontSetSort :: Config_ -> Ptr FontSet_
-> Int -> Pattern_ -> Bool -> CharSet_ -> Ptr Word8 -> IO FontSet_