@@ -94,10 +94,10 @@ import Data.ByteString (ByteString)
9494import Data.ByteString.Unsafe (unsafeUseAsCStringLen , unsafePackCString )
9595import Data.Text (Text )
9696import Data.Text.Encoding (decodeUtf8 )
97- import Data.Text.Foreign (lengthWord16 , unsafeCopyToPtr )
97+ import Data.Text.Foreign (lengthWord8 , unsafeCopyToPtr )
9898import Data.Word (Word8 , Word16 )
9999import Foreign.C.String (CString , withCString )
100- import Foreign.C.Types (CUShort , CInt )
100+ import Foreign.C.Types (CChar , CUShort , CInt )
101101import Foreign.Marshal.Alloc (allocaBytes , alloca )
102102import Foreign.Marshal.Utils (with , fromBool , toBool )
103103import Foreign.Ptr (Ptr , castPtr , nullPtr )
@@ -244,14 +244,14 @@ blended (Font font) (V4 r g b a) text =
244244
245245-- Analogous to Data.Text.Foreign.useAsPtr, just appends a null-byte.
246246-- FIXME: Is this even necessary?
247- withText :: Text -> (Ptr Word16 -> IO a ) -> IO a
247+ withText :: Text -> (Ptr Word8 -> IO a ) -> IO a
248248withText text act =
249249 allocaBytes len $ \ ptr -> do
250250 unsafeCopyToPtr text ptr
251- pokeByteOff ptr (len - 2 ) (0 :: CUShort )
251+ pokeByteOff ptr (len - 2 ) (0 :: CChar )
252252 act ptr
253253 where
254- len = 2 * (lengthWord16 text + 1 )
254+ len = lengthWord8 text + 1
255255
256256-- Helper function for converting a bitmask into a list of values.
257257fromMaskWith :: (Enum a , Bounded a ) => (a -> CInt ) -> CInt -> [a ]
@@ -505,7 +505,7 @@ blendedGlyph (Font font) (V4 r g b a) ch =
505505 with (SDL.Raw. Color r g b a) $ \ fg ->
506506 SDL.Raw.Font. renderGlyph_Blended font (fromChar ch) fg
507507
508- -- | Same as 'blended', but renders across multiple lines.
508+ -- | Same as 'blended', but renders across multiple lines.
509509-- Text is wrapped to multiple lines on line endings and on word boundaries
510510-- if it extends beyond wrapLength in pixels.
511511blendedWrapped :: MonadIO m => Font -> Color -> Int -> Text -> m SDL. Surface
0 commit comments