{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

The '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 'GI.Pango.Objects.FontMap.FontMap', the rendering-system
specific code should allocate a larger structure that contains a nested
'GI.Pango.Objects.FontMap.FontMap', fill in the \<structfield>klass\<\/structfield> member of the nested 'GI.Pango.Objects.FontMap.FontMap' with a
pointer to a appropriate 'GI.Pango.Structs.FontMapClass.FontMapClass', then call
@/pango_font_map_init()/@ on the structure.

The 'GI.Pango.Objects.FontMap.FontMap' structure contains one member which the implementation
fills in.
-}

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

module GI.Pango.Objects.FontMap
    (

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


 -- * Methods
-- ** changed #method:changed#

#if ENABLE_OVERLOADING
    FontMapChangedMethodInfo                ,
#endif
    fontMapChanged                          ,


-- ** createContext #method:createContext#

#if ENABLE_OVERLOADING
    FontMapCreateContextMethodInfo          ,
#endif
    fontMapCreateContext                    ,


-- ** getSerial #method:getSerial#

#if ENABLE_OVERLOADING
    FontMapGetSerialMethodInfo              ,
#endif
    fontMapGetSerial                        ,


-- ** getShapeEngineType #method:getShapeEngineType#

#if ENABLE_OVERLOADING
    FontMapGetShapeEngineTypeMethodInfo     ,
#endif
    fontMapGetShapeEngineType               ,


-- ** listFamilies #method:listFamilies#

#if ENABLE_OVERLOADING
    FontMapListFamiliesMethodInfo           ,
#endif
    fontMapListFamilies                     ,


-- ** loadFont #method:loadFont#

#if ENABLE_OVERLOADING
    FontMapLoadFontMethodInfo               ,
#endif
    fontMapLoadFont                         ,


-- ** loadFontset #method:loadFontset#

#if 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.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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

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)
foreign import ccall "pango_font_map_get_type"
    c_pango_font_map_get_type :: IO GType

instance GObject FontMap where
    gobjectType _ = c_pango_font_map_get_type


-- | Type class for types which can be safely cast to `FontMap`, for instance with `toFontMap`.
class GObject o => IsFontMap o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError FontMap a) =>
    IsFontMap a
#endif
instance IsFontMap FontMap
instance GObject.Object.IsObject FontMap

-- | 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 = liftIO . unsafeCastTo FontMap

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

#if 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 "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveFontMapMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveFontMapMethod t FontMap, O.MethodInfo info FontMap p) => O.IsLabelProxy t (FontMap -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

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

#endif

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

#if ENABLE_OVERLOADING
#endif

#if 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 '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 'GI.Pango.Objects.FontMap.FontMap' -}
    -> m ()
fontMapChanged fontmap = liftIO $ do
    fontmap' <- unsafeManagedPtrCastPtr fontmap
    pango_font_map_changed fontmap'
    touchManagedPtr fontmap
    return ()

#if 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 '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 '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 'GI.Pango.Objects.FontMap.FontMap' -}
    -> m Pango.Context.Context
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Objects.Context.Context',
              which should be freed with 'GI.GObject.Objects.Object.objectUnref'. -}
fontMapCreateContext fontmap = liftIO $ do
    fontmap' <- unsafeManagedPtrCastPtr fontmap
    result <- pango_font_map_create_context fontmap'
    checkUnexpectedReturnNULL "fontMapCreateContext" result
    result' <- (wrapObject Pango.Context.Context) result
    touchManagedPtr fontmap
    return result'

#if 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 'GI.Pango.Objects.FontMap.FontMap', like
in 'GI.Pango.Objects.Context.Context'.

/Since: 1.32.4/
-}
fontMapGetSerial ::
    (B.CallStack.HasCallStack, MonadIO m, IsFontMap a) =>
    a
    {- ^ /@fontmap@/: a 'GI.Pango.Objects.FontMap.FontMap' -}
    -> m Word32
    {- ^ __Returns:__ The current serial number of /@fontmap@/. -}
