| 20 | #define MAX_FONTS 8 |
| 21 | |
| 22 | int main() { |
| 23 | // Initialization |
| 24 | //-------------------------------------------------------------------------------------- |
| 25 | int screenWidth = 800; |
| 26 | int screenHeight = 450; |
| 27 | |
| 28 | raylib::Window window(screenWidth, screenHeight, "raylib [text] example - raylib fonts"); |
| 29 | raylib::Color textColor = DARKGRAY; |
| 30 | |
| 31 | // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) |
| 32 | std::array<raylib::Font, MAX_FONTS> fonts = { |
| 33 | raylib::Font("resources/fonts/alagard.png"), |
| 34 | raylib::Font("resources/fonts/pixelplay.png"), |
| 35 | raylib::Font("resources/fonts/mecha.png"), |
| 36 | raylib::Font("resources/fonts/setback.png"), |
| 37 | raylib::Font("resources/fonts/romulus.png"), |
| 38 | raylib::Font("resources/fonts/pixantiqua.png"), |
| 39 | raylib::Font("resources/fonts/alpha_beta.png"), |
| 40 | raylib::Font("resources/fonts/jupiter_crash.png") |
| 41 | }; |
| 42 | |
| 43 | std::array<std::string, MAX_FONTS> messages = { |
| 44 | "ALAGARD FONT designed by Hewett Tsoi", |
| 45 | "PIXELPLAY FONT designed by Aleksander Shevchuk", |
| 46 | "MECHA FONT designed by Captain Falcon", |
| 47 | "SETBACK FONT designed by Brian Kent (AEnigma)", |
| 48 | "ROMULUS FONT designed by Hewett Tsoi", |
| 49 | "PIXANTIQUA FONT designed by Gerhard Grossmann", |
| 50 | "ALPHA_BETA FONT designed by Brian Kent (AEnigma)", |
| 51 | "JUPITER_CRASH FONT designed by Brian Kent (AEnigma)" |
| 52 | }; |
| 53 | |
| 54 | std::array<int, MAX_FONTS> spacings = { 2, 4, 8, 4, 3, 4, 4, 1 }; |
| 55 | |
| 56 | std::array<raylib::Vector2, MAX_FONTS> positions; |
| 57 | |
| 58 | for (int i = 0; i < fonts.size(); i++) |
| 59 | { |
| 60 | auto size = fonts[i].MeasureText(messages[i], fonts[i].baseSize * 2, spacings[i]); |
| 61 | positions[i].x = screenWidth/2 - size.x/2; |
| 62 | positions[i].y = 60 + fonts[i].baseSize + 45*i; |
| 63 | } |
| 64 | |
| 65 | // Small Y position corrections |
| 66 | positions[3].y += 8; |
| 67 | positions[4].y += 2; |
| 68 | positions[7].y -= 8; |
| 69 | |
| 70 | std::array<raylib::Color, MAX_FONTS> colors = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED }; |
| 71 | //-------------------------------------------------------------------------------------- |
| 72 | |
| 73 | // Main game loop |
| 74 | while (!window.ShouldClose()) { // Detect window close button or ESC key |
| 75 | // Update |
| 76 | //---------------------------------------------------------------------------------- |
| 77 | // Update your variables here |
| 78 | //---------------------------------------------------------------------------------- |
| 79 |
nothing calls this directly
no test coverage detected