~alcinnz/fontconfig-pure

18b29da8fa2cc23650f2fd33c0917bcc2289a7b6 — Adrian Cochrane 8 months ago 9aee49d
Expose font weight adjustments & correct current-config refcount.
M fontconfig-pure.cabal => fontconfig-pure.cabal +1 -1
@@ 69,7 69,7 @@ library
            Graphics.Text.Font.Choose.Pattern, Graphics.Text.Font.Choose.FontSet,
            Graphics.Text.Font.Choose.Config, Graphics.Text.Font.Choose.Result,
            Graphics.Text.Font.Choose.Internal.FFI, FreeType.FontConfig,
            Graphics.Text.Font.Choose.Config.Accessors
            Graphics.Text.Font.Choose.Config.Accessors, Graphics.Text.Font.Choose.Weight

    c-sources: cbits/cmp.c, cbits/transcode.c, cbits/fontconfig-wrap.c
    include-dirs: cbits

M lib/Graphics/Text/Font/Choose/Config/Accessors.hs => lib/Graphics/Text/Font/Choose/Config/Accessors.hs +3 -3
@@ 7,7 7,7 @@ import Graphics.Text.Font.Choose.Pattern
import Graphics.Text.Font.Choose.CharSet
import Graphics.Text.Font.Choose.ObjectSet

import Foreign.Ptr (Ptr)
import Foreign.Ptr (Ptr, nullPtr)
import Foreign.ForeignPtr (newForeignPtr, withForeignPtr)
import Foreign.C.String (CString, withCString, peekCString)
--import Foreign.C.ConstPtr (ConstPtr)


@@ 26,8 26,8 @@ setCurrent conf = throwBool =<< withForeignPtr conf fcConfigSetCurrent
foreign import capi "fontconfig/fontconfig.h FcConfigSetCurrent" fcConfigSetCurrent :: Ptr Config' -> IO Bool

current :: IO Config
current = newForeignPtr fcConfigDestroy =<< throwNull =<< fcConfigGetCurrent
foreign import capi "fontconfig/fontconfig.h FcConfigGetCurrent" fcConfigGetCurrent :: IO (Ptr Config')
current = newForeignPtr fcConfigDestroy =<< throwNull =<< fcConfigReference nullPtr
foreign import capi "fontconfig/fontconfig.h FcConfigReference" fcConfigReference :: Ptr Config' -> IO (Ptr Config')

uptodate :: Config -> IO Bool
uptodate conf = withForeignPtr conf fcConfigUptoDate

A lib/Graphics/Text/Font/Choose/Weight.hs => lib/Graphics/Text/Font/Choose/Weight.hs +11 -0
@@ 0,0 1,11 @@
{-# LANGUAGE CApiFFI #-}
module Graphics.Text.Font.Choose.Weight where

foreign import capi "fontconfig/fontconfig.h FcWeightFromOpenTypeDouble"
    weightFromOpenTypeDouble :: Double -> Double
foreign import capi "fontconfig/fontconfig.h FcWeightToOpenTypeDouble"
    weightToOpenTypeDouble :: Double -> Double
foreign import capi "fontconfig/fontconfig.h FcWeightFromOpenType"
    weightFromOpenType :: Int -> Int
foreign import capi "fontconfig/fontconfig.h FcWeightToOpenType" 
    weightToOpenType :: Int -> Int