text_bmfont_unordered.lua 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. -------------------------------------------------------------------------------------------
  2. --
  3. -- raylib [text] example - BMFont unordered chars loading and drawing
  4. --
  5. -- This example has been created using raylib 1.6 (www.raylib.com)
  6. -- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  7. --
  8. -- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
  9. --
  10. -------------------------------------------------------------------------------------------
  11. -- Initialization
  12. -------------------------------------------------------------------------------------------
  13. local screenWidth = 800
  14. local screenHeight = 450
  15. InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont unordered loading and drawing")
  16. -- NOTE: Using chars outside the [32..127] limits!
  17. -- NOTE: If a character is not found in the font, it just renders a space
  18. local msg = "ASCII extended characters:\n¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆ\nÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæ\nçèéêëìíîïðñòóôõö÷øùúûüýþÿ"
  19. -- NOTE: Loaded font has an unordered list of characters (chars in the range 32..255)
  20. local font = LoadSpriteFont("resources/fonts/pixantiqua.fnt") -- BMFont (AngelCode)
  21. SetTargetFPS(60)
  22. -------------------------------------------------------------------------------------------
  23. -- Main game loop
  24. while not WindowShouldClose() do -- Detect window close button or ESC key
  25. -- Update
  26. ---------------------------------------------------------------------------------------
  27. -- TODO: Update variables here...
  28. ---------------------------------------------------------------------------------------
  29. -- Draw
  30. ---------------------------------------------------------------------------------------
  31. BeginDrawing()
  32. ClearBackground(RAYWHITE)
  33. DrawText("Font name: PixAntiqua", 40, 50, 20, GRAY)
  34. DrawText(string.format("Font base size: %i", font.size), 40, 80, 20, GRAY)
  35. DrawText(string.format("Font chars number: %i", font.numChars), 40, 110, 20, GRAY)
  36. DrawTextEx(font, msg, Vector2(40, 180), font.size, 0, MAROON)
  37. EndDrawing()
  38. ---------------------------------------------------------------------------------------
  39. end
  40. -- De-Initialization
  41. -------------------------------------------------------------------------------------------
  42. UnloadSpriteFont(font) -- AngelCode SpriteFont unloading
  43. CloseWindow() -- Close window and OpenGL context
  44. -------------------------------------------------------------------------------------------