{-# LINE 1 "src/SFML/Graphics/Glyph.hsc" #-} {-# LANGUAGE CPP, ForeignFunctionInterface #-} {-# LINE 2 "src/SFML/Graphics/Glyph.hsc" #-} module SFML.Graphics.Glyph ( Glyph(..) ) where import SFML.Graphics.Rect import Foreign.C.Types import Foreign.Storable {-# LINE 15 "src/SFML/Graphics/Glyph.hsc" #-} sizeInt = (4) {-# LINE 18 "src/SFML/Graphics/Glyph.hsc" #-} sizeIntRect = (16) {-# LINE 19 "src/SFML/Graphics/Glyph.hsc" #-} -- | Describes a glyph (a visual character). data Glyph = Glyph { advance :: Int -- ^ Offset to move horizontically to the next character , bounds :: IntRect -- ^ Bounding rectangle of the glyph, in coordinates relative to the baseline , textureRect :: IntRect -- ^ Texture coordinates of the glyph inside the font's image } instance Storable Glyph where sizeOf _ = sizeInt + 2*sizeIntRect alignment _ = alignment (undefined :: IntRect) peek ptr = do advance <- (\hsc_ptr -> peekByteOff hsc_ptr 0) ptr :: IO CInt {-# LINE 35 "src/SFML/Graphics/Glyph.hsc" #-} bounds <- (\hsc_ptr -> peekByteOff hsc_ptr 4) ptr {-# LINE 36 "src/SFML/Graphics/Glyph.hsc" #-} rect <- (\hsc_ptr -> peekByteOff hsc_ptr 20) ptr {-# LINE 37 "src/SFML/Graphics/Glyph.hsc" #-} return $ Glyph (fromIntegral advance) bounds rect poke ptr (Glyph advance bounds rect) = do (\hsc_ptr -> pokeByteOff hsc_ptr 0) ptr (fromIntegral advance :: CInt) {-# LINE 41 "src/SFML/Graphics/Glyph.hsc" #-} (\hsc_ptr -> pokeByteOff hsc_ptr 4) ptr bounds {-# LINE 42 "src/SFML/Graphics/Glyph.hsc" #-} (\hsc_ptr -> pokeByteOff hsc_ptr 20) ptr rect {-# LINE 43 "src/SFML/Graphics/Glyph.hsc" #-}