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

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

module GI.Pango.Functions
    (

 -- * Methods
-- ** attrBackgroundAlphaNew #method:attrBackgroundAlphaNew#

    attrBackgroundAlphaNew                  ,


-- ** attrBackgroundNew #method:attrBackgroundNew#

    attrBackgroundNew                       ,


-- ** attrFallbackNew #method:attrFallbackNew#

    attrFallbackNew                         ,


-- ** attrFamilyNew #method:attrFamilyNew#

    attrFamilyNew                           ,


-- ** attrForegroundAlphaNew #method:attrForegroundAlphaNew#

    attrForegroundAlphaNew                  ,


-- ** attrForegroundNew #method:attrForegroundNew#

    attrForegroundNew                       ,


-- ** attrGravityHintNew #method:attrGravityHintNew#

    attrGravityHintNew                      ,


-- ** attrGravityNew #method:attrGravityNew#

    attrGravityNew                          ,


-- ** attrLetterSpacingNew #method:attrLetterSpacingNew#

    attrLetterSpacingNew                    ,


-- ** attrRiseNew #method:attrRiseNew#

    attrRiseNew                             ,


-- ** attrScaleNew #method:attrScaleNew#

    attrScaleNew                            ,


-- ** attrStretchNew #method:attrStretchNew#

    attrStretchNew                          ,


-- ** attrStrikethroughColorNew #method:attrStrikethroughColorNew#

    attrStrikethroughColorNew               ,


-- ** attrStrikethroughNew #method:attrStrikethroughNew#

    attrStrikethroughNew                    ,


-- ** attrStyleNew #method:attrStyleNew#

    attrStyleNew                            ,


-- ** attrUnderlineColorNew #method:attrUnderlineColorNew#

    attrUnderlineColorNew                   ,


-- ** attrUnderlineNew #method:attrUnderlineNew#

    attrUnderlineNew                        ,


-- ** attrVariantNew #method:attrVariantNew#

    attrVariantNew                          ,


-- ** attrWeightNew #method:attrWeightNew#

    attrWeightNew                           ,


-- ** break #method:break#

    break                                   ,


-- ** configKeyGet #method:configKeyGet#

    configKeyGet                            ,


-- ** configKeyGetSystem #method:configKeyGetSystem#

    configKeyGetSystem                      ,


-- ** defaultBreak #method:defaultBreak#

    defaultBreak                            ,


-- ** extentsToPixels #method:extentsToPixels#

    extentsToPixels                         ,


-- ** findBaseDir #method:findBaseDir#

    findBaseDir                             ,


-- ** findParagraphBoundary #method:findParagraphBoundary#

    findParagraphBoundary                   ,


-- ** getLibSubdirectory #method:getLibSubdirectory#

    getLibSubdirectory                      ,


-- ** getLogAttrs #method:getLogAttrs#

    getLogAttrs                             ,


-- ** getMirrorChar #method:getMirrorChar#

    getMirrorChar                           ,


-- ** getSysconfSubdirectory #method:getSysconfSubdirectory#

    getSysconfSubdirectory                  ,


-- ** isZeroWidth #method:isZeroWidth#

    isZeroWidth                             ,


-- ** itemize #method:itemize#

    itemize                                 ,


-- ** itemizeWithBaseDir #method:itemizeWithBaseDir#

    itemizeWithBaseDir                      ,


-- ** log2visGetEmbeddingLevels #method:log2visGetEmbeddingLevels#

    log2visGetEmbeddingLevels               ,


-- ** lookupAliases #method:lookupAliases#

    lookupAliases                           ,


-- ** markupParserFinish #method:markupParserFinish#

    markupParserFinish                      ,


-- ** markupParserNew #method:markupParserNew#

    markupParserNew                         ,


-- ** moduleRegister #method:moduleRegister#

    moduleRegister                          ,


-- ** parseEnum #method:parseEnum#

    parseEnum                               ,


-- ** parseMarkup #method:parseMarkup#

    parseMarkup                             ,


-- ** quantizeLineGeometry #method:quantizeLineGeometry#

    quantizeLineGeometry                    ,


-- ** readLine #method:readLine#

    readLine                                ,


-- ** reorderItems #method:reorderItems#

    reorderItems                            ,


-- ** scanInt #method:scanInt#

    scanInt                                 ,


-- ** scanString #method:scanString#

    scanString                              ,


-- ** scanWord #method:scanWord#

    scanWord                                ,


-- ** shape #method:shape#

    shape                                   ,


-- ** shapeFull #method:shapeFull#

    shapeFull                               ,


-- ** skipSpace #method:skipSpace#

    skipSpace                               ,


-- ** splitFileList #method:splitFileList#

    splitFileList                           ,


-- ** trimString #method:trimString#

    trimString                              ,


-- ** unicharDirection #method:unicharDirection#

    unicharDirection                        ,


-- ** unitsFromDouble #method:unitsFromDouble#

    unitsFromDouble                         ,


-- ** unitsToDouble #method:unitsToDouble#

    unitsToDouble                           ,


-- ** version #method:version#

    version                                 ,


-- ** versionCheck #method:versionCheck#

    versionCheck                            ,


-- ** versionString #method:versionString#

    versionString                           ,




    ) 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.GLib.Structs.MarkupParseContext as GLib.MarkupParseContext
