From b4d67499a73af36453b7588cbd0427112a1154b2 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 24 Jul 2019 15:05:14 +0200 Subject: BREAKING CHANGE: Read description Changes: - Font structure has been redesigned, CharInfo structure contained character rectangle within font texture, it has not much sense, considering that it was an information relative to the font atlas generated and not the character itself, so character rectangles have been moved out from CharInfo to Font. - CharInfo included a data parameters to contain character pixel data (usually grayscale), generated on TTF font generation. It was inconsistent with other fonts types, so, now CharInfo includes directly an Image of the glyph. - REDESIGNED: GenImageFontAtlas(), additional recs parameter added, loaded and filled inside the function to export atlas characters rectangles, instead of silently modify the input CharInfo data. - REVIEWED: ImageTextEx(), funtion retrieved the font atlas image from the GPU, that was slow and problematic in several platforms. Now it uses directly the CharInfo image. Support for unicode codepoints has also been added. - REDESIGNED: ImageDraw(), now it includes an additional parameter, the color tint, not only it could be useful for several situations but also function signature is more consistent with similar functions. - ADDED: ImageFromImage() to generate a new image from a piece of another image. - REVIEWED: GetNextCodepoint(), renamed parameters to be more clear. Also all examples and games that were affected by those changes have been reviewed. --- examples/text/text_font_sdf.c | 6 ++++-- examples/textures/textures_image_drawing.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/text/text_font_sdf.c b/examples/text/text_font_sdf.c index 41ce3b2a..86545e80 100644 --- a/examples/text/text_font_sdf.c +++ b/examples/text/text_font_sdf.c @@ -17,6 +17,8 @@ #define GLSL_VERSION 100 #endif +#include + int main(void) { // Initialization @@ -37,7 +39,7 @@ int main(void) // Parameters > font size: 16, no chars array provided (0), chars count: 95 (autogenerate chars array) fontDefault.chars = LoadFontData("resources/AnonymousPro-Bold.ttf", 16, 0, 95, FONT_DEFAULT); // Parameters > chars count: 95, font size: 16, chars padding in image: 4 px, pack method: 0 (default) - Image atlas = GenImageFontAtlas(fontDefault.chars, 95, 16, 4, 0); + Image atlas = GenImageFontAtlas(fontDefault.chars, &fontDefault.recs, 95, 16, 4, 0); fontDefault.texture = LoadTextureFromImage(atlas); UnloadImage(atlas); @@ -48,7 +50,7 @@ int main(void) // Parameters > font size: 16, no chars array provided (0), chars count: 0 (defaults to 95) fontSDF.chars = LoadFontData("resources/AnonymousPro-Bold.ttf", 16, 0, 0, FONT_SDF); // Parameters > chars count: 95, font size: 16, chars padding in image: 0 px, pack method: 1 (Skyline algorythm) - atlas = GenImageFontAtlas(fontSDF.chars, 95, 16, 0, 1); + atlas = GenImageFontAtlas(fontSDF.chars, &fontSDF.recs, 95, 16, 0, 1); fontSDF.texture = LoadTextureFromImage(atlas); UnloadImage(atlas); diff --git a/examples/textures/textures_image_drawing.c b/examples/textures/textures_image_drawing.c index f5c3c85d..02caf1f9 100644 --- a/examples/textures/textures_image_drawing.c +++ b/examples/textures/textures_image_drawing.c @@ -32,7 +32,7 @@ int main(void) Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM) // Draw one image over the other with a scaling of 1.5f - ImageDraw(&parrots, cat, (Rectangle){ 0, 0, cat.width, cat.height }, (Rectangle){ 30, 40, cat.width*1.5f, cat.height*1.5f }); + ImageDraw(&parrots, cat, (Rectangle){ 0, 0, cat.width, cat.height }, (Rectangle){ 30, 40, cat.width*1.5f, cat.height*1.5f }, WHITE); ImageCrop(&parrots, (Rectangle){ 0, 50, parrots.width, parrots.height - 100 }); // Crop resulting image UnloadImage(cat); // Unload image from RAM -- cgit v1.2.3