{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- The t'GI.Pango.Objects.FontMap.FontMap' represents the set of fonts available for a
-- particular rendering system. This is a virtual object with
-- implementations being specific to particular rendering systems.  To
-- create an implementation of a t'GI.Pango.Objects.FontMap.FontMap', the rendering-system
-- specific code should allocate a larger structure that contains a nested
-- t'GI.Pango.Objects.FontMap.FontMap', fill in the \<structfield>klass\<\/structfield> member of the nested t'GI.Pango.Objects.FontMap.FontMap' with a
-- pointer to a appropriate t'GI.Pango.Structs.FontMapClass.FontMapClass', then call
-- @/pango_font_map_init()/@ on the structure.
-- 
-- The t'GI.Pango.Objects.FontMap.FontMap' structure contains one member which the implementation
-- fills in.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Pango.Objects.FontMap
    ( 

-- * Exported types
    FontMap(..)                             ,
    IsFontMap                               ,
    toFontMap                               ,
    noFontMap                               ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveFontMapMethod                    ,
#endif


-- ** changed #method:changed#

#if defined(ENABLE_OVERLOADING)
    FontMapChangedMethodInfo                ,
#endif
    fontMapChanged                          ,


-- ** createContext #method:createContext#

#if defined(ENABLE_OVERLOADING)
    FontMapCreateContextMethodInfo          ,
#endif
    fontMapCreateContext                    ,


-- ** getSerial #method:getSerial#

#if defined(ENABLE_OVERLOADING)
    FontMapGetSerialMethodInfo              ,
#endif
    fontMapGetSerial                        ,


-- ** getShapeEngineType #method:getShapeEngineType#

#if defined(ENABLE_OVERLOADING)
    FontMapGetShapeEngineTypeMethodInfo     ,
#endif
    fontMapGetShapeEngineType               ,


-- ** listFamilies #method:listFamilies#

#if defined(ENABLE_OVERLOADING)
    FontMapListFamiliesMethodInfo           ,
#endif
    fontMapListFamilies                     ,


-- ** loadFont #method:loadFont#

#if defined(ENABLE_OVERLOADING)
    FontMapLoadFontMethodInfo               ,
#endif
    fontMapLoadFont                         ,


-- ** loadFontset #method:loadFontset#

#if defined(ENABLE_OVERLOADING)
    FontMapLoadFontsetMethodInfo            ,
#endif
    fontMapLoadFontset                      ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Pango.Objects.Context as Pango.Context
import {-# SOURCE #-} qualified GI.Pango.Objects.Font as Pango.Font
import {-# SOURCE #-} qualified GI.Pango.Objects.FontFamily as Pango.FontFamily
import {-# SOURCE #-} qualified GI.Pango.Objects.Fontset as Pango.Fontset
import {-# SOURCE #-} qualified GI.Pango.Structs.FontDescription as Pango.FontDescription
import {-# SOURCE #-} qualified GI.Pango.Structs.Language as Pango.Language

-- | Memory-managed wrapper type.
newtype FontMap = FontMap (ManagedPtr FontMap)
    deriving (FontMap -> FontMap -> Bool
(FontMap -> FontMap -> Bool)
-> (FontMap -> FontMap -> Bool) -> Eq FontMap
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FontMap -> FontMap -> Bool
$c/= :: FontMap -> FontMap -> Bool
== :: FontMap -> FontMap -> Bool
$c== :: FontMap -> FontMap -> Bool
Eq)
foreign import ccall "pango_font_map_get_type"
    c_pango_font_map_get_type :: IO GType

instance GObject FontMap where
    gobjectType :: IO GType
gobjectType = IO GType
c_pango_font_map_get_type
    

-- | Convert 'FontMap' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue FontMap where
    toGValue :: FontMap -> IO GValue
toGValue o :: FontMap
o = do
        GType
gtype <- IO GType
c_pango_font_map_get_type
        FontMap -> (Ptr FontMap -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr FontMap
o (GType
-> (GValue -> Ptr FontMap -> IO ()) -> Ptr FontMap -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr FontMap -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO FontMap
fromGValue gv :: GValue
gv = do
        Ptr FontMap
ptr <- GValue -> IO (Ptr FontMap)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr FontMap)
        (ManagedPtr FontMap -> FontMap) -> Ptr FontMap -> IO FontMap
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr FontMap -> FontMap
FontMap Ptr FontMap
ptr
        
    

-- | Type class for types which can be safely cast to `FontMap`, for instance with `toFontMap`.
class (GObject o, O.IsDescendantOf FontMap o) => IsFontMap o
instance (GObject o, O.IsDescendantOf FontMap o) => IsFontMap o

instance O.HasParentTypes FontMap
type instance O.ParentTypes FontMap = '[GObject.Object.Object]

-- | Cast to `FontMap`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toFontMap :: (MonadIO m, IsFontMap o) => o -> m FontMap
toFontMap :: o -> m FontMap
toFontMap = IO FontMap -> m FontMap
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO FontMap -> m FontMap) -> (o -> IO FontMap) -> o -> m FontMap
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr FontMap -> FontMap) -> o -> IO FontMap
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr FontMap -> FontMap
FontMap

-- | A convenience alias for `Nothing` :: `Maybe` `FontMap`.
noFontMap :: Maybe FontMap
noFontMap :: Maybe FontMap
noFontMap = Maybe FontMap
forall a. Maybe a
Nothing

#if defined(ENABLE_OVERLOADING)
type family ResolveFontMapMethod (t :: Symbol) (o :: *) :: * where
    ResolveFontMapMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveFontMapMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveFontMapMethod "changed" o = FontMapChangedMethodInfo
    ResolveFontMapMethod "createContext" o = FontMapCreateContextMethodInfo
    ResolveFontMapMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveFontMapMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveFontMapMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveFontMapMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveFontMapMethod "listFamilies" o = FontMapListFamiliesMethodInfo
    ResolveFontMapMethod "loadFont" o = FontMapLoadFontMethodInfo
    ResolveFontMapMethod "loadFontset" o = FontMapLoadFontsetMethodInfo
    ResolveFontMapMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveFontMapMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveFontMapMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveFontMapMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveFontMapMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveFontMapMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveFontMapMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveFontMapMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveFontMapMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveFontMapMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveFontMapMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveFontMapMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveFontMapMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveFontMapMethod "getSerial" o = FontMapGetSerialMethodInfo
    ResolveFontMapMethod "getShapeEngineType" o = FontMapGetShapeEngineTypeMethodInfo
    ResolveFontMapMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveFontMapMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveFontMapMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveFontMapMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveFontMapMethod t FontMap, O.MethodInfo info FontMap p) => OL.IsLabel t (FontMap -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList FontMap
type instance O.AttributeList FontMap = FontMapAttributeList
type FontMapAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList FontMap = FontMapSignalList
type FontMapSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method FontMap::changed
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "fontmap"
--           , argType =
--               TInterface Name { namespace = "Pango" , name = "FontMap" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #PangoFontMap" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_map_changed" pango_font_map_changed :: 
    Ptr FontMap ->                          -- fontmap : TInterface (Name {namespace = "Pango", name = "FontMap"})
    IO ()

-- | Forces a change in the context, which will cause any t'GI.Pango.Objects.Context.Context'
-- using this fontmap to change.
-- 
-- This function is only useful when implementing a new backend
-- for Pango, something applications won\'t do. Backends should
-- call this function if they have attached extra data to the context
-- and such data is changed.
-- 
-- /Since: 1.34/
fontMapChanged ::
    (B.CallStack.HasCallStack, MonadIO m, IsFontMap a) =>
    a
    -- ^ /@fontmap@/: a t'GI.Pango.Objects.FontMap.FontMap'
    -> m ()
fontMapChanged :: a -> m ()
fontMapChanged fontmap :: a
fontmap = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr FontMap
fontmap' <- a -> IO (Ptr FontMap)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
fontmap
    Ptr FontMap -> IO ()
pango_font_map_changed Ptr FontMap
fontmap'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
fontmap
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data FontMapChangedMethodInfo
instance (signature ~ (m ()), MonadIO m, IsFontMap a) => O.MethodInfo FontMapChangedMethodInfo a signature where
    overloadedMethod = fontMapChanged

#endif

-- method FontMap::create_context
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "fontmap"
--           , argType =
--               TInterface Name { namespace = "Pango" , name = "FontMap" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #PangoFontMap" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Pango" , name = "Context" })
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_map_create_context" pango_font_map_create_context :: 
    Ptr FontMap ->                          -- fontmap : TInterface (Name {namespace = "Pango", name = "FontMap"})
    IO (Ptr Pango.Context.Context)

-- | Creates a t'GI.Pango.Objects.Context.Context' connected to /@fontmap@/.  This is equivalent
-- to 'GI.Pango.Objects.Context.contextNew' followed by 'GI.Pango.Objects.Context.contextSetFontMap'.
-- 
-- If you are using Pango as part of a higher-level system,
-- that system may have it\'s own way of create a t'GI.Pango.Objects.Context.Context'.
-- For instance, the GTK+ toolkit has, among others,
-- @/gdk_pango_context_get_for_screen()/@, and
-- @/gtk_widget_get_pango_context()/@.  Use those instead.
-- 
-- /Since: 1.22/
fontMapCreateContext ::
    (B.CallStack.HasCallStack, MonadIO m, IsFontMap a) =>
    a
    -- ^ /@fontmap@/: a t'GI.Pango.Objects.FontMap.FontMap'
    -> m Pango.Context.Context
    -- ^ __Returns:__ the newly allocated t'GI.Pango.Objects.Context.Context',
    --               which should be freed with 'GI.GObject.Objects.Object.objectUnref'.
fontMapCreateContext :: a -> m Context
fontMapCreateContext fontmap :: a
fontmap = IO Context -> m Context
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Context -> m Context) -> IO Context -> m Context
forall a b. (a -> b) -> a -> b
$ do
    Ptr FontMap
fontmap' <- a -> IO (Ptr FontMap)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
fontmap
    Ptr Context
result <- Ptr FontMap -> IO (Ptr Context)
pango_font_map_create_context Ptr FontMap
fontmap'
    Text -> Ptr Context -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "fontMapCreateContext" Ptr Context
result
    Context
result' <- ((ManagedPtr Context -> Context) -> Ptr Context -> IO Context
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Context -> Context
Pango.Context.Context) Ptr Context
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
fontmap
    Context -> IO Context
forall (m :: * -> *) a. Monad m => a -> m a
return Context
result'

#if defined(ENABLE_OVERLOADING)
data FontMapCreateContextMethodInfo
instance (signature ~ (m Pango.Context.Context), MonadIO m, IsFontMap a) => O.MethodInfo FontMapCreateContextMethodInfo a signature where
    overloadedMethod = fontMapCreateContext

#endif

-- method FontMap::get_serial
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "fontmap"
--           , argType =
--               TInterface Name { namespace = "Pango" , name = "FontMap" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #PangoFontMap" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_map_get_serial" pango_font_map_get_serial :: 
    Ptr FontMap ->                          -- fontmap : TInterface (Name {namespace = "Pango", name = "FontMap"})
    IO Word32

-- | Returns the current serial number of /@fontmap@/.  The serial number is
-- initialized to an small number larger than zero when a new fontmap
-- is created and is increased whenever the fontmap is changed. It may
-- wrap, but will never have the value 0. Since it can wrap, never compare
-- it with \"less than\", always use \"not equals\".
-- 
-- The fontmap can only be changed using backend-specific API, like changing
-- fontmap resolution.
-- 
-- This can be used to automatically detect changes to a t'GI.Pango.Objects.FontMap.FontMap', like
-- in t'GI.Pango.Objects.Context.Context'.
-- 
-- /Since: 1.32.4/
fontMapGetSerial ::
    (B.CallStack.HasCallStack, MonadIO m, IsFontMap a) =>
    a
    -- ^ /@fontmap@/: a t'GI.Pango.Objects.FontMap.FontMap'
    -> m Word32
    -- ^ __Returns:__ The current serial number of /@fontmap@/.
fontMapGetSerial :: a -> m Word32
fontMapGetSerial fontmap :: a
fontmap = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Ptr FontMap
fontmap' <- a -> IO (Ptr FontMap)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
fontmap
    Word32
result <- Ptr FontMap -> IO Word32
pango_font_map_get_serial Ptr FontMap
fontmap'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
fontmap
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result

#if defined(ENABLE_OVERLOADING)
data FontMapGetSerialMethodInfo
instance (signature ~ (m Word32), MonadIO m, IsFontMap a) => O.MethodInfo FontMapGetSerialMethodInfo a signature where
    overloadedMethod = fontMapGetSerial

#endif

-- method FontMap::get_shape_engine_type
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "fontmap"
--           , argType =
--               TInterface Name { namespace = "Pango" , name = "FontMap" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #PangoFontMap" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_map_get_shape_engine_type" pango_font_map_get_shape_engine_type :: 
    Ptr FontMap ->                          -- fontmap : TInterface (Name {namespace = "Pango", name = "FontMap"})
    IO CString

{-# DEPRECATED fontMapGetShapeEngineType ["(Since version 1.38)"] #-}
-- | Returns the render ID for shape engines for this fontmap.
-- See the \<structfield>render_type\<\/structfield> field of
-- t'GI.Pango.Structs.EngineInfo.EngineInfo'.
-- 
-- /Since: 1.4/
fontMapGetShapeEngineType ::
    (B.CallStack.HasCallStack, MonadIO m, IsFontMap a) =>
    a
    -- ^ /@fontmap@/: a t'GI.Pango.Objects.FontMap.FontMap'
    -> m T.Text
    -- ^ __Returns:__ the ID string for shape engines for
    --  this fontmap. Owned by Pango, should not be modified
    --  or freed.
fontMapGetShapeEngineType :: a -> m Text
fontMapGetShapeEngineType fontmap :: a
fontmap = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr FontMap
fontmap' <- a -> IO (Ptr FontMap)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
fontmap
    CString
result <- Ptr FontMap -> IO CString
pango_font_map_get_shape_engine_type Ptr FontMap
fontmap'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "fontMapGetShapeEngineType" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
fontmap
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if defined(ENABLE_OVERLOADING)
data FontMapGetShapeEngineTypeMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsFontMap a) => O.MethodInfo FontMapGetShapeEngineTypeMethodInfo a signature where
    overloadedMethod = fontMapGetShapeEngineType

#endif

-- method FontMap::list_families
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "fontmap"
--           , argType =
--               TInterface Name { namespace = "Pango" , name = "FontMap" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #PangoFontMap" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "families"
--           , argType =
--               TCArray
--                 False
--                 (-1)
--                 2
--                 (TInterface Name { namespace = "Pango" , name = "FontFamily" })
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "location to store a pointer to an array of #PangoFontFamily *.\n           This array should be freed with g_free()."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferContainer
--           }
--       , Arg
--           { argCName = "n_families"
--           , argType = TBasicType TInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "location to store the number of elements in @families"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "n_families"
--              , argType = TBasicType TInt
--              , direction = DirectionOut
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText =
--                        Just "location to store the number of elements in @families"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , transfer = TransferEverything
--              }
--          ]
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_map_list_families" pango_font_map_list_families :: 
    Ptr FontMap ->                          -- fontmap : TInterface (Name {namespace = "Pango", name = "FontMap"})
    Ptr (Ptr (Ptr Pango.FontFamily.FontFamily)) -> -- families : TCArray False (-1) 2 (TInterface (Name {namespace = "Pango", name = "FontFamily"}))
    Ptr Int32 ->                            -- n_families : TBasicType TInt
    IO ()

-- | List all families for a fontmap.
fontMapListFamilies ::
    (B.CallStack.HasCallStack, MonadIO m, IsFontMap a) =>
    a
    -- ^ /@fontmap@/: a t'GI.Pango.Objects.FontMap.FontMap'
    -> m ([Pango.FontFamily.FontFamily])
fontMapListFamilies :: a -> m [FontFamily]
fontMapListFamilies fontmap :: a
fontmap = IO [FontFamily] -> m [FontFamily]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [FontFamily] -> m [FontFamily])
-> IO [FontFamily] -> m [FontFamily]
forall a b. (a -> b) -> a -> b
$ do
    Ptr FontMap
fontmap' <- a -> IO (Ptr FontMap)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
fontmap
    Ptr (Ptr (Ptr FontFamily))
families <- IO (Ptr (Ptr (Ptr FontFamily)))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr (Ptr Pango.FontFamily.FontFamily)))
    Ptr Int32
nFamilies <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr FontMap -> Ptr (Ptr (Ptr FontFamily)) -> Ptr Int32 -> IO ()
pango_font_map_list_families Ptr FontMap
fontmap' Ptr (Ptr (Ptr FontFamily))
families Ptr Int32
nFamilies
    Int32
nFamilies' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
nFamilies
    Ptr (Ptr FontFamily)
families' <- Ptr (Ptr (Ptr FontFamily)) -> IO (Ptr (Ptr FontFamily))
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr (Ptr FontFamily))
families
    [Ptr FontFamily]
families'' <- (Int32 -> Ptr (Ptr FontFamily) -> IO [Ptr FontFamily]
forall a b. Integral a => a -> Ptr (Ptr b) -> IO [Ptr b]
unpackPtrArrayWithLength Int32
nFamilies') Ptr (Ptr FontFamily)
families'
    [FontFamily]
families''' <- (Ptr FontFamily -> IO FontFamily)
-> [Ptr FontFamily] -> IO [FontFamily]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr FontFamily -> FontFamily)
-> Ptr FontFamily -> IO FontFamily
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr FontFamily -> FontFamily
Pango.FontFamily.FontFamily) [Ptr FontFamily]
families''
    Ptr (Ptr FontFamily) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr FontFamily)
families'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
fontmap
    Ptr (Ptr (Ptr FontFamily)) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr (Ptr FontFamily))
families
    Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
nFamilies
    [FontFamily] -> IO [FontFamily]
forall (m :: * -> *) a. Monad m => a -> m a
return [FontFamily]
families'''

#if defined(ENABLE_OVERLOADING)
data FontMapListFamiliesMethodInfo
instance (signature ~ (m ([Pango.FontFamily.FontFamily])), MonadIO m, IsFontMap a) => O.MethodInfo FontMapListFamiliesMethodInfo a signature where
    overloadedMethod = fontMapListFamilies

#endif

-- method FontMap::load_font
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "fontmap"
--           , argType =
--               TInterface Name { namespace = "Pango" , name = "FontMap" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #PangoFontMap" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "Pango" , name = "Context" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the #PangoContext the font will be used with"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "desc"
--           , argType =
--               TInterface Name { namespace = "Pango" , name = "FontDescription" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a #PangoFontDescription describing the font to load"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Pango" , name = "Font" })
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_map_load_font" pango_font_map_load_font :: 
    Ptr FontMap ->                          -- fontmap : TInterface (Name {namespace = "Pango", name = "FontMap"})
    Ptr Pango.Context.Context ->            -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    Ptr Pango.FontDescription.FontDescription -> -- desc : TInterface (Name {namespace = "Pango", name = "FontDescription"})
    IO (Ptr Pango.Font.Font)

-- | Load the font in the fontmap that is the closest match for /@desc@/.
fontMapLoadFont ::
    (B.CallStack.HasCallStack, MonadIO m, IsFontMap a, Pango.Context.IsContext b) =>
    a
    -- ^ /@fontmap@/: a t'GI.Pango.Objects.FontMap.FontMap'
    -> b
    -- ^ /@context@/: the t'GI.Pango.Objects.Context.Context' the font will be used with
    -> Pango.FontDescription.FontDescription
    -- ^ /@desc@/: a t'GI.Pango.Structs.FontDescription.FontDescription' describing the font to load
    -> m (Maybe Pango.Font.Font)
    -- ^ __Returns:__ the newly allocated t'GI.Pango.Objects.Font.Font'
    --          loaded, or 'P.Nothing' if no font matched.
fontMapLoadFont :: a -> b -> FontDescription -> m (Maybe Font)
fontMapLoadFont fontmap :: a
fontmap context :: b
context desc :: FontDescription
desc = IO (Maybe Font) -> m (Maybe Font)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Font) -> m (Maybe Font))
-> IO (Maybe Font) -> m (Maybe Font)
forall a b. (a -> b) -> a -> b
$ do
    Ptr FontMap
fontmap' <- a -> IO (Ptr FontMap)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
fontmap
    Ptr Context
context' <- b -> IO (Ptr Context)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
context
    Ptr FontDescription
desc' <- FontDescription -> IO (Ptr FontDescription)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr FontDescription
desc
    Ptr Font
result <- Ptr FontMap -> Ptr Context -> Ptr FontDescription -> IO (Ptr Font)
pango_font_map_load_font Ptr FontMap
fontmap' Ptr Context
context' Ptr FontDescription
desc'
    Maybe Font
maybeResult <- Ptr Font -> (Ptr Font -> IO Font) -> IO (Maybe Font)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Font
result ((Ptr Font -> IO Font) -> IO (Maybe Font))
-> (Ptr Font -> IO Font) -> IO (Maybe Font)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr Font
result' -> do
        Font
result'' <- ((ManagedPtr Font -> Font) -> Ptr Font -> IO Font
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Font -> Font
Pango.Font.Font) Ptr Font
result'
        Font -> IO Font
forall (m :: * -> *) a. Monad m => a -> m a
return Font
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
fontmap
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
context
    FontDescription -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr FontDescription
desc
    Maybe Font -> IO (Maybe Font)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Font
maybeResult

#if defined(ENABLE_OVERLOADING)
data FontMapLoadFontMethodInfo
instance (signature ~ (b -> Pango.FontDescription.FontDescription -> m (Maybe Pango.Font.Font)), MonadIO m, IsFontMap a, Pango.Context.IsContext b) => O.MethodInfo FontMapLoadFontMethodInfo a signature where
    overloadedMethod = fontMapLoadFont

#endif

-- method FontMap::load_fontset
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "fontmap"
--           , argType =
--               TInterface Name { namespace = "Pango" , name = "FontMap" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #PangoFontMap" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "context"
--           , argType =
--               TInterface Name { namespace = "Pango" , name = "Context" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the #PangoContext the font will be used with"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "desc"
--           , argType =
--               TInterface Name { namespace = "Pango" , name = "FontDescription" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a #PangoFontDescription describing the font to load"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "language"
--           , argType =
--               TInterface Name { namespace = "Pango" , name = "Language" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #PangoLanguage the fonts will be used for"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Pango" , name = "Fontset" })
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_map_load_fontset" pango_font_map_load_fontset :: 
    Ptr FontMap ->                          -- fontmap : TInterface (Name {namespace = "Pango", name = "FontMap"})
    Ptr Pango.Context.Context ->            -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    Ptr Pango.FontDescription.FontDescription -> -- desc : TInterface (Name {namespace = "Pango", name = "FontDescription"})
    Ptr Pango.Language.Language ->          -- language : TInterface (Name {namespace = "Pango", name = "Language"})
    IO (Ptr Pango.Fontset.Fontset)

-- | Load a set of fonts in the fontmap that can be used to render
-- a font matching /@desc@/.
fontMapLoadFontset ::
    (B.CallStack.HasCallStack, MonadIO m, IsFontMap a, Pango.Context.IsContext b) =>
    a
    -- ^ /@fontmap@/: a t'GI.Pango.Objects.FontMap.FontMap'
    -> b
    -- ^ /@context@/: the t'GI.Pango.Objects.Context.Context' the font will be used with
    -> Pango.FontDescription.FontDescription
    -- ^ /@desc@/: a t'GI.Pango.Structs.FontDescription.FontDescription' describing the font to load
    -> Pango.Language.Language
    -- ^ /@language@/: a t'GI.Pango.Structs.Language.Language' the fonts will be used for
    -> m (Maybe Pango.Fontset.Fontset)
    -- ^ __Returns:__ the newly allocated
    --          t'GI.Pango.Objects.Fontset.Fontset' loaded, or 'P.Nothing' if no font matched.
fontMapLoadFontset :: a -> b -> FontDescription -> Language -> m (Maybe Fontset)
fontMapLoadFontset fontmap :: a
fontmap context :: b
context desc :: FontDescription
desc language :: Language
language = IO (Maybe Fontset) -> m (Maybe Fontset)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Fontset) -> m (Maybe Fontset))
-> IO (Maybe Fontset) -> m (Maybe Fontset)
forall a b. (a -> b) -> a -> b
$ do
    Ptr FontMap
fontmap' <- a -> IO (Ptr FontMap)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
fontmap
    Ptr Context
context' <- b -> IO (Ptr Context)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
context
    Ptr FontDescription
desc' <- FontDescription -> IO (Ptr FontDescription)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr FontDescription
desc
    Ptr Language
language' <- Language -> IO (Ptr Language)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Language
language
    Ptr Fontset
result <- Ptr FontMap
-> Ptr Context
-> Ptr FontDescription
-> Ptr Language
-> IO (Ptr Fontset)
pango_font_map_load_fontset Ptr FontMap
fontmap' Ptr Context
context' Ptr FontDescription
desc' Ptr Language
language'
    Maybe Fontset
maybeResult <- Ptr Fontset -> (Ptr Fontset -> IO Fontset) -> IO (Maybe Fontset)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Fontset
result ((Ptr Fontset -> IO Fontset) -> IO (Maybe Fontset))
-> (Ptr Fontset -> IO Fontset) -> IO (Maybe Fontset)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr Fontset
result' -> do
        Fontset
result'' <- ((ManagedPtr Fontset -> Fontset) -> Ptr Fontset -> IO Fontset
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Fontset -> Fontset
Pango.Fontset.Fontset) Ptr Fontset
result'
        Fontset -> IO Fontset
forall (m :: * -> *) a. Monad m => a -> m a
return Fontset
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
fontmap
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
context
    FontDescription -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr FontDescription
desc
    Language -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Language
language
    Maybe Fontset -> IO (Maybe Fontset)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Fontset
maybeResult

#if defined(ENABLE_OVERLOADING)
data FontMapLoadFontsetMethodInfo
instance (signature ~ (b -> Pango.FontDescription.FontDescription -> Pango.Language.Language -> m (Maybe Pango.Fontset.Fontset)), MonadIO m, IsFontMap a, Pango.Context.IsContext b) => O.MethodInfo FontMapLoadFontsetMethodInfo a signature where
    overloadedMethod = fontMapLoadFontset

#endif