import qualified GI.GLib.Structs.String as GLib.String
import {-# SOURCE #-} qualified GI.Pango.Enums as Pango.Enums
import {-# SOURCE #-} qualified GI.Pango.Objects.Context as Pango.Context
import {-# SOURCE #-} qualified GI.Pango.Structs.Analysis as Pango.Analysis
import {-# SOURCE #-} qualified GI.Pango.Structs.AttrIterator as Pango.AttrIterator
import {-# SOURCE #-} qualified GI.Pango.Structs.AttrList as Pango.AttrList
import {-# SOURCE #-} qualified GI.Pango.Structs.Attribute as Pango.Attribute
import {-# SOURCE #-} qualified GI.Pango.Structs.GlyphString as Pango.GlyphString
import {-# SOURCE #-} qualified GI.Pango.Structs.IncludedModule as Pango.IncludedModule
import {-# SOURCE #-} qualified GI.Pango.Structs.Item as Pango.Item
import {-# SOURCE #-} qualified GI.Pango.Structs.Language as Pango.Language
import {-# SOURCE #-} qualified GI.Pango.Structs.LogAttr as Pango.LogAttr
import {-# SOURCE #-} qualified GI.Pango.Structs.Rectangle as Pango.Rectangle

-- function pango_version_string
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "pango_version_string" pango_version_string ::
    IO CString

{- |
This is similar to the macro @/PANGO_VERSION_STRING/@ except that
it returns the version of Pango available at run-time, as opposed to
the version available at compile-time.

/Since: 1.16/
-}
versionString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m T.Text
    {- ^ __Returns:__ A string containing the version of Pango library
  available at run time.
  The returned string is owned by Pango and should not be modified
  or freed. -}
versionString  = liftIO $ do
    result <- pango_version_string
    checkUnexpectedReturnNULL "versionString" result
    result' <- cstringToText result
    return result'


-- function pango_version_check
-- Args : [Arg {argCName = "required_major", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the required major version.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "required_minor", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the required minor version.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "required_micro", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the required major version.", 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_version_check" pango_version_check ::
    Int32 ->                                -- required_major : TBasicType TInt
    Int32 ->                                -- required_minor : TBasicType TInt
    Int32 ->                                -- required_micro : TBasicType TInt
    IO CString

{- |
Checks that the Pango library in use is compatible with the
given version. Generally you would pass in the constants
@/PANGO_VERSION_MAJOR/@, @/PANGO_VERSION_MINOR/@, @/PANGO_VERSION_MICRO/@
as the three arguments to this function; that produces
a check that the library in use at run-time is compatible with
the version of Pango the application or module was compiled against.

Compatibility is defined by two things: first the version
of the running library is newer than the version
/@requiredMajor@/.required_minor./@requiredMicro@/. Second
the running library must be binary compatible with the
version /@requiredMajor@/.required_minor./@requiredMicro@/
(same major version.)

For compile-time version checking use @/PANGO_VERSION_CHECK()/@.

/Since: 1.16/
-}
versionCheck ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@requiredMajor@/: the required major version. -}
    -> Int32
    {- ^ /@requiredMinor@/: the required minor version. -}
    -> Int32
    {- ^ /@requiredMicro@/: the required major version. -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ 'Nothing' if the Pango library is compatible
  with the given version, or a string describing the version
  mismatch.  The returned string is owned by Pango and should not
  be modified or freed. -}
versionCheck requiredMajor requiredMinor requiredMicro = liftIO $ do
    result <- pango_version_check requiredMajor requiredMinor requiredMicro
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        return result''
    return maybeResult


-- function pango_version
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "pango_version" pango_version ::
    IO Int32

{- |
This is similar to the macro @/PANGO_VERSION/@ except that
it returns the encoded version of Pango available at run-time,
as opposed to the version available at compile-time.

A version number can be encoded into an integer using
@/PANGO_VERSION_ENCODE()/@.

/Since: 1.16/
-}
version ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Int32
    {- ^ __Returns:__ The encoded version of Pango library
  available at run time. -}
version  = liftIO $ do
    result <- pango_version
    return result


-- function pango_units_to_double
-- Args : [Arg {argCName = "i", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "value in Pango units", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TDouble)
-- throws : False
-- Skip return : False

foreign import ccall "pango_units_to_double" pango_units_to_double ::
    Int32 ->                                -- i : TBasicType TInt
    IO CDouble

{- |
Converts a number in Pango units to floating-point: divides
it by 'GI.Pango.Constants.SCALE'.

/Since: 1.16/
-}
unitsToDouble ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@i@/: value in Pango units -}
    -> m Double
    {- ^ __Returns:__ the double value. -}
unitsToDouble i = liftIO $ do
    result <- pango_units_to_double i
    let result' = realToFrac result
    return result'


-- function pango_units_from_double
-- Args : [Arg {argCName = "d", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "double floating-point value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "pango_units_from_double" pango_units_from_double ::
    CDouble ->                              -- d : TBasicType TDouble
    IO Int32

{- |
Converts a floating-point number to Pango units: multiplies
it by 'GI.Pango.Constants.SCALE' and rounds to nearest integer.

/Since: 1.16/
-}
unitsFromDouble ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Double
    {- ^ /@d@/: double floating-point value -}
    -> m Int32
    {- ^ __Returns:__ the value in Pango units. -}
unitsFromDouble d = liftIO $ do
    let d' = realToFrac d
    result <- pango_units_from_double d'
    return result


-- function pango_unichar_direction
-- Args : [Arg {argCName = "ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Direction"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_unichar_direction" pango_unichar_direction ::
    CInt ->                                 -- ch : TBasicType TUniChar
    IO CUInt

{- |
Determines the inherent direction of a character; either
'GI.Pango.Enums.DirectionLtr', 'GI.Pango.Enums.DirectionRtl', or
'GI.Pango.Enums.DirectionNeutral'.

This function is useful to categorize characters into left-to-right
letters, right-to-left letters, and everything else.  If full
Unicode bidirectional type of a character is needed,
'GI.Pango.Functions.bidiTypeForUnichar' can be used instead.
-}
unicharDirection ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@ch@/: a Unicode character -}
    -> m Pango.Enums.Direction
    {- ^ __Returns:__ the direction of the character. -}
unicharDirection ch = liftIO $ do
    let ch' = (fromIntegral . ord) ch
    result <- pango_unichar_direction ch'
    let result' = (toEnum . fromIntegral) result
    return result'


-- function pango_trim_string
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", 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_trim_string" pango_trim_string ::
    CString ->                              -- str : TBasicType TUTF8
    IO CString

{-# DEPRECATED trimString ["(Since version 1.38)"] #-}
{- |
Trims leading and trailing whitespace from a string.
-}
trimString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a string -}
    -> m T.Text
    {- ^ __Returns:__ A newly-allocated string that must be freed with 'GI.GLib.Functions.free' -}
trimString str = liftIO $ do
    str' <- textToCString str
    result <- pango_trim_string str'
    checkUnexpectedReturnNULL "trimString" result
    result' <- cstringToText result
    freeMem result
    freeMem str'
    return result'


-- function pango_split_file_list
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a %G_SEARCHPATH_SEPARATOR separated list of filenames", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "pango_split_file_list" pango_split_file_list ::
    CString ->                              -- str : TBasicType TUTF8
    IO (Ptr CString)

{-# DEPRECATED splitFileList ["(Since version 1.38)"] #-}
{- |
Splits a 'GI.GLib.Constants.SEARCHPATH_SEPARATOR'-separated list of files, stripping
white space and substituting ~\/ with $HOME\/.
-}
splitFileList ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a 'GI.GLib.Constants.SEARCHPATH_SEPARATOR' separated list of filenames -}
    -> m [T.Text]
    {- ^ __Returns:__ a list of
strings to be freed with 'GI.GLib.Functions.strfreev' -}
splitFileList str = liftIO $ do
    str' <- textToCString str
    result <- pango_split_file_list str'
    checkUnexpectedReturnNULL "splitFileList" result
    result' <- unpackZeroTerminatedUTF8CArray result
    mapZeroTerminatedCArray freeMem result
    freeMem result
    freeMem str'
    return result'


-- function pango_skip_space
-- Args : [Arg {argCName = "pos", argType = TBasicType TUTF8, direction = DirectionInout, mayBeNull = False, argDoc = Documentation {rawDocText = Just "in/out string position", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "pango_skip_space" pango_skip_space ::
    Ptr CString ->                          -- pos : TBasicType TUTF8
    IO CInt

{-# DEPRECATED skipSpace ["(Since version 1.38)"] #-}
{- |
Skips 0 or more characters of white space.
-}
skipSpace ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@pos@/: in\/out string position -}
    -> m ((Bool, T.Text))
    {- ^ __Returns:__ 'False' if skipping the white space leaves
the position at a \'\\0\' character. -}
skipSpace pos = liftIO $ do
    pos' <- textToCString pos
    pos'' <- allocMem :: IO (Ptr CString)
    poke pos'' pos'
    result <- pango_skip_space pos''
    let result' = (/= 0) result
    pos''' <- peek pos''
    pos'''' <- cstringToText pos'''
    freeMem pos'''
    freeMem pos''
    return (result', pos'''')


-- function pango_shape_full
-- Args : [Arg {argCName = "item_text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "valid UTF-8 text to shape.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item_length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length (in bytes) of @item_text. -1 means nul-terminated text.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "paragraph_text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "text of the paragraph (see details).  May be %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "paragraph_length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length (in bytes) of @paragraph_text. -1 means nul-terminated text.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "analysis", argType = TInterface (Name {namespace = "Pango", name = "Analysis"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#PangoAnalysis structure from pango_itemize().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "glyphs", argType = TInterface (Name {namespace = "Pango", name = "GlyphString"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "glyph string in which to store results.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_shape_full" pango_shape_full ::
    CString ->                              -- item_text : TBasicType TUTF8
    Int32 ->                                -- item_length : TBasicType TInt
    CString ->                              -- paragraph_text : TBasicType TUTF8
    Int32 ->                                -- paragraph_length : TBasicType TInt
    Ptr Pango.Analysis.Analysis ->          -- analysis : TInterface (Name {namespace = "Pango", name = "Analysis"})
    Ptr Pango.GlyphString.GlyphString ->    -- glyphs : TInterface (Name {namespace = "Pango", name = "GlyphString"})
    IO ()

{- |
Given a segment of text and the corresponding
'GI.Pango.Structs.Analysis.Analysis' structure returned from 'GI.Pango.Functions.itemize',
convert the characters into glyphs. You may also pass
in only a substring of the item from 'GI.Pango.Functions.itemize'.

This is similar to 'GI.Pango.Functions.shape', except it also can optionally take
the full paragraph text as input, which will then be used to perform
certain cross-item shaping interactions.  If you have access to the broader
text of which /@itemText@/ is part of, provide the broader text as
/@paragraphText@/.  If /@paragraphText@/ is 'Nothing', item text is used instead.

/Since: 1.32/
-}
shapeFull ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@itemText@/: valid UTF-8 text to shape. -}
    -> Int32
    {- ^ /@itemLength@/: the length (in bytes) of /@itemText@/. -1 means nul-terminated text. -}
    -> Maybe (T.Text)
    {- ^ /@paragraphText@/: text of the paragraph (see details).  May be 'Nothing'. -}
    -> Int32
    {- ^ /@paragraphLength@/: the length (in bytes) of /@paragraphText@/. -1 means nul-terminated text. -}
    -> Pango.Analysis.Analysis
    {- ^ /@analysis@/: 'GI.Pango.Structs.Analysis.Analysis' structure from 'GI.Pango.Functions.itemize'. -}
    -> Pango.GlyphString.GlyphString
    {- ^ /@glyphs@/: glyph string in which to store results. -}
    -> m ()
shapeFull itemText itemLength paragraphText paragraphLength analysis glyphs = liftIO $ do
    itemText' <- textToCString itemText
    maybeParagraphText <- case paragraphText of
        Nothing -> return nullPtr
        Just jParagraphText -> do
            jParagraphText' <- textToCString jParagraphText
            return jParagraphText'
    analysis' <- unsafeManagedPtrGetPtr analysis
    glyphs' <- unsafeManagedPtrGetPtr glyphs
    pango_shape_full itemText' itemLength maybeParagraphText paragraphLength analysis' glyphs'
    touchManagedPtr analysis
    touchManagedPtr glyphs
    freeMem itemText'
    freeMem maybeParagraphText
    return ()


-- function pango_shape
-- Args : [Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the text to process", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length (in bytes) of @text", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "analysis", argType = TInterface (Name {namespace = "Pango", name = "Analysis"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#PangoAnalysis structure from pango_itemize()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "glyphs", argType = TInterface (Name {namespace = "Pango", name = "GlyphString"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "glyph string in which to store results", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_shape" pango_shape ::
    CString ->                              -- text : TBasicType TUTF8
    Int32 ->                                -- length : TBasicType TInt
    Ptr Pango.Analysis.Analysis ->          -- analysis : TInterface (Name {namespace = "Pango", name = "Analysis"})
    Ptr Pango.GlyphString.GlyphString ->    -- glyphs : TInterface (Name {namespace = "Pango", name = "GlyphString"})
    IO ()

{- |
Given a segment of text and the corresponding
'GI.Pango.Structs.Analysis.Analysis' structure returned from 'GI.Pango.Functions.itemize',
convert the characters into glyphs. You may also pass
in only a substring of the item from 'GI.Pango.Functions.itemize'.

It is recommended that you use 'GI.Pango.Functions.shapeFull' instead, since
that API allows for shaping interaction happening across text item
boundaries.
-}
shape ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@text@/: the text to process -}
    -> Int32
    {- ^ /@length@/: the length (in bytes) of /@text@/ -}
    -> Pango.Analysis.Analysis
    {- ^ /@analysis@/: 'GI.Pango.Structs.Analysis.Analysis' structure from 'GI.Pango.Functions.itemize' -}
    -> Pango.GlyphString.GlyphString
    {- ^ /@glyphs@/: glyph string in which to store results -}
    -> m ()
shape text length_ analysis glyphs = liftIO $ do
    text' <- textToCString text
    analysis' <- unsafeManagedPtrGetPtr analysis
    glyphs' <- unsafeManagedPtrGetPtr glyphs
    pango_shape text' length_ analysis' glyphs'
    touchManagedPtr analysis
    touchManagedPtr glyphs
    freeMem text'
    return ()


-- function pango_scan_word
-- Args : [Arg {argCName = "pos", argType = TBasicType TUTF8, direction = DirectionInout, mayBeNull = False, argDoc = Documentation {rawDocText = Just "in/out string position", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "out", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString into which to write the result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "pango_scan_word" pango_scan_word ::
    Ptr CString ->                          -- pos : TBasicType TUTF8
    Ptr GLib.String.String ->               -- out : TInterface (Name {namespace = "GLib", name = "String"})
    IO CInt

{-# DEPRECATED scanWord ["(Since version 1.38)"] #-}
{- |
Scans a word into a 'GI.GLib.Structs.String.String' buffer. A word consists
of [A-Za-z_] followed by zero or more [A-Za-z_0-9]
Leading white space is skipped.
-}
scanWord ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@pos@/: in\/out string position -}
    -> m ((Bool, T.Text, GLib.String.String))
    {- ^ __Returns:__ 'False' if a parse error occurred. -}
scanWord pos = liftIO $ do
    pos' <- textToCString pos
    pos'' <- allocMem :: IO (Ptr CString)
    poke pos'' pos'
    out <- callocBoxedBytes 24 :: IO (Ptr GLib.String.String)
    result <- pango_scan_word pos'' out
    let result' = (/= 0) result
    pos''' <- peek pos''
    pos'''' <- cstringToText pos'''
    freeMem pos'''
    out' <- (wrapBoxed GLib.String.String) out
    freeMem pos''
    return (result', pos'''', out')


-- function pango_scan_string
-- Args : [Arg {argCName = "pos", argType = TBasicType TUTF8, direction = DirectionInout, mayBeNull = False, argDoc = Documentation {rawDocText = Just "in/out string position", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "out", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString into which to write the result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "pango_scan_string" pango_scan_string ::
    Ptr CString ->                          -- pos : TBasicType TUTF8
    Ptr GLib.String.String ->               -- out : TInterface (Name {namespace = "GLib", name = "String"})
    IO CInt

{-# DEPRECATED scanString ["(Since version 1.38)"] #-}
{- |
Scans a string into a 'GI.GLib.Structs.String.String' buffer. The string may either
be a sequence of non-white-space characters, or a quoted
string with \'\"\'. Instead a quoted string, \'\\\"\' represents
a literal quote. Leading white space outside of quotes is skipped.
-}
scanString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@pos@/: in\/out string position -}
    -> m ((Bool, T.Text, GLib.String.String))
    {- ^ __Returns:__ 'False' if a parse error occurred. -}
scanString pos = liftIO $ do
    pos' <- textToCString pos
    pos'' <- allocMem :: IO (Ptr CString)
    poke pos'' pos'
    out <- callocBoxedBytes 24 :: IO (Ptr GLib.String.String)
    result <- pango_scan_string pos'' out
    let result' = (/= 0) result
    pos''' <- peek pos''
    pos'''' <- cstringToText pos'''
    freeMem pos'''
    out' <- (wrapBoxed GLib.String.String) out
    freeMem pos''
    return (result', pos'''', out')


-- function pango_scan_int
-- Args : [Arg {argCName = "pos", argType = TBasicType TUTF8, direction = DirectionInout, mayBeNull = False, argDoc = Documentation {rawDocText = Just "in/out string position", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "out", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an int into which to write the result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "pango_scan_int" pango_scan_int ::
    Ptr CString ->                          -- pos : TBasicType TUTF8
    Ptr Int32 ->                            -- out : TBasicType TInt
    IO CInt

{-# DEPRECATED scanInt ["(Since version 1.38)"] #-}
{- |
Scans an integer.
Leading white space is skipped.
-}
scanInt ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@pos@/: in\/out string position -}
    -> m ((Bool, T.Text, Int32))
    {- ^ __Returns:__ 'False' if a parse error occurred. -}
scanInt pos = liftIO $ do
    pos' <- textToCString pos
    pos'' <- allocMem :: IO (Ptr CString)
    poke pos'' pos'
    out <- allocMem :: IO (Ptr Int32)
    result <- pango_scan_int pos'' out
    let result' = (/= 0) result
    pos''' <- peek pos''
    pos'''' <- cstringToText pos'''
    freeMem pos'''
    out' <- peek out
    freeMem pos''
    freeMem out
    return (result', pos'''', out')


-- function pango_reorder_items
-- Args : [Arg {argCName = "logical_items", argType = TGList (TInterface (Name {namespace = "Pango", name = "Item"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GList of #PangoItem in logical order.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Pango", name = "Item"})))
-- throws : False
-- Skip return : False

foreign import ccall "pango_reorder_items" pango_reorder_items ::
    Ptr (GList (Ptr Pango.Item.Item)) ->    -- logical_items : TGList (TInterface (Name {namespace = "Pango", name = "Item"}))
    IO (Ptr (GList (Ptr Pango.Item.Item)))

{- |
From a list of items in logical order and the associated
directional levels, produce a list in visual order.
The original list is unmodified.
-}
reorderItems ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Pango.Item.Item]
    {- ^ /@logicalItems@/: a 'GI.GLib.Structs.List.List' of 'GI.Pango.Structs.Item.Item' in logical order. -}
    -> m [Pango.Item.Item]
    {- ^ __Returns:__ a 'GI.GLib.Structs.List.List'
         of 'GI.Pango.Structs.Item.Item' structures in visual order.

(Please open a bug if you use this function.
 It is not a particularly convenient interface, and the code
 is duplicated elsewhere in Pango for that reason.) -}
reorderItems logicalItems = liftIO $ do
    logicalItems' <- mapM unsafeManagedPtrGetPtr logicalItems
    logicalItems'' <- packGList logicalItems'
    result <- pango_reorder_items logicalItems''
    result' <- unpackGList result
    result'' <- mapM (wrapBoxed Pango.Item.Item) result'
    g_list_free result
    mapM_ touchManagedPtr logicalItems
    g_list_free logicalItems''
    return result''


-- function pango_read_line
-- Args : [Arg {argCName = "stream", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a stdio stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "str", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GString buffer into which to write the result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "pango_read_line" pango_read_line ::
    Ptr () ->                               -- stream : TBasicType TPtr
    Ptr GLib.String.String ->               -- str : TInterface (Name {namespace = "GLib", name = "String"})
    IO Int32

{-# DEPRECATED readLine ["(Since version 1.38)"] #-}
{- |
Reads an entire line from a file into a buffer. Lines may
be delimited with \'\\n\', \'\\r\', \'\\n\\r\', or \'\\r\\n\'. The delimiter
is not written into the buffer. Text after a \'#\' character is treated as
a comment and skipped. \'\\\' can be used to escape a # character.
\'\\\' proceeding a line delimiter combines adjacent lines. A \'\\\' proceeding
any other character is ignored and written into the output buffer
unmodified.
-}
readLine ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    {- ^ /@stream@/: a stdio stream -}
    -> m ((Int32, GLib.String.String))
    {- ^ __Returns:__ 0 if the stream was already at an @/EOF/@ character, otherwise
              the number of lines read (this is useful for maintaining
              a line number counter which doesn\'t combine lines with \'\\\') -}
readLine stream = liftIO $ do
    str <- callocBoxedBytes 24 :: IO (Ptr GLib.String.String)
    result <- pango_read_line stream str
    str' <- (wrapBoxed GLib.String.String) str
    return (result, str')


-- function pango_quantize_line_geometry
-- Args : [Arg {argCName = "thickness", argType = TBasicType TInt, direction = DirectionInout, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to the thickness of a line, in Pango units", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "position", argType = TBasicType TInt, direction = DirectionInout, mayBeNull = False, argDoc = Documentation {rawDocText = Just "corresponding position", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_quantize_line_geometry" pango_quantize_line_geometry ::
    Ptr Int32 ->                            -- thickness : TBasicType TInt
    Ptr Int32 ->                            -- position : TBasicType TInt
    IO ()

{- |
Quantizes the thickness and position of a line, typically an
underline or strikethrough, to whole device pixels, that is integer
multiples of 'GI.Pango.Constants.SCALE'. The purpose of this function is to avoid
such lines looking blurry.

Care is taken to make sure /@thickness@/ is at least one pixel when this
function returns, but returned /@position@/ may become zero as a result
of rounding.

/Since: 1.12/
-}
quantizeLineGeometry ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@thickness@/: pointer to the thickness of a line, in Pango units -}
    -> Int32
    {- ^ /@position@/: corresponding position -}
    -> m ((Int32, Int32))
quantizeLineGeometry thickness position = liftIO $ do
    thickness' <- allocMem :: IO (Ptr Int32)
    poke thickness' thickness
    position' <- allocMem :: IO (Ptr Int32)
    poke position' position
    pango_quantize_line_geometry thickness' position'
    thickness'' <- peek thickness'
    position'' <- peek position'
    freeMem thickness'
    freeMem position'
    return (thickness'', position'')


-- function pango_parse_weight
-- XXX Could not generate function pango_parse_weight
-- Error was : Not implemented: "Don't know how to allocate \"weight\" of type TInterface (Name {namespace = \"Pango\", name = \"Weight\"})"

-- function pango_parse_variant
-- XXX Could not generate function pango_parse_variant
-- Error was : Not implemented: "Don't know how to allocate \"variant\" of type TInterface (Name {namespace = \"Pango\", name = \"Variant\"})"

-- function pango_parse_style
-- XXX Could not generate function pango_parse_style
-- Error was : Not implemented: "Don't know how to allocate \"style\" of type TInterface (Name {namespace = \"Pango\", name = \"Style\"})"

-- function pango_parse_stretch
-- XXX Could not generate function pango_parse_stretch
-- Error was : Not implemented: "Don't know how to allocate \"stretch\" of type TInterface (Name {namespace = \"Pango\", name = \"Stretch\"})"

-- function pango_parse_markup
-- Args : [Arg {argCName = "markup_text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "markup to parse (see <link linkend=\"PangoMarkupFormat\">markup format</link>)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @markup_text, or -1 if nul-terminated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "accel_marker", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "character that precedes an accelerator, or 0 for none", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attr_list", argType = TInterface (Name {namespace = "Pango", name = "AttrList"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "address of return location for a #PangoAttrList, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "address of return location for text with tags stripped, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "accel_char", argType = TBasicType TUniChar, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "address of return location for accelerator char, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "pango_parse_markup" pango_parse_markup ::
    CString ->                              -- markup_text : TBasicType TUTF8
    Int32 ->                                -- length : TBasicType TInt
    CInt ->                                 -- accel_marker : TBasicType TUniChar
    Ptr (Ptr Pango.AttrList.AttrList) ->    -- attr_list : TInterface (Name {namespace = "Pango", name = "AttrList"})
    Ptr CString ->                          -- text : TBasicType TUTF8
    Ptr CInt ->                             -- accel_char : TBasicType TUniChar
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Parses marked-up text (see
\<link linkend=\"PangoMarkupFormat\">markup format\<\/link>) to create
a plain-text string and an attribute list.

If /@accelMarker@/ is nonzero, the given character will mark the
character following it as an accelerator. For example, /@accelMarker@/
might be an ampersand or underscore. All characters marked
as an accelerator will receive a 'GI.Pango.Enums.UnderlineLow' attribute,
and the first character so marked will be returned in /@accelChar@/.
Two /@accelMarker@/ characters following each other produce a single
literal /@accelMarker@/ character.

To parse a stream of pango markup incrementally, use 'GI.Pango.Functions.markupParserNew'.

If any error happens, none of the output arguments are touched except
for /@error@/.
-}
parseMarkup ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@markupText@/: markup to parse (see \<link linkend=\"PangoMarkupFormat\">markup format\<\/link>) -}
    -> Int32
    {- ^ /@length@/: length of /@markupText@/, or -1 if nul-terminated -}
    -> Char
    {- ^ /@accelMarker@/: character that precedes an accelerator, or 0 for none -}
    -> m ((Pango.AttrList.AttrList, T.Text, Char))
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
parseMarkup markupText length_ accelMarker = liftIO $ do
    markupText' <- textToCString markupText
    let accelMarker' = (fromIntegral . ord) accelMarker
    attrList <- allocMem :: IO (Ptr (Ptr Pango.AttrList.AttrList))
    text <- allocMem :: IO (Ptr CString)
    accelChar <- allocMem :: IO (Ptr CInt)
    onException (do
        _ <- propagateGError $ pango_parse_markup markupText' length_ accelMarker' attrList text accelChar
        attrList' <- peek attrList
        attrList'' <- (wrapBoxed Pango.AttrList.AttrList) attrList'
        text' <- peek text
        text'' <- cstringToText text'
        freeMem text'
        accelChar' <- peek accelChar
        let accelChar'' = (chr . fromIntegral) accelChar'
        freeMem markupText'
        freeMem attrList
        freeMem text
        freeMem accelChar
        return (attrList'', text'', accelChar'')
     ) (do
        freeMem markupText'
        freeMem attrList
        freeMem text
        freeMem accelChar
     )


-- function pango_parse_enum
-- Args : [Arg {argCName = "type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "enum type to parse, eg. %PANGO_TYPE_ELLIPSIZE_MODE.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "string to parse.  May be %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "integer to store the result in, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "warn", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "if %TRUE, issue a g_warning() on bad input.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "possible_values", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "place to store list of possible values on failure, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "pango_parse_enum" pango_parse_enum ::
    CGType ->                               -- type : TBasicType TGType
    CString ->                              -- str : TBasicType TUTF8
    Ptr Int32 ->                            -- value : TBasicType TInt
    CInt ->                                 -- warn : TBasicType TBoolean
    Ptr CString ->                          -- possible_values : TBasicType TUTF8
    IO CInt

{-# DEPRECATED parseEnum ["(Since version 1.38)"] #-}
{- |
Parses an enum type and stores the result in /@value@/.

If /@str@/ does not match the nick name of any of the possible values for the
enum and is not an integer, 'False' is returned, a warning is issued
if /@warn@/ is 'True', and a
string representing the list of possible values is stored in
/@possibleValues@/.  The list is slash-separated, eg.
\"none\/start\/middle\/end\".  If failed and /@possibleValues@/ is not 'Nothing',
returned string should be freed using 'GI.GLib.Functions.free'.

/Since: 1.16/
-}
parseEnum ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GType
    {- ^ /@type@/: enum type to parse, eg. @/PANGO_TYPE_ELLIPSIZE_MODE/@. -}
    -> Maybe (T.Text)
    {- ^ /@str@/: string to parse.  May be 'Nothing'. -}
    -> Bool
    {- ^ /@warn@/: if 'True', issue a @/g_warning()/@ on bad input. -}
    -> m ((Bool, Int32, T.Text))
    {- ^ __Returns:__ 'True' if /@str@/ was successfully parsed. -}
parseEnum type_ str warn = liftIO $ do
    let type_' = gtypeToCGType type_
    maybeStr <- case str of
        Nothing -> return nullPtr
        Just jStr -> do
            jStr' <- textToCString jStr
            return jStr'
    value <- allocMem :: IO (Ptr Int32)
    let warn' = (fromIntegral . fromEnum) warn
    possibleValues <- allocMem :: IO (Ptr CString)
    result <- pango_parse_enum type_' maybeStr value warn' possibleValues
    let result' = (/= 0) result
    value' <- peek value
    possibleValues' <- peek possibleValues
    possibleValues'' <- cstringToText possibleValues'
    freeMem possibleValues'
    freeMem maybeStr
    freeMem value
    freeMem possibleValues
    return (result', value', possibleValues'')


-- function pango_module_register
-- Args : [Arg {argCName = "module", argType = TInterface (Name {namespace = "Pango", name = "IncludedModule"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoIncludedModule", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_module_register" pango_module_register ::
    Ptr Pango.IncludedModule.IncludedModule -> -- module : TInterface (Name {namespace = "Pango", name = "IncludedModule"})
    IO ()

{-# DEPRECATED moduleRegister ["(Since version 1.38)"] #-}
{- |
Do not use.  Does not do anything.
-}
moduleRegister ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Pango.IncludedModule.IncludedModule
    {- ^ /@module@/: a 'GI.Pango.Structs.IncludedModule.IncludedModule' -}
    -> m ()
moduleRegister module_ = liftIO $ do
    module_' <- unsafeManagedPtrGetPtr module_
    pango_module_register module_'
    touchManagedPtr module_
    return ()


-- function pango_markup_parser_new
-- Args : [Arg {argCName = "accel_marker", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "character that precedes an accelerator, or 0 for none", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "MarkupParseContext"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_markup_parser_new" pango_markup_parser_new ::
    CInt ->                                 -- accel_marker : TBasicType TUniChar
    IO (Ptr GLib.MarkupParseContext.MarkupParseContext)

{- |
Parses marked-up text (see
\<link linkend=\"PangoMarkupFormat\">markup format\<\/link>) to create
a plain-text string and an attribute list.

If /@accelMarker@/ is nonzero, the given character will mark the
character following it as an accelerator. For example, /@accelMarker@/
might be an ampersand or underscore. All characters marked
as an accelerator will receive a 'GI.Pango.Enums.UnderlineLow' attribute,
and the first character so marked will be returned in /@accelChar@/,
when calling @/finish()/@. Two /@accelMarker@/ characters following each
other produce a single literal /@accelMarker@/ character.

To feed markup to the parser, use 'GI.GLib.Structs.MarkupParseContext.markupParseContextParse'
on the returned 'GI.GLib.Structs.MarkupParseContext.MarkupParseContext'. When done with feeding markup
to the parser, use 'GI.Pango.Functions.markupParserFinish' to get the data out
of it, and then use 'GI.GLib.Structs.MarkupParseContext.markupParseContextFree' to free it.

This function is designed for applications that read pango markup
from streams. To simply parse a string containing pango markup,
the simpler 'GI.Pango.Functions.parseMarkup' API is recommended instead.

/Since: 1.31.0/
-}
markupParserNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@accelMarker@/: character that precedes an accelerator, or 0 for none -}
    -> m GLib.MarkupParseContext.MarkupParseContext
    {- ^ __Returns:__ a 'GI.GLib.Structs.MarkupParseContext.MarkupParseContext' that should be
destroyed with 'GI.GLib.Structs.MarkupParseContext.markupParseContextFree'. -}
markupParserNew accelMarker = liftIO $ do
    let accelMarker' = (fromIntegral . ord) accelMarker
    result <- pango_markup_parser_new accelMarker'
    checkUnexpectedReturnNULL "markupParserNew" result
    result' <- (newBoxed GLib.MarkupParseContext.MarkupParseContext) result
    return result'


-- function pango_markup_parser_finish
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "MarkupParseContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A valid parse context that was returned from pango_markup_parser_new()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attr_list", argType = TInterface (Name {namespace = "Pango", name = "AttrList"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "address of return location for a #PangoAttrList, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "address of return location for text with tags stripped, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "accel_char", argType = TBasicType TUniChar, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "address of return location for accelerator char, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "pango_markup_parser_finish" pango_markup_parser_finish ::
    Ptr GLib.MarkupParseContext.MarkupParseContext -> -- context : TInterface (Name {namespace = "GLib", name = "MarkupParseContext"})
    Ptr (Ptr Pango.AttrList.AttrList) ->    -- attr_list : TInterface (Name {namespace = "Pango", name = "AttrList"})
    Ptr CString ->                          -- text : TBasicType TUTF8
    Ptr CInt ->                             -- accel_char : TBasicType TUniChar
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
After feeding a pango markup parser some data with 'GI.GLib.Structs.MarkupParseContext.markupParseContextParse',
use this function to get the list of pango attributes and text out of the
markup. This function will not free /@context@/, use 'GI.GLib.Structs.MarkupParseContext.markupParseContextFree'
to do so.

/Since: 1.31.0/
-}
markupParserFinish ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GLib.MarkupParseContext.MarkupParseContext
    {- ^ /@context@/: A valid parse context that was returned from 'GI.Pango.Functions.markupParserNew' -}
    -> m ((Pango.AttrList.AttrList, T.Text, Char))
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
markupParserFinish context = liftIO $ do
    context' <- unsafeManagedPtrGetPtr context
    attrList <- allocMem :: IO (Ptr (Ptr Pango.AttrList.AttrList))
    text <- allocMem :: IO (Ptr CString)
    accelChar <- allocMem :: IO (Ptr CInt)
    onException (do
        _ <- propagateGError $ pango_markup_parser_finish context' attrList text accelChar
        attrList' <- peek attrList
        attrList'' <- (wrapBoxed Pango.AttrList.AttrList) attrList'
        text' <- peek text
        text'' <- cstringToText text'
        freeMem text'
        accelChar' <- peek accelChar
        let accelChar'' = (chr . fromIntegral) accelChar'
        touchManagedPtr context
        freeMem attrList
        freeMem text
        freeMem accelChar
        return (attrList'', text'', accelChar'')
     ) (do
        freeMem attrList
        freeMem text
        freeMem accelChar
     )


-- function pango_lookup_aliases
-- Args : [Arg {argCName = "fontname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an ascii string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "families", argType = TCArray False (-1) 2 (TBasicType TUTF8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "will be set to an array of font family names.\n   this array is owned by pango and should not be freed.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "n_families", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "will be set to the length of the @families array.", 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 "will be set to the length of the @families array.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_lookup_aliases" pango_lookup_aliases ::
    CString ->                              -- fontname : TBasicType TUTF8
    Ptr (Ptr CString) ->                    -- families : TCArray False (-1) 2 (TBasicType TUTF8)
    Ptr Int32 ->                            -- n_families : TBasicType TInt
    IO ()

{-# DEPRECATED lookupAliases ["(Since version 1.32)","This function is not thread-safe."] #-}
{- |
Look up all user defined aliases for the alias /@fontname@/.
The resulting font family names will be stored in /@families@/,
and the number of families in /@nFamilies@/.
-}
lookupAliases ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@fontname@/: an ascii string -}
    -> m ([T.Text])
lookupAliases fontname = liftIO $ do
    fontname' <- textToCString fontname
    families <- allocMem :: IO (Ptr (Ptr CString))
    nFamilies <- allocMem :: IO (Ptr Int32)
    pango_lookup_aliases fontname' families nFamilies
    nFamilies' <- peek nFamilies
    families' <- peek families
    families'' <- (unpackUTF8CArrayWithLength nFamilies') families'
    (mapCArrayWithLength nFamilies') freeMem families'
    freeMem families'
    freeMem fontname'
    freeMem families
    freeMem nFamilies
    return families''


-- function pango_log2vis_get_embedding_levels
-- Args : [Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the text to itemize.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes (not characters) to process, or -1\n            if @text is nul-terminated and the length should be calculated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pbase_dir", argType = TInterface (Name {namespace = "Pango", name = "Direction"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "input base direction, and output resolved direction.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt8)
-- throws : False
-- Skip return : False

foreign import ccall "pango_log2vis_get_embedding_levels" pango_log2vis_get_embedding_levels ::
    CString ->                              -- text : TBasicType TUTF8
    Int32 ->                                -- length : TBasicType TInt
    CUInt ->                                -- pbase_dir : TInterface (Name {namespace = "Pango", name = "Direction"})
    IO Word8

{- |
This will return the bidirectional embedding levels of the input paragraph
as defined by the Unicode Bidirectional Algorithm available at:

  http:\/\/www.unicode.org\/reports\/tr9\/

If the input base direction is a weak direction, the direction of the
characters in the text will determine the final resolved direction.

/Since: 1.4/
-}
log2visGetEmbeddingLevels ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@text@/: the text to itemize. -}
    -> Int32
    {- ^ /@length@/: the number of bytes (not characters) to process, or -1
            if /@text@/ is nul-terminated and the length should be calculated. -}
    -> Pango.Enums.Direction
    {- ^ /@pbaseDir@/: input base direction, and output resolved direction. -}
    -> m Word8
    {- ^ __Returns:__ a newly allocated array of embedding levels, one item per
              character (not byte), that should be freed using g_free. -}
log2visGetEmbeddingLevels text length_ pbaseDir = liftIO $ do
    text' <- textToCString text
    let pbaseDir' = (fromIntegral . fromEnum) pbaseDir
    result <- pango_log2vis_get_embedding_levels text' length_ pbaseDir'
    freeMem text'
    return result


-- function pango_itemize_with_base_dir
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a structure holding information that affects\n            the itemization process.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "base_dir", argType = TInterface (Name {namespace = "Pango", name = "Direction"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "base direction to use for bidirectional processing", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the text to itemize.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "start_index", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "first byte in @text to process", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes (not characters) to process\n            after @start_index. This must be >= 0.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attrs", argType = TInterface (Name {namespace = "Pango", name = "AttrList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the set of attributes that apply to @text.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cached_iter", argType = TInterface (Name {namespace = "Pango", name = "AttrIterator"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cached attribute iterator, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Pango", name = "Item"})))
-- throws : False
-- Skip return : False

foreign import ccall "pango_itemize_with_base_dir" pango_itemize_with_base_dir ::
    Ptr Pango.Context.Context ->            -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    CUInt ->                                -- base_dir : TInterface (Name {namespace = "Pango", name = "Direction"})
    CString ->                              -- text : TBasicType TUTF8
    Int32 ->                                -- start_index : TBasicType TInt
    Int32 ->                                -- length : TBasicType TInt
    Ptr Pango.AttrList.AttrList ->          -- attrs : TInterface (Name {namespace = "Pango", name = "AttrList"})
    Ptr Pango.AttrIterator.AttrIterator ->  -- cached_iter : TInterface (Name {namespace = "Pango", name = "AttrIterator"})
    IO (Ptr (GList (Ptr Pango.Item.Item)))

{- |
Like 'GI.Pango.Functions.itemize', but the base direction to use when
computing bidirectional levels (see pango_context_set_base_dir ()),
is specified explicitly rather than gotten from the 'GI.Pango.Objects.Context.Context'.

/Since: 1.4/
-}
itemizeWithBaseDir ::
    (B.CallStack.HasCallStack, MonadIO m, Pango.Context.IsContext a) =>
    a
    {- ^ /@context@/: a structure holding information that affects
            the itemization process. -}
    -> Pango.Enums.Direction
    {- ^ /@baseDir@/: base direction to use for bidirectional processing -}
    -> T.Text
    {- ^ /@text@/: the text to itemize. -}
    -> Int32
    {- ^ /@startIndex@/: first byte in /@text@/ to process -}
    -> Int32
    {- ^ /@length@/: the number of bytes (not characters) to process
            after /@startIndex@/. This must be >= 0. -}
    -> Pango.AttrList.AttrList
    {- ^ /@attrs@/: the set of attributes that apply to /@text@/. -}
    -> Maybe (Pango.AttrIterator.AttrIterator)
    {- ^ /@cachedIter@/: Cached attribute iterator, or 'Nothing' -}
    -> m [Pango.Item.Item]
    {- ^ __Returns:__ a 'GI.GLib.Structs.List.List' of
              'GI.Pango.Structs.Item.Item' structures.  The items should be freed using
              'GI.Pango.Structs.Item.itemFree' probably in combination with
              @/g_list_foreach()/@, and the list itself using @/g_list_free()/@. -}
itemizeWithBaseDir context baseDir text startIndex length_ attrs cachedIter = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    let baseDir' = (fromIntegral . fromEnum) baseDir
    text' <- textToCString text
    attrs' <- unsafeManagedPtrGetPtr attrs
    maybeCachedIter <- case cachedIter of
        Nothing -> return nullPtr
        Just jCachedIter -> do
            jCachedIter' <- unsafeManagedPtrGetPtr jCachedIter
            return jCachedIter'
    result <- pango_itemize_with_base_dir context' baseDir' text' startIndex length_ attrs' maybeCachedIter
    result' <- unpackGList result
    result'' <- mapM (wrapBoxed Pango.Item.Item) result'
    g_list_free result
    touchManagedPtr context
    touchManagedPtr attrs
    whenJust cachedIter touchManagedPtr
    freeMem text'
    return result''


-- function pango_itemize
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a structure holding information that affects\n\t       the itemization process.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the text to itemize.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "start_index", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "first byte in @text to process", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes (not characters) to process\n            after @start_index.\n            This must be >= 0.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attrs", argType = TInterface (Name {namespace = "Pango", name = "AttrList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the set of attributes that apply to @text.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cached_iter", argType = TInterface (Name {namespace = "Pango", name = "AttrIterator"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cached attribute iterator, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Pango", name = "Item"})))
-- throws : False
-- Skip return : False

foreign import ccall "pango_itemize" pango_itemize ::
    Ptr Pango.Context.Context ->            -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    CString ->                              -- text : TBasicType TUTF8
    Int32 ->                                -- start_index : TBasicType TInt
    Int32 ->                                -- length : TBasicType TInt
    Ptr Pango.AttrList.AttrList ->          -- attrs : TInterface (Name {namespace = "Pango", name = "AttrList"})
    Ptr Pango.AttrIterator.AttrIterator ->  -- cached_iter : TInterface (Name {namespace = "Pango", name = "AttrIterator"})
    IO (Ptr (GList (Ptr Pango.Item.Item)))

{- |
Breaks a piece of text into segments with consistent
directional level and shaping engine. Each byte of /@text@/ will
be contained in exactly one of the items in the returned list;
the generated list of items will be in logical order (the start
offsets of the items are ascending).

/@cachedIter@/ should be an iterator over /@attrs@/ currently positioned at a
range before or containing /@startIndex@/; /@cachedIter@/ will be advanced to
the range covering the position just after /@startIndex@/ + /@length@/.
(i.e. if itemizing in a loop, just keep passing in the same /@cachedIter@/).
-}
itemize ::
    (B.CallStack.HasCallStack, MonadIO m, Pango.Context.IsContext a) =>
    a
    {- ^ /@context@/: a structure holding information that affects
	       the itemization process. -}
    -> T.Text
    {- ^ /@text@/: the text to itemize. -}
    -> Int32
    {- ^ /@startIndex@/: first byte in /@text@/ to process -}
    -> Int32
    {- ^ /@length@/: the number of bytes (not characters) to process
            after /@startIndex@/.
            This must be >= 0. -}
    -> Pango.AttrList.AttrList
    {- ^ /@attrs@/: the set of attributes that apply to /@text@/. -}
    -> Maybe (Pango.AttrIterator.AttrIterator)
    {- ^ /@cachedIter@/: Cached attribute iterator, or 'Nothing' -}
    -> m [Pango.Item.Item]
    {- ^ __Returns:__ a 'GI.GLib.Structs.List.List' of 'GI.Pango.Structs.Item.Item'
              structures. The items should be freed using 'GI.Pango.Structs.Item.itemFree'
              probably in combination with @/g_list_foreach()/@, and the list itself
              using @/g_list_free()/@. -}
itemize context text startIndex length_ attrs cachedIter = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    text' <- textToCString text
    attrs' <- unsafeManagedPtrGetPtr attrs
    maybeCachedIter <- case cachedIter of
        Nothing -> return nullPtr
        Just jCachedIter -> do
            jCachedIter' <- unsafeManagedPtrGetPtr jCachedIter
            return jCachedIter'
    result <- pango_itemize context' text' startIndex length_ attrs' maybeCachedIter
    result' <- unpackGList result
    result'' <- mapM (wrapBoxed Pango.Item.Item) result'
    g_list_free result
    touchManagedPtr context
    touchManagedPtr attrs
    whenJust cachedIter touchManagedPtr
    freeMem text'
    return result''


-- function pango_is_zero_width
-- Args : [Arg {argCName = "ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "pango_is_zero_width" pango_is_zero_width ::
    CInt ->                                 -- ch : TBasicType TUniChar
    IO CInt

{- |
Checks /@ch@/ to see if it is a character that should not be
normally rendered on the screen.  This includes all Unicode characters
with \"ZERO WIDTH\" in their name, as well as \<firstterm>bidi\<\/firstterm> formatting characters, and
a few other ones.  This is totally different from 'GI.GLib.Functions.unicharIszerowidth'
and is at best misnamed.

/Since: 1.10/
-}
isZeroWidth ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@ch@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@ch@/ is a zero-width character, 'False' otherwise -}
isZeroWidth ch = liftIO $ do
    let ch' = (fromIntegral . ord) ch
    result <- pango_is_zero_width ch'
    let result' = (/= 0) result
    return result'


-- function pango_get_sysconf_subdirectory
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "pango_get_sysconf_subdirectory" pango_get_sysconf_subdirectory ::
    IO CString

{-# DEPRECATED getSysconfSubdirectory ["(Since version 1.38)"] #-}
{- |
Returns the name of the \"pango\" subdirectory of SYSCONFDIR
(which is set at compile time).
-}
getSysconfSubdirectory ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m T.Text
    {- ^ __Returns:__ the Pango sysconf directory. The returned string should
not be freed. -}
getSysconfSubdirectory  = liftIO $ do
    result <- pango_get_sysconf_subdirectory
    checkUnexpectedReturnNULL "getSysconfSubdirectory" result
    result' <- cstringToText result
    return result'


-- function pango_get_mirror_char
-- Args : [Arg {argCName = "ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mirrored_ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store the mirrored character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "pango_get_mirror_char" pango_get_mirror_char ::
    CInt ->                                 -- ch : TBasicType TUniChar
    CInt ->                                 -- mirrored_ch : TBasicType TUniChar
    IO CInt

{- |
If /@ch@/ has the Unicode mirrored property and there is another Unicode
character that typically has a glyph that is the mirror image of /@ch@/\'s
glyph, puts that character in the address pointed to by /@mirroredCh@/.

Use 'GI.GLib.Functions.unicharGetMirrorChar' instead; the docs for that function
provide full details.
-}
getMirrorChar ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@ch@/: a Unicode character -}
    -> Char
    {- ^ /@mirroredCh@/: location to store the mirrored character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@ch@/ has a mirrored character and /@mirroredCh@/ is
filled in, 'False' otherwise -}
getMirrorChar ch mirroredCh = liftIO $ do
    let ch' = (fromIntegral . ord) ch
    let mirroredCh' = (fromIntegral . ord) mirroredCh
    result <- pango_get_mirror_char ch' mirroredCh'
    let result' = (/= 0) result
    return result'


-- function pango_get_log_attrs
-- Args : [Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "text to process", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length in bytes of @text", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "level", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "embedding level, or -1 if unknown", 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 "language tag", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "log_attrs", argType = TCArray False (-1) 5 (TInterface (Name {namespace = "Pango", name = "LogAttr"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "array with one #PangoLogAttr\n  per character in @text, plus one extra, to be filled in", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attrs_len", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @log_attrs array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "attrs_len", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @log_attrs array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_get_log_attrs" pango_get_log_attrs ::
    CString ->                              -- text : TBasicType TUTF8
    Int32 ->                                -- length : TBasicType TInt
    Int32 ->                                -- level : TBasicType TInt
    Ptr Pango.Language.Language ->          -- language : TInterface (Name {namespace = "Pango", name = "Language"})
    Ptr Pango.LogAttr.LogAttr ->            -- log_attrs : TCArray False (-1) 5 (TInterface (Name {namespace = "Pango", name = "LogAttr"}))
    Int32 ->                                -- attrs_len : TBasicType TInt
    IO ()

{- |
Computes a 'GI.Pango.Structs.LogAttr.LogAttr' for each character in /@text@/. The /@logAttrs@/
array must have one 'GI.Pango.Structs.LogAttr.LogAttr' for each position in /@text@/; if
/@text@/ contains N characters, it has N+1 positions, including the
last position at the end of the text. /@text@/ should be an entire
paragraph; logical attributes can\'t be computed without context
(for example you need to see spaces on either side of a word to know
the word is a word).
-}
getLogAttrs ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@text@/: text to process -}
    -> Int32
    {- ^ /@length@/: length in bytes of /@text@/ -}
    -> Int32
    {- ^ /@level@/: embedding level, or -1 if unknown -}
    -> Pango.Language.Language
    {- ^ /@language@/: language tag -}
    -> [Pango.LogAttr.LogAttr]
    {- ^ /@logAttrs@/: array with one 'GI.Pango.Structs.LogAttr.LogAttr'
  per character in /@text@/, plus one extra, to be filled in -}
    -> m ()
getLogAttrs text length_ level language logAttrs = liftIO $ do
    let attrsLen = fromIntegral $ length logAttrs
    text' <- textToCString text
    language' <- unsafeManagedPtrGetPtr language
    logAttrs' <- mapM unsafeManagedPtrGetPtr logAttrs
    logAttrs'' <- packBlockArray 52 logAttrs'
    pango_get_log_attrs text' length_ level language' logAttrs'' attrsLen
    touchManagedPtr language
    mapM_ touchManagedPtr logAttrs
    freeMem text'
    freeMem logAttrs''
    return ()


-- function pango_get_lib_subdirectory
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "pango_get_lib_subdirectory" pango_get_lib_subdirectory ::
    IO CString

{-# DEPRECATED getLibSubdirectory ["(Since version 1.38)"] #-}
{- |
Returns the name of the \"pango\" subdirectory of LIBDIR
(which is set at compile time).
-}
getLibSubdirectory ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m T.Text
    {- ^ __Returns:__ the Pango lib directory. The returned string should
not be freed. -}
getLibSubdirectory  = liftIO $ do
    result <- pango_get_lib_subdirectory
    checkUnexpectedReturnNULL "getLibSubdirectory" result
    result' <- cstringToText result
    return result'


-- function pango_find_paragraph_boundary
-- Args : [Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "UTF-8 text", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @text in bytes, or -1 if nul-terminated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "paragraph_delimiter_index", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for index of\n  delimiter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "next_paragraph_start", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for start of next\n  paragraph", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_find_paragraph_boundary" pango_find_paragraph_boundary ::
    CString ->                              -- text : TBasicType TUTF8
    Int32 ->                                -- length : TBasicType TInt
    Ptr Int32 ->                            -- paragraph_delimiter_index : TBasicType TInt
    Ptr Int32 ->                            -- next_paragraph_start : TBasicType TInt
    IO ()

{- |
Locates a paragraph boundary in /@text@/. A boundary is caused by
delimiter characters, such as a newline, carriage return, carriage
return-newline pair, or Unicode paragraph separator character.  The
index of the run of delimiters is returned in
/@paragraphDelimiterIndex@/. The index of the start of the paragraph
(index after all delimiters) is stored in /@nextParagraphStart@/.

If no delimiters are found, both /@paragraphDelimiterIndex@/ and
/@nextParagraphStart@/ are filled with the length of /@text@/ (an index one
off the end).
-}
findParagraphBoundary ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@text@/: UTF-8 text -}
    -> Int32
    {- ^ /@length@/: length of /@text@/ in bytes, or -1 if nul-terminated -}
    -> m ((Int32, Int32))
findParagraphBoundary text length_ = liftIO $ do
    text' <- textToCString text
    paragraphDelimiterIndex <- allocMem :: IO (Ptr Int32)
    nextParagraphStart <- allocMem :: IO (Ptr Int32)
    pango_find_paragraph_boundary text' length_ paragraphDelimiterIndex nextParagraphStart
    paragraphDelimiterIndex' <- peek paragraphDelimiterIndex
    nextParagraphStart' <- peek nextParagraphStart
    freeMem text'
    freeMem paragraphDelimiterIndex
    freeMem nextParagraphStart
    return (paragraphDelimiterIndex', nextParagraphStart')


-- function pango_find_base_dir
-- Args : [Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the text to process", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @text in bytes (may be -1 if @text is nul-terminated)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Direction"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_find_base_dir" pango_find_base_dir ::
    CString ->                              -- text : TBasicType TUTF8
    Int32 ->                                -- length : TBasicType TInt
    IO CUInt

{- |
Searches a string the first character that has a strong
direction, according to the Unicode bidirectional algorithm.

/Since: 1.4/
-}
findBaseDir ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@text@/: the text to process -}
    -> Int32
    {- ^ /@length@/: length of /@text@/ in bytes (may be -1 if /@text@/ is nul-terminated) -}
    -> m Pango.Enums.Direction
    {- ^ __Returns:__ The direction corresponding to the first strong character.
If no such character is found, then 'GI.Pango.Enums.DirectionNeutral' is returned. -}
findBaseDir text length_ = liftIO $ do
    text' <- textToCString text
    result <- pango_find_base_dir text' length_
    let result' = (toEnum . fromIntegral) result
    freeMem text'
    return result'


-- function pango_extents_to_pixels
-- Args : [Arg {argCName = "inclusive", argType = TInterface (Name {namespace = "Pango", name = "Rectangle"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "rectangle to round to pixels inclusively, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "nearest", argType = TInterface (Name {namespace = "Pango", name = "Rectangle"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "rectangle to round to nearest pixels, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_extents_to_pixels" pango_extents_to_pixels ::
    Ptr Pango.Rectangle.Rectangle ->        -- inclusive : TInterface (Name {namespace = "Pango", name = "Rectangle"})
    Ptr Pango.Rectangle.Rectangle ->        -- nearest : TInterface (Name {namespace = "Pango", name = "Rectangle"})
    IO ()

{- |
Converts extents from Pango units to device units, dividing by the
'GI.Pango.Constants.SCALE' factor and performing rounding.

The /@inclusive@/ rectangle is converted by flooring the x\/y coordinates and extending
width\/height, such that the final rectangle completely includes the original
rectangle.

The /@nearest@/ rectangle is converted by rounding the coordinates
of the rectangle to the nearest device unit (pixel).

The rule to which argument to use is: if you want the resulting device-space
rectangle to completely contain the original rectangle, pass it in as /@inclusive@/.
If you want two touching-but-not-overlapping rectangles stay
touching-but-not-overlapping after rounding to device units, pass them in
as /@nearest@/.

/Since: 1.16/
-}
extentsToPixels ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (Pango.Rectangle.Rectangle)
    {- ^ /@inclusive@/: rectangle to round to pixels inclusively, or 'Nothing'. -}
    -> Maybe (Pango.Rectangle.Rectangle)
    {- ^ /@nearest@/: rectangle to round to nearest pixels, or 'Nothing'. -}
    -> m ()
extentsToPixels inclusive nearest = liftIO $ do
    maybeInclusive <- case inclusive of
        Nothing -> return nullPtr
        Just jInclusive -> do
            jInclusive' <- unsafeManagedPtrGetPtr jInclusive
            return jInclusive'
    maybeNearest <- case nearest of
        Nothing -> return nullPtr
        Just jNearest -> do
            jNearest' <- unsafeManagedPtrGetPtr jNearest
            return jNearest'
    pango_extents_to_pixels maybeInclusive maybeNearest
    whenJust inclusive touchManagedPtr
    whenJust nearest touchManagedPtr
    return ()


-- function pango_default_break
-- Args : [Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "text to break", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of text in bytes (may be -1 if @text is nul-terminated)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "analysis", argType = TInterface (Name {namespace = "Pango", name = "Analysis"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #PangoAnalysis for the @text", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attrs", argType = TInterface (Name {namespace = "Pango", name = "LogAttr"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "logical attributes to fill in", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attrs_len", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of the array passed as @attrs", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_default_break" pango_default_break ::
    CString ->                              -- text : TBasicType TUTF8
    Int32 ->                                -- length : TBasicType TInt
    Ptr Pango.Analysis.Analysis ->          -- analysis : TInterface (Name {namespace = "Pango", name = "Analysis"})
    Ptr Pango.LogAttr.LogAttr ->            -- attrs : TInterface (Name {namespace = "Pango", name = "LogAttr"})
    Int32 ->                                -- attrs_len : TBasicType TInt
    IO ()

{- |
This is the default break algorithm, used if no language
engine overrides it. Normally you should use 'GI.Pango.Functions.break'
instead. Unlike 'GI.Pango.Functions.break',
/@analysis@/ can be 'Nothing', but only do that if you know what
you\'re doing. If you need an analysis to pass to 'GI.Pango.Functions.break',
you need to 'GI.Pango.Functions.itemize'.  In most cases however you should
simply use 'GI.Pango.Functions.getLogAttrs'.
-}
defaultBreak ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@text@/: text to break -}
    -> Int32
    {- ^ /@length@/: length of text in bytes (may be -1 if /@text@/ is nul-terminated) -}
    -> Maybe (Pango.Analysis.Analysis)
    {- ^ /@analysis@/: a 'GI.Pango.Structs.Analysis.Analysis' for the /@text@/ -}
    -> Pango.LogAttr.LogAttr
    {- ^ /@attrs@/: logical attributes to fill in -}
    -> Int32
    {- ^ /@attrsLen@/: size of the array passed as /@attrs@/ -}
    -> m ()
defaultBreak text length_ analysis attrs attrsLen = liftIO $ do
    text' <- textToCString text
    maybeAnalysis <- case analysis of
        Nothing -> return nullPtr
        Just jAnalysis -> do
            jAnalysis' <- unsafeManagedPtrGetPtr jAnalysis
            return jAnalysis'
    attrs' <- unsafeManagedPtrGetPtr attrs
    pango_default_break text' length_ maybeAnalysis attrs' attrsLen
    whenJust analysis touchManagedPtr
    touchManagedPtr attrs
    freeMem text'
    return ()


-- function pango_config_key_get_system
-- Args : [Arg {argCName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Key to look up, in the form \"SECTION/KEY\".", 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_config_key_get_system" pango_config_key_get_system ::
    CString ->                              -- key : TBasicType TUTF8
    IO CString

{-# DEPRECATED configKeyGetSystem ["(Since version 1.38)"] #-}
{- |
Do not use.  Does not do anything.
-}
configKeyGetSystem ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@key@/: Key to look up, in the form \"SECTION\/KEY\". -}
    -> m T.Text
    {- ^ __Returns:__ 'Nothing' -}
configKeyGetSystem key = liftIO $ do
    key' <- textToCString key
    result <- pango_config_key_get_system key'
    checkUnexpectedReturnNULL "configKeyGetSystem" result
    result' <- cstringToText result
    freeMem result
    freeMem key'
    return result'


-- function pango_config_key_get
-- Args : [Arg {argCName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Key to look up, in the form \"SECTION/KEY\".", 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_config_key_get" pango_config_key_get ::
    CString ->                              -- key : TBasicType TUTF8
    IO CString

{-# DEPRECATED configKeyGet ["(Since version 1.38)"] #-}
{- |
Do not use.  Does not do anything.
-}
configKeyGet ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@key@/: Key to look up, in the form \"SECTION\/KEY\". -}
    -> m T.Text
    {- ^ __Returns:__ 'Nothing' -}
configKeyGet key = liftIO $ do
    key' <- textToCString key
    result <- pango_config_key_get key'
    checkUnexpectedReturnNULL "configKeyGet" result
    result' <- cstringToText result
    freeMem result
    freeMem key'
    return result'


-- function pango_break
-- Args : [Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the text to process", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @text in bytes (may be -1 if @text is nul-terminated)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "analysis", argType = TInterface (Name {namespace = "Pango", name = "Analysis"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#PangoAnalysis structure from pango_itemize()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attrs", argType = TCArray False (-1) 4 (TInterface (Name {namespace = "Pango", name = "LogAttr"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an array to store character\n            information in", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "attrs_len", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of the array passed as @attrs", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "attrs_len", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of the array passed as @attrs", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_break" pango_break ::
    CString ->                              -- text : TBasicType TUTF8
    Int32 ->                                -- length : TBasicType TInt
    Ptr Pango.Analysis.Analysis ->          -- analysis : TInterface (Name {namespace = "Pango", name = "Analysis"})
    Ptr Pango.LogAttr.LogAttr ->            -- attrs : TCArray False (-1) 4 (TInterface (Name {namespace = "Pango", name = "LogAttr"}))
    Int32 ->                                -- attrs_len : TBasicType TInt
    IO ()

{- |
Determines possible line, word, and character breaks
for a string of Unicode text with a single analysis.  For most
purposes you may want to use 'GI.Pango.Functions.getLogAttrs'.
-}
break ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@text@/: the text to process -}
    -> Int32
    {- ^ /@length@/: length of /@text@/ in bytes (may be -1 if /@text@/ is nul-terminated) -}
    -> Pango.Analysis.Analysis
    {- ^ /@analysis@/: 'GI.Pango.Structs.Analysis.Analysis' structure from 'GI.Pango.Functions.itemize' -}
    -> [Pango.LogAttr.LogAttr]
    {- ^ /@attrs@/: an array to store character
            information in -}
    -> m ()
break text length_ analysis attrs = liftIO $ do
    let attrsLen = fromIntegral $ length attrs
    text' <- textToCString text
    analysis' <- unsafeManagedPtrGetPtr analysis
    attrs' <- mapM unsafeManagedPtrGetPtr attrs
    attrs'' <- packBlockArray 52 attrs'
    pango_break text' length_ analysis' attrs'' attrsLen
    touchManagedPtr analysis
    mapM_ touchManagedPtr attrs
    freeMem text'
    freeMem attrs''
    return ()


-- function pango_attr_weight_new
-- Args : [Arg {argCName = "weight", argType = TInterface (Name {namespace = "Pango", name = "Weight"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the weight", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_weight_new" pango_attr_weight_new ::
    CUInt ->                                -- weight : TInterface (Name {namespace = "Pango", name = "Weight"})
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new font weight attribute.
-}
attrWeightNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Pango.Enums.Weight
    {- ^ /@weight@/: the weight -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrWeightNew weight = liftIO $ do
    let weight' = (fromIntegral . fromEnum) weight
    result <- pango_attr_weight_new weight'
    checkUnexpectedReturnNULL "attrWeightNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_variant_new
-- Args : [Arg {argCName = "variant", argType = TInterface (Name {namespace = "Pango", name = "Variant"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the variant", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_variant_new" pango_attr_variant_new ::
    CUInt ->                                -- variant : TInterface (Name {namespace = "Pango", name = "Variant"})
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new font variant attribute (normal or small caps)
-}
attrVariantNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Pango.Enums.Variant
    {- ^ /@variant@/: the variant -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrVariantNew variant = liftIO $ do
    let variant' = (fromIntegral . fromEnum) variant
    result <- pango_attr_variant_new variant'
    checkUnexpectedReturnNULL "attrVariantNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_underline_new
-- Args : [Arg {argCName = "underline", argType = TInterface (Name {namespace = "Pango", name = "Underline"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the underline style.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_underline_new" pango_attr_underline_new ::
    CUInt ->                                -- underline : TInterface (Name {namespace = "Pango", name = "Underline"})
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new underline-style attribute.
-}
attrUnderlineNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Pango.Enums.Underline
    {- ^ /@underline@/: the underline style. -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrUnderlineNew underline = liftIO $ do
    let underline' = (fromIntegral . fromEnum) underline
    result <- pango_attr_underline_new underline'
    checkUnexpectedReturnNULL "attrUnderlineNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_underline_color_new
-- Args : [Arg {argCName = "red", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the red value (ranging from 0 to 65535)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "green", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the green value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "blue", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the blue value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_underline_color_new" pango_attr_underline_color_new ::
    Word16 ->                               -- red : TBasicType TUInt16
    Word16 ->                               -- green : TBasicType TUInt16
    Word16 ->                               -- blue : TBasicType TUInt16
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new underline color attribute. This attribute
modifies the color of underlines. If not set, underlines
will use the foreground color.

/Since: 1.8/
-}
attrUnderlineColorNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word16
    {- ^ /@red@/: the red value (ranging from 0 to 65535) -}
    -> Word16
    {- ^ /@green@/: the green value -}
    -> Word16
    {- ^ /@blue@/: the blue value -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrUnderlineColorNew red green blue = liftIO $ do
    result <- pango_attr_underline_color_new red green blue
    checkUnexpectedReturnNULL "attrUnderlineColorNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_style_new
-- Args : [Arg {argCName = "style", argType = TInterface (Name {namespace = "Pango", name = "Style"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the slant style", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_style_new" pango_attr_style_new ::
    CUInt ->                                -- style : TInterface (Name {namespace = "Pango", name = "Style"})
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new font slant style attribute.
-}
attrStyleNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Pango.Enums.Style
    {- ^ /@style@/: the slant style -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrStyleNew style = liftIO $ do
    let style' = (fromIntegral . fromEnum) style
    result <- pango_attr_style_new style'
    checkUnexpectedReturnNULL "attrStyleNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_strikethrough_new
-- Args : [Arg {argCName = "strikethrough", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE if the text should be struck-through.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_strikethrough_new" pango_attr_strikethrough_new ::
    CInt ->                                 -- strikethrough : TBasicType TBoolean
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new strike-through attribute.
-}
attrStrikethroughNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Bool
    {- ^ /@strikethrough@/: 'True' if the text should be struck-through. -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrStrikethroughNew strikethrough = liftIO $ do
    let strikethrough' = (fromIntegral . fromEnum) strikethrough
    result <- pango_attr_strikethrough_new strikethrough'
    checkUnexpectedReturnNULL "attrStrikethroughNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_strikethrough_color_new
-- Args : [Arg {argCName = "red", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the red value (ranging from 0 to 65535)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "green", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the green value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "blue", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the blue value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_strikethrough_color_new" pango_attr_strikethrough_color_new ::
    Word16 ->                               -- red : TBasicType TUInt16
    Word16 ->                               -- green : TBasicType TUInt16
    Word16 ->                               -- blue : TBasicType TUInt16
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new strikethrough color attribute. This attribute
modifies the color of strikethrough lines. If not set, strikethrough
lines will use the foreground color.

/Since: 1.8/
-}
attrStrikethroughColorNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word16
    {- ^ /@red@/: the red value (ranging from 0 to 65535) -}
    -> Word16
    {- ^ /@green@/: the green value -}
    -> Word16
    {- ^ /@blue@/: the blue value -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrStrikethroughColorNew red green blue = liftIO $ do
    result <- pango_attr_strikethrough_color_new red green blue
    checkUnexpectedReturnNULL "attrStrikethroughColorNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_stretch_new
-- Args : [Arg {argCName = "stretch", argType = TInterface (Name {namespace = "Pango", name = "Stretch"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the stretch", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_stretch_new" pango_attr_stretch_new ::
    CUInt ->                                -- stretch : TInterface (Name {namespace = "Pango", name = "Stretch"})
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new font stretch attribute
-}
attrStretchNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Pango.Enums.Stretch
    {- ^ /@stretch@/: the stretch -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrStretchNew stretch = liftIO $ do
    let stretch' = (fromIntegral . fromEnum) stretch
    result <- pango_attr_stretch_new stretch'
    checkUnexpectedReturnNULL "attrStretchNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_scale_new
-- Args : [Arg {argCName = "scale_factor", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "factor to scale the font", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_scale_new" pango_attr_scale_new ::
    CDouble ->                              -- scale_factor : TBasicType TDouble
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new font size scale attribute. The base font for the
affected text will have its size multiplied by /@scaleFactor@/.
-}
attrScaleNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Double
    {- ^ /@scaleFactor@/: factor to scale the font -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrScaleNew scaleFactor = liftIO $ do
    let scaleFactor' = realToFrac scaleFactor
    result <- pango_attr_scale_new scaleFactor'
    checkUnexpectedReturnNULL "attrScaleNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_rise_new
-- Args : [Arg {argCName = "rise", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the amount that the text should be displaced vertically,\n       in Pango units. Positive values displace the text upwards.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_rise_new" pango_attr_rise_new ::
    Int32 ->                                -- rise : TBasicType TInt
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new baseline displacement attribute.
-}
attrRiseNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@rise@/: the amount that the text should be displaced vertically,
       in Pango units. Positive values displace the text upwards. -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrRiseNew rise = liftIO $ do
    result <- pango_attr_rise_new rise
    checkUnexpectedReturnNULL "attrRiseNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_letter_spacing_new
-- Args : [Arg {argCName = "letter_spacing", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "amount of extra space to add between graphemes\n  of the text, in Pango units.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_letter_spacing_new" pango_attr_letter_spacing_new ::
    Int32 ->                                -- letter_spacing : TBasicType TInt
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new letter-spacing attribute.

/Since: 1.6/
-}
attrLetterSpacingNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@letterSpacing@/: amount of extra space to add between graphemes
  of the text, in Pango units. -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrLetterSpacingNew letterSpacing = liftIO $ do
    result <- pango_attr_letter_spacing_new letterSpacing
    checkUnexpectedReturnNULL "attrLetterSpacingNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_gravity_new
-- Args : [Arg {argCName = "gravity", argType = TInterface (Name {namespace = "Pango", name = "Gravity"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the gravity value; should not be %PANGO_GRAVITY_AUTO.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_gravity_new" pango_attr_gravity_new ::
    CUInt ->                                -- gravity : TInterface (Name {namespace = "Pango", name = "Gravity"})
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new gravity attribute.

/Since: 1.16/
-}
attrGravityNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Pango.Enums.Gravity
    {- ^ /@gravity@/: the gravity value; should not be 'GI.Pango.Enums.GravityAuto'. -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrGravityNew gravity = liftIO $ do
    let gravity' = (fromIntegral . fromEnum) gravity
    result <- pango_attr_gravity_new gravity'
    checkUnexpectedReturnNULL "attrGravityNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_gravity_hint_new
-- Args : [Arg {argCName = "hint", argType = TInterface (Name {namespace = "Pango", name = "GravityHint"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the gravity hint value.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_gravity_hint_new" pango_attr_gravity_hint_new ::
    CUInt ->                                -- hint : TInterface (Name {namespace = "Pango", name = "GravityHint"})
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new gravity hint attribute.

/Since: 1.16/
-}
attrGravityHintNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Pango.Enums.GravityHint
    {- ^ /@hint@/: the gravity hint value. -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrGravityHintNew hint = liftIO $ do
    let hint' = (fromIntegral . fromEnum) hint
    result <- pango_attr_gravity_hint_new hint'
    checkUnexpectedReturnNULL "attrGravityHintNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_foreground_new
-- Args : [Arg {argCName = "red", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the red value (ranging from 0 to 65535)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "green", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the green value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "blue", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the blue value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_foreground_new" pango_attr_foreground_new ::
    Word16 ->                               -- red : TBasicType TUInt16
    Word16 ->                               -- green : TBasicType TUInt16
    Word16 ->                               -- blue : TBasicType TUInt16
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new foreground color attribute.
-}
attrForegroundNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word16
    {- ^ /@red@/: the red value (ranging from 0 to 65535) -}
    -> Word16
    {- ^ /@green@/: the green value -}
    -> Word16
    {- ^ /@blue@/: the blue value -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrForegroundNew red green blue = liftIO $ do
    result <- pango_attr_foreground_new red green blue
    checkUnexpectedReturnNULL "attrForegroundNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_foreground_alpha_new
-- Args : [Arg {argCName = "alpha", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the alpha value, between 1 and 65536", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_foreground_alpha_new" pango_attr_foreground_alpha_new ::
    Word16 ->                               -- alpha : TBasicType TUInt16
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new foreground alpha attribute.

/Since: 1.38/
-}
attrForegroundAlphaNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word16
    {- ^ /@alpha@/: the alpha value, between 1 and 65536 -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the new allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrForegroundAlphaNew alpha = liftIO $ do
    result <- pango_attr_foreground_alpha_new alpha
    checkUnexpectedReturnNULL "attrForegroundAlphaNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_family_new
-- Args : [Arg {argCName = "family", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the family or comma separated list of families", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_family_new" pango_attr_family_new ::
    CString ->                              -- family : TBasicType TUTF8
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new font family attribute.
-}
attrFamilyNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@family@/: the family or comma separated list of families -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrFamilyNew family = liftIO $ do
    family' <- textToCString family
    result <- pango_attr_family_new family'
    checkUnexpectedReturnNULL "attrFamilyNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    freeMem family'
    return result'


-- function pango_attr_fallback_new
-- Args : [Arg {argCName = "enable_fallback", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE if we should fall back on other fonts\n                  for characters the active font is missing.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_fallback_new" pango_attr_fallback_new ::
    CInt ->                                 -- enable_fallback : TBasicType TBoolean
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new font fallback attribute.

If fallback is disabled, characters will only be used from the
closest matching font on the system. No fallback will be done to
other fonts on the system that might contain the characters in the
text.

/Since: 1.4/
-}
attrFallbackNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Bool
    {- ^ /@enableFallback@/: 'True' if we should fall back on other fonts
                  for characters the active font is missing. -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrFallbackNew enableFallback = liftIO $ do
    let enableFallback' = (fromIntegral . fromEnum) enableFallback
    result <- pango_attr_fallback_new enableFallback'
    checkUnexpectedReturnNULL "attrFallbackNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_background_new
-- Args : [Arg {argCName = "red", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the red value (ranging from 0 to 65535)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "green", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the green value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "blue", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the blue value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_background_new" pango_attr_background_new ::
    Word16 ->                               -- red : TBasicType TUInt16
    Word16 ->                               -- green : TBasicType TUInt16
    Word16 ->                               -- blue : TBasicType TUInt16
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new background color attribute.
-}
attrBackgroundNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word16
    {- ^ /@red@/: the red value (ranging from 0 to 65535) -}
    -> Word16
    {- ^ /@green@/: the green value -}
    -> Word16
    {- ^ /@blue@/: the blue value -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrBackgroundNew red green blue = liftIO $ do
    result <- pango_attr_background_new red green blue
    checkUnexpectedReturnNULL "attrBackgroundNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'


-- function pango_attr_background_alpha_new
-- Args : [Arg {argCName = "alpha", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the alpha value, between 1 and 65536", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Attribute"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_background_alpha_new" pango_attr_background_alpha_new ::
    Word16 ->                               -- alpha : TBasicType TUInt16
    IO (Ptr Pango.Attribute.Attribute)

{- |
Create a new background alpha attribute.

/Since: 1.38/
-}
attrBackgroundAlphaNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word16
    {- ^ /@alpha@/: the alpha value, between 1 and 65536 -}
    -> m Pango.Attribute.Attribute
    {- ^ __Returns:__ the new allocated 'GI.Pango.Structs.Attribute.Attribute',
              which should be freed with 'GI.Pango.Structs.Attribute.attributeDestroy'. -}
attrBackgroundAlphaNew alpha = liftIO $ do
    result <- pango_attr_background_alpha_new alpha
    checkUnexpectedReturnNULL "attrBackgroundAlphaNew" result
    result' <- (wrapPtr Pango.Attribute.Attribute) result
    return result'