A Graphics/Text/Font/Choose/File/Atomic.hs => Graphics/Text/Font/Choose/File/Atomic.hs +45 -0
@@ 0,0 1,45 @@
+module Graphics.Text.Font.Choose.File.Atomic where
+
+import Foreign.ForeignPtr
+import Foreign.Ptr (Ptr, FunPtr)
+import Foreign.C.String (CString, peekCString, withCString)
+import Control.Exception (bracket)
+
+data Atomic'
+type Atomic = ForeignPtr Atomic'
+type Atomic_ = Ptr Atomic'
+
+create :: String -> IO Atomic
+create filename = withCString filename fcAtomicCreate >>= newForeignPtr fcAtomicDestroy
+foreign import ccall "FcAtomicCreate" fcAtomicCreate :: CString -> IO Atomic_
+foreign import ccall "&FcAtomicDestroy" fcAtomicDestroy :: FunPtr (Atomic_ -> IO ())
+
+lock :: Atomic -> IO Bool
+lock = flip withForeignPtr fcAtomicLock
+foreign import ccall "FcAtomicLock" fcAtomicLock :: Atomic_ -> IO Bool
+
+newFile :: Atomic -> IO String
+newFile atomic = withForeignPtr atomic fcAtomicNewFile >>= peekCString
+foreign import ccall "FcAtomicNewFile" fcAtomicNewFile :: Atomic_ -> IO CString
+
+origFile :: Atomic -> IO String
+origFile atomic = withForeignPtr atomic fcAtomicOrigFile >>= peekCString
+foreign import ccall "FcAtomicOrigFile" fcAtomicOrigFile :: Atomic_ -> IO CString
+
+replaceOrig :: Atomic -> IO Bool
+replaceOrig = flip withForeignPtr fcAtomicReplaceOrig
+foreign import ccall "FcAtomicReplaceOrig" fcAtomicReplaceOrig :: Atomic_ -> IO Bool
+
+deleteNew :: Atomic -> IO ()
+deleteNew = flip withForeignPtr fcAtomicDeleteNew
+foreign import ccall "FcAtomicDeleteNew" fcAtomicDeleteNew :: Atomic_ -> IO ()
+
+unlock :: Atomic -> IO ()
+unlock = flip withForeignPtr fcAtomicUnlock
+foreign import ccall "FcAtomicUnlock" fcAtomicUnlock :: Atomic_ -> IO ()
+
+withLock :: Atomic -> IO () -> IO ()
+withLock atomic cb = bracket (lock atomic) (const $ unlock atomic) inner
+ where
+ inner True = cb
+ inner False = return ()
M Graphics/Text/Font/Choose/Weight.hs => Graphics/Text/Font/Choose/Weight.hs +2 -1
@@ 4,4 4,5 @@ foreign import ccall "FcWeightFromOpenTypeDouble" weightFromOpenTypeDouble ::
Double -> Double
foreign import ccall "FcWeightToOpenTypeDouble" weightToOpenTypeDouble ::
Double -> Double
-
+foreign import ccall "FcWeightFromOpenType" weightFromOpenType :: Int -> Int
+foreign import ccall "FcWeightToOpenType" weightToOpenType :: Int -> Int
M fontconfig-pure.cabal => fontconfig-pure.cabal +1 -1
@@ 56,7 56,7 @@ library
Graphics.Text.Font.Choose.Strings, Graphics.Text.Font.Choose.Range,
Graphics.Text.Font.Choose.LangSet, Graphics.Text.Font.Choose.Value,
Graphics.Text.Font.Choose.Pattern, Graphics.Text.Font.Choose.FontSet,
- Graphics.Text.Font.Choose.Config
+ Graphics.Text.Font.Choose.Config, Graphics.Text.Font.Choose.File.Atomic
c-sources: cbits/pattern.c