REXM: RENAME: example: text_raylib_fonts -> text_sprite_fonts
This commit is contained in:
parent
2cb387b50a
commit
cadd28e5a0
6 changed files with 574 additions and 574 deletions
|
|
@ -596,7 +596,7 @@ TEXT = \
|
|||
text/text_font_spritefont \
|
||||
text/text_format_text \
|
||||
text/text_input_box \
|
||||
text/text_raylib_fonts \
|
||||
text/text_sprite_fonts \
|
||||
text/text_rectangle_bounds \
|
||||
text/text_unicode_emojis \
|
||||
text/text_unicode_ranges \
|
||||
|
|
|
|||
|
|
@ -596,7 +596,7 @@ TEXT = \
|
|||
text/text_font_spritefont \
|
||||
text/text_format_text \
|
||||
text/text_input_box \
|
||||
text/text_raylib_fonts \
|
||||
text/text_sprite_fonts \
|
||||
text/text_rectangle_bounds \
|
||||
text/text_unicode_emojis \
|
||||
text/text_unicode_ranges \
|
||||
|
|
@ -998,7 +998,7 @@ text/text_format_text: text/text_format_text.c
|
|||
text/text_input_box: text/text_input_box.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
|
||||
text/text_raylib_fonts: text/text_raylib_fonts.c
|
||||
text/text_sprite_fonts: text/text_sprite_fonts.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file text/resources/sprite_fonts/alagard.png@resources/sprite_fonts/alagard.png \
|
||||
--preload-file text/resources/sprite_fonts/pixelplay.png@resources/sprite_fonts/pixelplay.png \
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ Examples using raylib text functionality, including sprite fonts loading/generat
|
|||
|
||||
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
||||
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
||||
| [text_raylib_fonts](text/text_raylib_fonts.c) | <img src="text/text_raylib_fonts.png" alt="text_raylib_fonts" width="80"> | ⭐☆☆☆ | 1.7 | 3.7 | [Ramon Santamaria](https://github.com/raysan5) |
|
||||
| [text_sprite_fonts](text/text_sprite_fonts.c) | <img src="text/text_sprite_fonts.png" alt="text_sprite_fonts" width="80"> | ⭐☆☆☆ | 1.7 | 3.7 | [Ramon Santamaria](https://github.com/raysan5) |
|
||||
| [text_font_spritefont](text/text_font_spritefont.c) | <img src="text/text_font_spritefont.png" alt="text_font_spritefont" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
||||
| [text_font_filters](text/text_font_filters.c) | <img src="text/text_font_filters.png" alt="text_font_filters" width="80"> | ⭐⭐☆☆ | 1.3 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
|
||||
| [text_font_loading](text/text_font_loading.c) | <img src="text/text_font_loading.png" alt="text_font_loading" width="80"> | ⭐☆☆☆ | 1.4 | 3.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ textures;textures_image_kernel;⭐️⭐️⭐️⭐️;1.3;1.3;"Karim Salem";@k
|
|||
textures;textures_image_channel;⭐️⭐️☆☆;5.1-dev;5.1-dev;"Bruno Cabral";@brccabral
|
||||
textures;textures_image_rotate;⭐️⭐️☆☆;1.0;1.0;"Ramon Santamaria";@raysan5
|
||||
textures;textures_textured_curve;⭐️⭐️⭐️☆;4.5;4.5;"Jeffery Myers";@JeffM2501
|
||||
text;text_raylib_fonts;⭐️☆☆☆;1.7;3.7;"Ramon Santamaria";@raysan5
|
||||
text;text_sprite_fonts;⭐️☆☆☆;1.7;3.7;"Ramon Santamaria";@raysan5
|
||||
text;text_font_spritefont;⭐️☆☆☆;1.0;1.0;"Ramon Santamaria";@raysan5
|
||||
text;text_font_filters;⭐️⭐️☆☆;1.3;4.2;"Ramon Santamaria";@raysan5
|
||||
text;text_font_loading;⭐️☆☆☆;1.4;3.0;"Ramon Santamaria";@raysan5
|
||||
|
|
|
|||
112
examples/text/text_sprite_fonts.c
Normal file
112
examples/text/text_sprite_fonts.c
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [text] example - sprite fonts
|
||||
*
|
||||
* Example complexity rating: [★☆☆☆] 1/4
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Example originally created with raylib 1.7, last time updated with raylib 3.7
|
||||
*
|
||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software
|
||||
*
|
||||
* Copyright (c) 2017-2025 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define MAX_FONTS 8
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [text] example - sprite fonts");
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
Font fonts[MAX_FONTS] = { 0 };
|
||||
|
||||
fonts[0] = LoadFont("resources/sprite_fonts/alagard.png");
|
||||
fonts[1] = LoadFont("resources/sprite_fonts/pixelplay.png");
|
||||
fonts[2] = LoadFont("resources/sprite_fonts/mecha.png");
|
||||
fonts[3] = LoadFont("resources/sprite_fonts/setback.png");
|
||||
fonts[4] = LoadFont("resources/sprite_fonts/romulus.png");
|
||||
fonts[5] = LoadFont("resources/sprite_fonts/pixantiqua.png");
|
||||
fonts[6] = LoadFont("resources/sprite_fonts/alpha_beta.png");
|
||||
fonts[7] = LoadFont("resources/sprite_fonts/jupiter_crash.png");
|
||||
|
||||
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)",
|
||||
"ROMULUS FONT designed by Hewett Tsoi",
|
||||
"PIXANTIQUA FONT designed by Gerhard Grossmann",
|
||||
"ALPHA_BETA FONT designed by Brian Kent (AEnigma)",
|
||||
"JUPITER_CRASH FONT designed by Brian Kent (AEnigma)" };
|
||||
|
||||
const int spacings[MAX_FONTS] = { 2, 4, 8, 4, 3, 4, 4, 1 };
|
||||
|
||||
Vector2 positions[MAX_FONTS] = { 0 };
|
||||
|
||||
for (int i = 0; i < MAX_FONTS; i++)
|
||||
{
|
||||
positions[i].x = screenWidth/2.0f - MeasureTextEx(fonts[i], messages[i], fonts[i].baseSize*2.0f, (float)spacings[i]).x/2.0f;
|
||||
positions[i].y = 60.0f + fonts[i].baseSize + 45.0f*i;
|
||||
}
|
||||
|
||||
// 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 };
|
||||
|
||||
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
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText("free sprite fonts included with raylib", 220, 20, 20, DARKGRAY);
|
||||
DrawLine(220, 50, 600, 50, DARKGRAY);
|
||||
|
||||
for (int i = 0; i < MAX_FONTS; i++)
|
||||
{
|
||||
DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].baseSize*2.0f, (float)spacings[i], colors[i]);
|
||||
}
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Fonts unloading
|
||||
for (int i = 0; i < MAX_FONTS; i++) UnloadFont(fonts[i]);
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
examples/text/text_sprite_fonts.png
Normal file
BIN
examples/text/text_sprite_fonts.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
Loading…
Reference in a new issue