You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.8 KiB

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