diff options
| author | raysan5 <[email protected]> | 2017-02-05 02:59:39 +0100 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2017-02-05 02:59:39 +0100 |
| commit | 1a879ba08efe1877c26a76bfabd43f282d2b2a97 (patch) | |
| tree | 7870e105ee57aaab20ffd89f5708948960d34460 /src/raylib.h | |
| parent | a08117155da1a0a439239ad8801a58b85f528014 (diff) | |
| download | raylib-1a879ba08efe1877c26a76bfabd43f282d2b2a97.tar.gz raylib-1a879ba08efe1877c26a76bfabd43f282d2b2a97.zip | |
Refactor SpriteFont struct
Now it uses CharInfo data, this way, it's better aligned with the future
RRES file format data layout for sprite font characters.
Diffstat (limited to 'src/raylib.h')
| -rw-r--r-- | src/raylib.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/raylib.h b/src/raylib.h index 3c84ee72..f5b908db 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -370,15 +370,21 @@ typedef struct RenderTexture2D { Texture2D depth; // Depth buffer attachment texture } RenderTexture2D; +// SpriteFont character info +typedef struct CharInfo { + int value; // Character value (Unicode) + Rectangle rec; // Character rectangle in sprite font + int offsetX; // Character offset X when drawing + int offsetY; // Character offset Y when drawing + int advanceX; // Character advance position X +} CharInfo; + // SpriteFont type, includes texture and charSet array data typedef struct SpriteFont { Texture2D texture; // Font texture - int size; // Base size (default chars height) - int numChars; // Number of characters - int *charValues; // Characters values array - Rectangle *charRecs; // Characters rectangles within the texture - Vector2 *charOffsets; // Characters offsets (on drawing) - int *charAdvanceX; // Characters x advance (on drawing) + int baseSize; // Base size (default chars height) + int charsCount; // Number of characters + CharInfo *chars; // Characters info data } SpriteFont; // Camera type, defines a camera position/orientation in 3d space @@ -825,7 +831,7 @@ RLAPI void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle dest //------------------------------------------------------------------------------------ RLAPI SpriteFont GetDefaultFont(void); // Get the default SpriteFont RLAPI SpriteFont LoadSpriteFont(const char *fileName); // Load SpriteFont from file into GPU memory (VRAM) -RLAPI SpriteFont LoadSpriteFontTTF(const char *fileName, int fontSize, int numChars, int *fontChars); // Load SpriteFont from TTF font file with generation parameters +RLAPI SpriteFont LoadSpriteFontTTF(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load SpriteFont from TTF font file with generation parameters RLAPI void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory (VRAM) RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) |
