Anut-py / h-raylib

Haskell bindings for Raylib
https://hackage.haskell.org/package/h-raylib
Apache License 2.0
80 stars 13 forks source link

drawTextEx not working properly #6

Closed barbafh3 closed 1 year ago

barbafh3 commented 1 year ago

I tried drawing text using drawTextEx and it mostly won't work, and sometimes it shows for a frame or 2 then nothing again. Tried using this code with two different fonts I know are working from another project:

mainFontPath :: String
mainFontPath = "/path/to/font"

main :: IO ()
main = do
  initWindow screenWidth screenHeight "Font Test"
  setTargetFPS 75

  mainFont <- loadFont mainFontPath
  gameLoop mainFont

gameLoop :: Font -> IO ()
gameLoop mainFont = do
  beginDrawing
  clearBackground rayWhite

  drawTextEx mainFont "Testing drawTextEx" (Vector2 640.0 12.0) 20.0 1.0 black

  endDrawing

  shouldClose <- windowShouldClose
  unless shouldClose $ gameLoop mainFont

And the logs show the font loaded successfully

Anut-py commented 1 year ago

This looks like a bug with loadFont. The font data isn't being marshalled properly into Haskell, which corrupts the font data. I'll work on this and try to find the source.

Anut-py commented 1 year ago

I have fixed this in version 4.5.0.6, please close the issue if it fixed the problem on your end.

barbafh3 commented 1 year ago

Confirmed. Retried the example and the text showed properly.