{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) The #PangoGlyphGeometry structure contains width and positioning information for a single glyph. -} module GI.Pango.Structs.GlyphGeometry ( -- * Exported types GlyphGeometry(..) , newZeroGlyphGeometry , noGlyphGeometry , -- * Properties -- ** Width glyphGeometryReadWidth , -- ** XOffset glyphGeometryReadXOffset , -- ** YOffset glyphGeometryReadYOffset , ) where import Prelude () import Data.GI.Base.ShortPrelude import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import GI.Pango.Types import GI.Pango.Callbacks newtype GlyphGeometry = GlyphGeometry (ForeignPtr GlyphGeometry) -- | Construct a `GlyphGeometry` struct initialized to zero. newZeroGlyphGeometry :: MonadIO m => m GlyphGeometry newZeroGlyphGeometry = liftIO $ callocBytes 12 >>= wrapPtr GlyphGeometry noGlyphGeometry :: Maybe GlyphGeometry noGlyphGeometry = Nothing glyphGeometryReadWidth :: GlyphGeometry -> IO Int32 glyphGeometryReadWidth s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 0) :: IO Int32 return val glyphGeometryReadXOffset :: GlyphGeometry -> IO Int32 glyphGeometryReadXOffset s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 4) :: IO Int32 return val glyphGeometryReadYOffset :: GlyphGeometry -> IO Int32 glyphGeometryReadYOffset s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 8) :: IO Int32 return val type family ResolveGlyphGeometryMethod (t :: Symbol) (o :: *) :: * where ResolveGlyphGeometryMethod l o = MethodResolutionFailed l o instance (info ~ ResolveGlyphGeometryMethod t GlyphGeometry, MethodInfo info GlyphGeometry p) => IsLabelProxy t (GlyphGeometry -> p) where fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info) #if MIN_VERSION_base(4,9,0) instance (info ~ ResolveGlyphGeometryMethod t GlyphGeometry, MethodInfo info GlyphGeometry p) => IsLabel t (GlyphGeometry -> p) where fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info) #endif