Skip to content

Commit 5dd66ac

Browse files
committed
Update to work with text-2.0
1 parent 26631ca commit 5dd66ac

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/SDL/Font.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ import Data.ByteString (ByteString)
9494
import Data.ByteString.Unsafe (unsafeUseAsCStringLen, unsafePackCString)
9595
import Data.Text (Text)
9696
import Data.Text.Encoding (decodeUtf8)
97-
import Data.Text.Foreign (lengthWord16, unsafeCopyToPtr)
97+
import Data.Text.Foreign (lengthWord8, unsafeCopyToPtr)
9898
import Data.Word (Word8, Word16)
9999
import Foreign.C.String (CString, withCString)
100-
import Foreign.C.Types (CUShort, CInt)
100+
import Foreign.C.Types (CChar, CUShort, CInt)
101101
import Foreign.Marshal.Alloc (allocaBytes, alloca)
102102
import Foreign.Marshal.Utils (with, fromBool, toBool)
103103
import 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
248248
withText 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.
257257
fromMaskWith :: (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.
511511
blendedWrapped :: MonadIO m => Font -> Color -> Int -> Text -> m SDL.Surface

0 commit comments

Comments
 (0)