fontMapGetSerial fontmap = liftIO $ do
    fontmap' <- unsafeManagedPtrCastPtr fontmap
    result <- pango_font_map_get_serial fontmap'
    touchManagedPtr fontmap
    return result

#if 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
'GI.Pango.Structs.EngineInfo.EngineInfo'.

/Since: 1.4/
-}
fontMapGetShapeEngineType ::
    (B.CallStack.HasCallStack, MonadIO m, IsFontMap a) =>
    a
    {- ^ /@fontmap@/: a '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 fontmap = liftIO $ do
    fontmap' <- unsafeManagedPtrCastPtr fontmap
    result <- pango_font_map_get_shape_engine_type fontmap'
    checkUnexpectedReturnNULL "fontMapGetShapeEngineType" result
    result' <- cstringToText result
    touchManagedPtr fontmap
    return result'

#if 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 'GI.Pango.Objects.FontMap.FontMap' -}
    -> m ([Pango.FontFamily.FontFamily])
fontMapListFamilies fontmap = liftIO $ do
    fontmap' <- unsafeManagedPtrCastPtr fontmap
    families <- allocMem :: IO (Ptr (Ptr (Ptr Pango.FontFamily.FontFamily)))
    nFamilies <- allocMem :: IO (Ptr Int32)
    pango_font_map_list_families fontmap' families nFamilies
    nFamilies' <- peek nFamilies
    families' <- peek families
    families'' <- (unpackPtrArrayWithLength nFamilies') families'
    families''' <- mapM (newObject Pango.FontFamily.FontFamily) families''
    freeMem families'
    touchManagedPtr fontmap
    freeMem families
    freeMem nFamilies
    return families'''

#if 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 'GI.Pango.Objects.FontMap.FontMap' -}
    -> b
    {- ^ /@context@/: the 'GI.Pango.Objects.Context.Context' the font will be used with -}
    -> Pango.FontDescription.FontDescription
    {- ^ /@desc@/: a 'GI.Pango.Structs.FontDescription.FontDescription' describing the font to load -}
    -> m (Maybe Pango.Font.Font)
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Objects.Font.Font'
         loaded, or 'Nothing' if no font matched. -}
fontMapLoadFont fontmap context desc = liftIO $ do
    fontmap' <- unsafeManagedPtrCastPtr fontmap
    context' <- unsafeManagedPtrCastPtr context
    desc' <- unsafeManagedPtrGetPtr desc
    result <- pango_font_map_load_font fontmap' context' desc'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Pango.Font.Font) result'
        return result''
    touchManagedPtr fontmap
    touchManagedPtr context
    touchManagedPtr desc
    return maybeResult

#if 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 'GI.Pango.Objects.FontMap.FontMap' -}
    -> b
    {- ^ /@context@/: the 'GI.Pango.Objects.Context.Context' the font will be used with -}
    -> Pango.FontDescription.FontDescription
    {- ^ /@desc@/: a 'GI.Pango.Structs.FontDescription.FontDescription' describing the font to load -}
    -> Pango.Language.Language
    {- ^ /@language@/: a 'GI.Pango.Structs.Language.Language' the fonts will be used for -}
    -> m (Maybe Pango.Fontset.Fontset)
    {- ^ __Returns:__ the newly allocated
         'GI.Pango.Objects.Fontset.Fontset' loaded, or 'Nothing' if no font matched. -}
fontMapLoadFontset fontmap context desc language = liftIO $ do
    fontmap' <- unsafeManagedPtrCastPtr fontmap
    context' <- unsafeManagedPtrCastPtr context
    desc' <- unsafeManagedPtrGetPtr desc
    language' <- unsafeManagedPtrGetPtr language
    result <- pango_font_map_load_fontset fontmap' context' desc' language'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Pango.Fontset.Fontset) result'
        return result''
    touchManagedPtr fontmap
    touchManagedPtr context
    touchManagedPtr desc
    touchManagedPtr language
    return maybeResult

#if 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