summaryrefslogtreecommitdiffhomepage
path: root/examples/text
diff options
context:
space:
mode:
authorRay <[email protected]>2017-04-20 00:21:38 +0200
committerGitHub <[email protected]>2017-04-20 00:21:38 +0200
commitbc1bfe54d6df0b872b604870d3e55a9f9f4e19dd (patch)
treefa1fb6c1b03008d98c342970fa095d7cc84c2252 /examples/text
parent407746193d991190fa4dead94649abb2ed27d462 (diff)
parent35172430c6b5929e8f6781e0d92b4bc1f9fcc2a2 (diff)
downloadraylib-bc1bfe54d6df0b872b604870d3e55a9f9f4e19dd.tar.gz
raylib-bc1bfe54d6df0b872b604870d3e55a9f9f4e19dd.zip
Merge pull request #262 from raysan5/develop
Integrate develop branch
Diffstat (limited to 'examples/text')
-rw-r--r--examples/text/resources/KAISG.ttf (renamed from examples/text/resources/fonts/KAISG.ttf)bin79912 -> 79912 bytes
-rw-r--r--examples/text/resources/bmfont.fnt (renamed from examples/text/resources/fonts/bmfont.fnt)0
-rw-r--r--examples/text/resources/bmfont.png (renamed from examples/text/resources/fonts/bmfont.png)bin14471 -> 14471 bytes
-rw-r--r--examples/text/resources/custom_alagard.png (renamed from examples/text/resources/fonts/custom_alagard.png)bin37935 -> 37935 bytes
-rw-r--r--examples/text/resources/custom_jupiter_crash.png (renamed from examples/text/resources/fonts/custom_jupiter_crash.png)bin23596 -> 23596 bytes
-rw-r--r--examples/text/resources/custom_mecha.png (renamed from examples/text/resources/fonts/custom_mecha.png)bin26597 -> 26597 bytes
-rw-r--r--examples/text/resources/fonts/alagard.pngbin0 -> 4424 bytes
-rw-r--r--examples/text/resources/fonts/alagard.rbmfbin2159 -> 0 bytes
-rw-r--r--examples/text/resources/fonts/alpha_beta.pngbin0 -> 2442 bytes
-rw-r--r--examples/text/resources/fonts/alpha_beta.rbmfbin2160 -> 0 bytes
-rw-r--r--examples/text/resources/fonts/jupiter_crash.pngbin0 -> 3478 bytes
-rw-r--r--examples/text/resources/fonts/jupiter_crash.rbmfbin2160 -> 0 bytes
-rw-r--r--examples/text/resources/fonts/mecha.pngbin0 -> 2399 bytes
-rw-r--r--examples/text/resources/fonts/mecha.rbmfbin2160 -> 0 bytes
-rw-r--r--examples/text/resources/fonts/pixantiqua.pngbin0 -> 3003 bytes
-rw-r--r--examples/text/resources/fonts/pixantiqua.rbmfbin2160 -> 0 bytes
-rw-r--r--examples/text/resources/fonts/pixelplay.pngbin0 -> 2912 bytes
-rw-r--r--examples/text/resources/fonts/pixelplay.rbmfbin2160 -> 0 bytes
-rw-r--r--examples/text/resources/fonts/romulus.pngbin0 -> 2932 bytes
-rw-r--r--examples/text/resources/fonts/romulus.rbmfbin2160 -> 0 bytes
-rw-r--r--examples/text/resources/fonts/setback.pngbin0 -> 2539 bytes
-rw-r--r--examples/text/resources/fonts/setback.rbmfbin2160 -> 0 bytes
-rw-r--r--examples/text/resources/pixantiqua.fnt (renamed from examples/text/resources/fonts/pixantiqua.fnt)0
-rw-r--r--examples/text/resources/pixantiqua.ttf (renamed from examples/text/resources/fonts/pixantiqua.ttf)bin35408 -> 35408 bytes
-rw-r--r--examples/text/resources/pixantiqua_0.png (renamed from examples/text/resources/fonts/pixantiqua_0.png)bin4531 -> 4531 bytes
-rw-r--r--examples/text/text_bmfont_ttf.c4
-rw-r--r--examples/text/text_bmfont_unordered.c2
-rw-r--r--examples/text/text_font_select.c158
-rw-r--r--examples/text/text_font_select.pngbin16261 -> 0 bytes
-rw-r--r--examples/text/text_input_box.c116
-rw-r--r--examples/text/text_input_box.pngbin0 -> 15484 bytes
-rw-r--r--examples/text/text_raylib_fonts.c (renamed from examples/text/text_rbmf_fonts.c)54
-rw-r--r--examples/text/text_raylib_fonts.pngbin0 -> 20204 bytes
-rw-r--r--examples/text/text_rbmf_fonts.pngbin19458 -> 0 bytes
-rw-r--r--examples/text/text_sprite_fonts.c6
-rw-r--r--examples/text/text_ttf_loading.c2
36 files changed, 153 insertions, 189 deletions
diff --git a/examples/text/resources/fonts/KAISG.ttf b/examples/text/resources/KAISG.ttf
index 04478b25..04478b25 100644
--- a/examples/text/resources/fonts/KAISG.ttf
+++ b/examples/text/resources/KAISG.ttf
Binary files differ
diff --git a/examples/text/resources/fonts/bmfont.fnt b/examples/text/resources/bmfont.fnt
index 372c2c88..372c2c88 100644
--- a/examples/text/resources/fonts/bmfont.fnt
+++ b/examples/text/resources/bmfont.fnt
diff --git a/examples/text/resources/fonts/bmfont.png b/examples/text/resources/bmfont.png
index 9d621594..9d621594 100644
--- a/examples/text/resources/fonts/bmfont.png
+++ b/examples/text/resources/bmfont.png
Binary files differ
diff --git a/examples/text/resources/fonts/custom_alagard.png b/examples/text/resources/custom_alagard.png
index c3eb63b7..c3eb63b7 100644
--- a/examples/text/resources/fonts/custom_alagard.png
+++ b/examples/text/resources/custom_alagard.png
Binary files differ
diff --git a/examples/text/resources/fonts/custom_jupiter_crash.png b/examples/text/resources/custom_jupiter_crash.png
index 451b591f..451b591f 100644
--- a/examples/text/resources/fonts/custom_jupiter_crash.png
+++ b/examples/text/resources/custom_jupiter_crash.png
Binary files differ
diff --git a/examples/text/resources/fonts/custom_mecha.png b/examples/text/resources/custom_mecha.png
index 59caab2c..59caab2c 100644
--- a/examples/text/resources/fonts/custom_mecha.png
+++ b/examples/text/resources/custom_mecha.png
Binary files differ
diff --git a/examples/text/resources/fonts/alagard.png b/examples/text/resources/fonts/alagard.png
new file mode 100644
index 00000000..3ac4bf1c
--- /dev/null
+++ b/examples/text/resources/fonts/alagard.png
Binary files differ
diff --git a/examples/text/resources/fonts/alagard.rbmf b/examples/text/resources/fonts/alagard.rbmf
deleted file mode 100644
index 8c9b68d3..00000000
--- a/examples/text/resources/fonts/alagard.rbmf
+++ /dev/null
Binary files differ
diff --git a/examples/text/resources/fonts/alpha_beta.png b/examples/text/resources/fonts/alpha_beta.png
new file mode 100644
index 00000000..c362bfb1
--- /dev/null
+++ b/examples/text/resources/fonts/alpha_beta.png
Binary files differ
diff --git a/examples/text/resources/fonts/alpha_beta.rbmf b/examples/text/resources/fonts/alpha_beta.rbmf
deleted file mode 100644
index bdb2e752..00000000
--- a/examples/text/resources/fonts/alpha_beta.rbmf
+++ /dev/null
Binary files differ
diff --git a/examples/text/resources/fonts/jupiter_crash.png b/examples/text/resources/fonts/jupiter_crash.png
new file mode 100644
index 00000000..1f5172fb
--- /dev/null
+++ b/examples/text/resources/fonts/jupiter_crash.png
Binary files differ
diff --git a/examples/text/resources/fonts/jupiter_crash.rbmf b/examples/text/resources/fonts/jupiter_crash.rbmf
deleted file mode 100644
index d797e0d6..00000000
--- a/examples/text/resources/fonts/jupiter_crash.rbmf
+++ /dev/null
Binary files differ
diff --git a/examples/text/resources/fonts/mecha.png b/examples/text/resources/fonts/mecha.png
new file mode 100644
index 00000000..8022d18c
--- /dev/null
+++ b/examples/text/resources/fonts/mecha.png
Binary files differ
diff --git a/examples/text/resources/fonts/mecha.rbmf b/examples/text/resources/fonts/mecha.rbmf
deleted file mode 100644
index 0266a065..00000000
--- a/examples/text/resources/fonts/mecha.rbmf
+++ /dev/null
Binary files differ
diff --git a/examples/text/resources/fonts/pixantiqua.png b/examples/text/resources/fonts/pixantiqua.png
new file mode 100644
index 00000000..ce422e7e
--- /dev/null
+++ b/examples/text/resources/fonts/pixantiqua.png
Binary files differ
diff --git a/examples/text/resources/fonts/pixantiqua.rbmf b/examples/text/resources/fonts/pixantiqua.rbmf
deleted file mode 100644
index 04ef0e25..00000000
--- a/examples/text/resources/fonts/pixantiqua.rbmf
+++ /dev/null
Binary files differ
diff --git a/examples/text/resources/fonts/pixelplay.png b/examples/text/resources/fonts/pixelplay.png
new file mode 100644
index 00000000..bf8f8818
--- /dev/null
+++ b/examples/text/resources/fonts/pixelplay.png
Binary files differ
diff --git a/examples/text/resources/fonts/pixelplay.rbmf b/examples/text/resources/fonts/pixelplay.rbmf
deleted file mode 100644
index 31d14038..00000000
--- a/examples/text/resources/fonts/pixelplay.rbmf
+++ /dev/null
Binary files differ
diff --git a/examples/text/resources/fonts/romulus.png b/examples/text/resources/fonts/romulus.png
new file mode 100644
index 00000000..46ccc327
--- /dev/null
+++ b/examples/text/resources/fonts/romulus.png
Binary files differ
diff --git a/examples/text/resources/fonts/romulus.rbmf b/examples/text/resources/fonts/romulus.rbmf
deleted file mode 100644
index be9da01a..00000000
--- a/examples/text/resources/fonts/romulus.rbmf
+++ /dev/null
Binary files differ
diff --git a/examples/text/resources/fonts/setback.png b/examples/text/resources/fonts/setback.png
new file mode 100644
index 00000000..086f3e27
--- /dev/null
+++ b/examples/text/resources/fonts/setback.png
Binary files differ
diff --git a/examples/text/resources/fonts/setback.rbmf b/examples/text/resources/fonts/setback.rbmf
deleted file mode 100644
index 09572215..00000000
--- a/examples/text/resources/fonts/setback.rbmf
+++ /dev/null
Binary files differ
diff --git a/examples/text/resources/fonts/pixantiqua.fnt b/examples/text/resources/pixantiqua.fnt
index 971b9b0b..971b9b0b 100644
--- a/examples/text/resources/fonts/pixantiqua.fnt
+++ b/examples/text/resources/pixantiqua.fnt
diff --git a/examples/text/resources/fonts/pixantiqua.ttf b/examples/text/resources/pixantiqua.ttf
index e012875d..e012875d 100644
--- a/examples/text/resources/fonts/pixantiqua.ttf
+++ b/examples/text/resources/pixantiqua.ttf
Binary files differ
diff --git a/examples/text/resources/fonts/pixantiqua_0.png b/examples/text/resources/pixantiqua_0.png
index 2aa2870f..2aa2870f 100644
--- a/examples/text/resources/fonts/pixantiqua_0.png
+++ b/examples/text/resources/pixantiqua_0.png
Binary files differ
diff --git a/examples/text/text_bmfont_ttf.c b/examples/text/text_bmfont_ttf.c
index 4d060915..0778fd11 100644
--- a/examples/text/text_bmfont_ttf.c
+++ b/examples/text/text_bmfont_ttf.c
@@ -24,8 +24,8 @@ int main()
const char msgTtf[64] = "THIS SPRITE FONT has been GENERATED from a TTF";
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
- SpriteFont fontBm = LoadSpriteFont("resources/fonts/bmfont.fnt"); // BMFont (AngelCode)
- SpriteFont fontTtf = LoadSpriteFont("resources/fonts/pixantiqua.ttf"); // TTF font
+ SpriteFont fontBm = LoadSpriteFont("resources/bmfont.fnt"); // BMFont (AngelCode)
+ SpriteFont fontTtf = LoadSpriteFont("resources/pixantiqua.ttf"); // TTF font
Vector2 fontPosition;
diff --git a/examples/text/text_bmfont_unordered.c b/examples/text/text_bmfont_unordered.c
index 6fec3256..01561bec 100644
--- a/examples/text/text_bmfont_unordered.c
+++ b/examples/text/text_bmfont_unordered.c
@@ -25,7 +25,7 @@ int main()
const char msg[256] = "ASCII extended characters:\n¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆ\nÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæ\nçèéêëìíîïðñòóôõö÷øùúûüýþÿ";
// NOTE: Loaded font has an unordered list of characters (chars in the range 32..255)
- SpriteFont font = LoadSpriteFont("resources/fonts/pixantiqua.fnt"); // BMFont (AngelCode)
+ SpriteFont font = LoadSpriteFont("resources/pixantiqua.fnt"); // BMFont (AngelCode)
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
diff --git a/examples/text/text_font_select.c b/examples/text/text_font_select.c
deleted file mode 100644
index 5891bef7..00000000
--- a/examples/text/text_font_select.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************************
-*
-* raylib [text] example - Font selector
-*
-* This example has been created using raylib 1.3 (www.raylib.com)
-* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
-*
-* Copyright (c) 2015 Ramon Santamaria (@raysan5)
-*
-********************************************************************************************/
-
-#include "raylib.h"
-
-int main()
-{
- // Initialization
- //--------------------------------------------------------------------------------------
- int screenWidth = 800;
- int screenHeight = 450;
-
- InitWindow(screenWidth, screenHeight, "raylib [text] example - font selector");
-
- // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
- SpriteFont fonts[8]; // SpriteFont array
-
- fonts[0] = LoadSpriteFont("resources/fonts/alagard.rbmf"); // SpriteFont loading
- fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // SpriteFont loading
- fonts[2] = LoadSpriteFont("resources/fonts/mecha.rbmf"); // SpriteFont loading
- fonts[3] = LoadSpriteFont("resources/fonts/setback.rbmf"); // SpriteFont loading
- fonts[4] = LoadSpriteFont("resources/fonts/romulus.rbmf"); // SpriteFont loading
- fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // SpriteFont loading
- fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // SpriteFont loading
- fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // SpriteFont loading
-
- int currentFont = 0; // Selected font
-
- Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED };
-
- const char fontNames[8][20] = { "[0] Alagard", "[1] PixelPlay", "[2] MECHA", "[3] Setback",
- "[4] Romulus", "[5] PixAntiqua", "[6] Alpha Beta", "[7] Jupiter Crash" };
-
- const char text[50] = "THIS is THE FONT you SELECTED!"; // Main text
-
- Vector2 textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].baseSize*3, 1);
-
- Vector2 mousePoint;
-
- Color btnNextOutColor = DARKBLUE; // Button color (outside line)
- Color btnNextInColor = SKYBLUE; // Button color (inside)
-
- int framesCounter = 0; // Useful to count frames button is 'active' = clicked
-
- int positionY = 180; // Text selector and button Y position
-
- Rectangle btnNextRec = { 673, positionY, 109, 44 }; // Button rectangle (useful for collision)
-
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
- //--------------------------------------------------------------------------------------
-
- // Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
- {
- // Update
- //----------------------------------------------------------------------------------
-
- // Keyboard-based font selection (easy)
- if (IsKeyPressed(KEY_RIGHT))
- {
- if (currentFont < 7) currentFont++;
- }
-
- if (IsKeyPressed(KEY_LEFT))
- {
- if (currentFont > 0) currentFont--;
- }
-
- if (IsKeyPressed('0')) currentFont = 0;
- else if (IsKeyPressed('1')) currentFont = 1;
- else if (IsKeyPressed('2')) currentFont = 2;
- else if (IsKeyPressed('3')) currentFont = 3;
- else if (IsKeyPressed('4')) currentFont = 4;
- else if (IsKeyPressed('5')) currentFont = 5;
- else if (IsKeyPressed('6')) currentFont = 6;
- else if (IsKeyPressed('7')) currentFont = 7;
-
- // Mouse-based font selection (NEXT button logic)
- mousePoint = GetMousePosition();
-
- if (CheckCollisionPointRec(mousePoint, btnNextRec))
- {
- // Mouse hover button logic
- if (framesCounter == 0)
- {
- btnNextOutColor = DARKPURPLE;
- btnNextInColor = PURPLE;
- }
-
- if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
- {
- framesCounter = 20; // Frames button is 'active'
- btnNextOutColor = MAROON;
- btnNextInColor = RED;
- }
- }
- else
- {
- // Mouse not hover button
- btnNextOutColor = DARKBLUE;
- btnNextInColor = SKYBLUE;
- }
-
- if (framesCounter > 0) framesCounter--;
-
- if (framesCounter == 1) // We change font on frame 1
- {
- currentFont++;
- if (currentFont > 7) currentFont = 0;
- }
-
- // Text measurement for better positioning on screen
- textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].baseSize*3, 1);
- //----------------------------------------------------------------------------------
-
- // Draw
- //----------------------------------------------------------------------------------
- BeginDrawing();
-
- ClearBackground(RAYWHITE);
-
- DrawText("font selector - use arroys, button or numbers", 160, 80, 20, DARKGRAY);
- DrawLine(120, 120, 680, 120, DARKGRAY);
-
- DrawRectangle(18, positionY, 644, 44, DARKGRAY);
- DrawRectangle(20, positionY + 2, 640, 40, LIGHTGRAY);
- DrawText(fontNames[currentFont], 30, positionY + 13, 20, BLACK);
- DrawText("< >", 610, positionY + 8, 30, BLACK);
-
- DrawRectangleRec(btnNextRec, btnNextOutColor);
- DrawRectangle(675, positionY + 2, 105, 40, btnNextInColor);
- DrawText("NEXT", 700, positionY + 13, 20, btnNextOutColor);
-
- DrawTextEx(fonts[currentFont], text, (Vector2){ screenWidth/2 - textSize.x/2,
- 260 + (70 - textSize.y)/2 }, fonts[currentFont].baseSize*3,
- 1, colors[currentFont]);
-
- EndDrawing();
- //----------------------------------------------------------------------------------
- }
-
- // De-Initialization
- //--------------------------------------------------------------------------------------
- for (int i = 0; i < 8; i++) UnloadSpriteFont(fonts[i]); // SpriteFont(s) unloading
-
- CloseWindow(); // Close window and OpenGL context
- //--------------------------------------------------------------------------------------
-
- return 0;
-} \ No newline at end of file
diff --git a/examples/text/text_font_select.png b/examples/text/text_font_select.png
deleted file mode 100644
index 65040df6..00000000
--- a/examples/text/text_font_select.png
+++ /dev/null
Binary files differ
diff --git a/examples/text/text_input_box.c b/examples/text/text_input_box.c
new file mode 100644
index 00000000..54eebf40
--- /dev/null
+++ b/examples/text/text_input_box.c
@@ -0,0 +1,116 @@
+/*******************************************************************************************
+*
+* raylib [text] example - Input Box
+*
+* This example has been created using raylib 1.7 (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* Copyright (c) 2017 Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#define MAX_INPUT_CHARS 9
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [text] example - input box");
+
+ char name[MAX_INPUT_CHARS + 1] = "\0"; // NOTE: One extra space required for line ending char '\0'
+ int letterCount = 0;
+
+ Rectangle textBox = { screenWidth/2 - 100, 180, 225, 50 };
+ bool mouseOnText = false;
+
+ int framesCounter = 0;
+
+ SetTargetFPS(60);
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ if (CheckCollisionPointRec(GetMousePosition(), textBox)) mouseOnText = true;
+ else mouseOnText = false;
+
+ if (mouseOnText)
+ {
+ int key = GetKeyPressed();
+
+ // NOTE: Only allow keys in range [32..125]
+ if ((key >= 32) && (key <= 125) && (letterCount < MAX_INPUT_CHARS))
+ {
+ name[letterCount] = (char)key;
+ letterCount++;
+ }
+
+ if (key == KEY_BACKSPACE)
+ {
+ letterCount--;
+ name[letterCount] = '\0';
+
+ if (letterCount < 0) letterCount = 0;
+ }
+ }
+
+ if (mouseOnText) framesCounter++;
+ else framesCounter = 0;
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ DrawText("PLACE MOUSE OVER INPUT BOX!", 240, 140, 20, GRAY);
+
+ DrawRectangleRec(textBox, LIGHTGRAY);
+ if (mouseOnText) DrawRectangleLines(textBox.x, textBox.y, textBox.width, textBox.height, RED);
+ else DrawRectangleLines(textBox.x, textBox.y, textBox.width, textBox.height, DARKGRAY);
+
+ DrawText(name, textBox.x + 5, textBox.y + 8, 40, MAROON);
+
+ DrawText(FormatText("INPUT CHARS: %i/%i", letterCount, MAX_INPUT_CHARS), 315, 250, 20, DARKGRAY);
+
+ if (mouseOnText)
+ {
+ if (letterCount < MAX_INPUT_CHARS)
+ {
+ // Draw blinking underscore char
+ if (((framesCounter/20)%2) == 0) DrawText("_", textBox.x + 8 + MeasureText(name, 40), textBox.y + 12, 40, MAROON);
+ }
+ else DrawText("Press BACKSPACE to delete chars...", 230, 300, 20, GRAY);
+ }
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}
+
+// Check if any key is pressed
+// NOTE: We limit keys check to keys between 32 (KEY_SPACE) and 126
+bool IsAnyKeyPressed()
+{
+ bool keyPressed = false;
+ int key = GetKeyPressed();
+
+ if ((key >= 32) && (key <= 126)) keyPressed = true;
+
+ return keyPressed;
+} \ No newline at end of file
diff --git a/examples/text/text_input_box.png b/examples/text/text_input_box.png
new file mode 100644
index 00000000..42f9d73a
--- /dev/null
+++ b/examples/text/text_input_box.png
Binary files differ
diff --git a/examples/text/text_rbmf_fonts.c b/examples/text/text_raylib_fonts.c
index cd5da1fe..6d8ef2b6 100644
--- a/examples/text/text_rbmf_fonts.c
+++ b/examples/text/text_raylib_fonts.c
@@ -1,19 +1,21 @@
/*******************************************************************************************
*
-* raylib [text] example - raylib bitmap font (rbmf) loading and usage
+* raylib [text] example - raylib font loading and usage
*
* NOTE: raylib is distributed with some free to use fonts (even for commercial pourposes!)
* To view details and credits for those fonts, check raylib license file
*
-* This example has been created using raylib 1.3 (www.raylib.com)
+* This example has been created using raylib 1.7 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
-* Copyright (c) 2015 Ramon Santamaria (@raysan5)
+* Copyright (c) 2017 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
+#define MAX_FONTS 8
+
int main()
{
// Initialization
@@ -21,21 +23,21 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
- InitWindow(screenWidth, screenHeight, "raylib [text] example - rBMF fonts");
+ InitWindow(screenWidth, screenHeight, "raylib [text] example - raylib fonts");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
- SpriteFont fonts[8];
+ SpriteFont fonts[MAX_FONTS];
- fonts[0] = LoadSpriteFont("resources/fonts/alagard.rbmf"); // rBMF font loading
- fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // rBMF font loading
- fonts[2] = LoadSpriteFont("resources/fonts/mecha.rbmf"); // rBMF font loading
- fonts[3] = LoadSpriteFont("resources/fonts/setback.rbmf"); // rBMF font loading
- fonts[4] = LoadSpriteFont("resources/fonts/romulus.rbmf"); // rBMF font loading
- fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // rBMF font loading
- fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // rBMF font loading
- fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // rBMF font loading
+ fonts[0] = LoadSpriteFont("resources/fonts/alagard.png");
+ fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.png");
+ fonts[2] = LoadSpriteFont("resources/fonts/mecha.png");
+ fonts[3] = LoadSpriteFont("resources/fonts/setback.png");
+ fonts[4] = LoadSpriteFont("resources/fonts/romulus.png");
+ fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.png");
+ fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.png");
+ fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.png");
- const char *messages[8] = { "ALAGARD FONT designed by Hewett Tsoi",
+ const char *messages[MAX_FONTS] = { "ALAGARD FONT designed by Hewett Tsoi",
"PIXELPLAY FONT designed by Aleksander Shevchuk",
"MECHA FONT designed by Captain Falcon",
"SETBACK FONT designed by Brian Kent (AEnigma)",
@@ -44,17 +46,22 @@ int main()
"ALPHA_BETA FONT designed by Brian Kent (AEnigma)",
"JUPITER_CRASH FONT designed by Brian Kent (AEnigma)" };
- const int spacings[8] = { 2, 4, 8, 4, 3, 4, 4, 1 };
+ const int spacings[MAX_FONTS] = { 2, 4, 8, 4, 3, 4, 4, 1 };
- Vector2 positions[8];
+ Vector2 positions[MAX_FONTS];
- for (int i = 0; i < 8; i++)
+ for (int i = 0; i < MAX_FONTS; i++)
{
positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].baseSize*2, spacings[i]).x/2;
- positions[i].y = 60 + fonts[i].baseSize + 50*i;
+ positions[i].y = 60 + fonts[i].baseSize + 45*i;
}
- Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD };
+ // Small Y position corrections
+ positions[3].y += 8;
+ positions[4].y += 2;
+ positions[7].y -= 8;
+
+ Color colors[MAX_FONTS] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED };
//--------------------------------------------------------------------------------------
// Main game loop
@@ -74,7 +81,7 @@ int main()
DrawText("free fonts included with raylib", 250, 20, 20, DARKGRAY);
DrawLine(220, 50, 590, 50, DARKGRAY);
- for (int i = 0; i < 8; i++)
+ for (int i = 0; i < MAX_FONTS; i++)
{
DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].baseSize*2, spacings[i], colors[i]);
}
@@ -85,10 +92,9 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
- for (int i = 0; i < 8; i++)
- {
- UnloadSpriteFont(fonts[i]); // SpriteFont unloading
- }
+
+ // SpriteFonts unloading
+ for (int i = 0; i < MAX_FONTS; i++) UnloadSpriteFont(fonts[i]);
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
diff --git a/examples/text/text_raylib_fonts.png b/examples/text/text_raylib_fonts.png
new file mode 100644
index 00000000..8f428a67
--- /dev/null
+++ b/examples/text/text_raylib_fonts.png
Binary files differ
diff --git a/examples/text/text_rbmf_fonts.png b/examples/text/text_rbmf_fonts.png
deleted file mode 100644
index c047c503..00000000
--- a/examples/text/text_rbmf_fonts.png
+++ /dev/null
Binary files differ
diff --git a/examples/text/text_sprite_fonts.c b/examples/text/text_sprite_fonts.c
index bded266e..aefbfd1f 100644
--- a/examples/text/text_sprite_fonts.c
+++ b/examples/text/text_sprite_fonts.c
@@ -25,9 +25,9 @@ int main()
const char msg3[50] = "...and a THIRD one! GREAT! :D";
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
- SpriteFont font1 = LoadSpriteFont("resources/fonts/custom_mecha.png"); // SpriteFont loading
- SpriteFont font2 = LoadSpriteFont("resources/fonts/custom_alagard.png"); // SpriteFont loading
- SpriteFont font3 = LoadSpriteFont("resources/fonts/custom_jupiter_crash.png"); // SpriteFont loading
+ SpriteFont font1 = LoadSpriteFont("resources/custom_mecha.png"); // SpriteFont loading
+ SpriteFont font2 = LoadSpriteFont("resources/custom_alagard.png"); // SpriteFont loading
+ SpriteFont font3 = LoadSpriteFont("resources/custom_jupiter_crash.png"); // SpriteFont loading
Vector2 fontPosition1, fontPosition2, fontPosition3;
diff --git a/examples/text/text_ttf_loading.c b/examples/text/text_ttf_loading.c
index 4aa0bef4..4e490399 100644
--- a/examples/text/text_ttf_loading.c
+++ b/examples/text/text_ttf_loading.c
@@ -25,7 +25,7 @@ int main()
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
// TTF SpriteFont loading with custom generation parameters
- SpriteFont font = LoadSpriteFontTTF("resources/fonts/KAISG.ttf", 96, 0, 0);
+ SpriteFont font = LoadSpriteFontTTF("resources/KAISG.ttf", 96, 0, 0);
// Generate mipmap levels to use trilinear filtering
// NOTE: On 2D drawing it won't be noticeable, it looks like FILTER_BILINEAR