Wise&mystical  1.0
Project about Europe
Loading...
Searching...
No Matches
rtext.c File Reference
#include "raylib.h"
#include "config.h"
#include "utils.h"
#include "rlgl.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#include "external/stb_rect_pack.h"
#include "external/stb_truetype.h"
+ Include dependency graph for rtext.c:

Go to the source code of this file.

Macros

#define STB_RECT_PACK_IMPLEMENTATION
 rtext - Basic functions to load fonts and draw text More...
 
#define STBTT_STATIC
 
#define STB_TRUETYPE_IMPLEMENTATION
 
#define MAX_TEXT_UNICODE_CHARS   512
 
#define BIT_CHECK(a, b)   ((a) & (1u << (b)))
 
#define FONT_TTF_DEFAULT_SIZE   32
 
#define FONT_TTF_DEFAULT_NUMCHARS   95
 
#define FONT_TTF_DEFAULT_FIRST_CHAR   32
 
#define FONT_TTF_DEFAULT_CHARS_PADDING   4
 
#define MAX_GLYPHS_FROM_IMAGE   256
 
#define COLOR_EQUAL(col1, col2)   ((col1.r == col2.r) && (col1.g == col2.g) && (col1.b == col2.b) && (col1.a == col2.a))
 
#define FONT_SDF_CHAR_PADDING   4
 
#define FONT_SDF_ON_EDGE_VALUE   128
 
#define FONT_SDF_PIXEL_DIST_SCALE   64.0f
 
#define FONT_BITMAP_ALPHA_THRESHOLD   80
 
#define TEXT_BYTES_PER_LINE   20
 
#define MAX_FONT_DATA_SIZE   1024*1024
 
#define SUPPORT_COMPRESSED_FONT_ATLAS
 
#define GLYPH_NOTFOUND_CHAR_FALLBACK   63
 
#define SUPPORT_UNORDERED_CHARSET
 
#define MAX_TEXTFORMAT_BUFFERS   4
 
#define MAX_BUFFER_SIZE   256
 

Functions

void LoadFontDefault (void)
 
void UnloadFontDefault (void)
 
Font GetFontDefault ()
 
Font LoadFont (const char *fileName)
 
Font LoadFontEx (const char *fileName, int fontSize, int *fontChars, int glyphCount)
 
Font LoadFontFromImage (Image image, Color key, int firstChar)
 
Font LoadFontFromMemory (const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount)
 
GlyphInfoLoadFontData (const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount, int type)
 
Image GenImageFontAtlas (const GlyphInfo *chars, Rectangle **charRecs, int glyphCount, int fontSize, int padding, int packMethod)
 
void UnloadFontData (GlyphInfo *glyphs, int glyphCount)
 
void UnloadFont (Font font)
 
bool ExportFontAsCode (Font font, const char *fileName)
 
void DrawFPS (int posX, int posY)
 
void DrawText (const char *text, int posX, int posY, int fontSize, Color color)
 
void DrawTextEx (Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
 
void DrawTextPro (Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint)
 
void DrawTextCodepoint (Font font, int codepoint, Vector2 position, float fontSize, Color tint)
 
void DrawTextCodepoints (Font font, const int *codepoints, int count, Vector2 position, float fontSize, float spacing, Color tint)
 
int MeasureText (const char *text, int fontSize)
 
Vector2 MeasureTextEx (Font font, const char *text, float fontSize, float spacing)
 
int GetGlyphIndex (Font font, int codepoint)
 
GlyphInfo GetGlyphInfo (Font font, int codepoint)
 
Rectangle GetGlyphAtlasRec (Font font, int codepoint)
 
unsigned int TextLength (const char *text)
 
const char * TextFormat (const char *text,...)
 
int TextToInteger (const char *text)
 
int TextCopy (char *dst, const char *src)
 
bool TextIsEqual (const char *text1, const char *text2)
 
const char * TextSubtext (const char *text, int position, int length)
 
char * TextReplace (char *text, const char *replace, const char *by)
 
char * TextInsert (const char *text, const char *insert, int position)
 
const char * TextJoin (const char **textList, int count, const char *delimiter)
 
const char ** TextSplit (const char *text, char delimiter, int *count)
 
void TextAppend (char *text, const char *append, int *position)
 
int TextFindIndex (const char *text, const char *find)
 
const char * TextToUpper (const char *text)
 
const char * TextToLower (const char *text)
 
const char * TextToPascal (const char *text)
 
char * TextCodepointsToUTF8 (const int *codepoints, int length)
 
RLAPI const char * CodepointToUTF8 (int codepoint, int *byteSize)
 
int * LoadCodepoints (const char *text, int *count)
 
void UnloadCodepoints (int *codepoints)
 
int GetCodepointCount (const char *text)
 
int GetCodepoint (const char *text, int *bytesProcessed)
 

Macro Definition Documentation

◆ BIT_CHECK

#define BIT_CHECK (   a,
 
)    ((a) & (1u << (b)))

◆ COLOR_EQUAL

#define COLOR_EQUAL (   col1,
  col2 
)    ((col1.r == col2.r) && (col1.g == col2.g) && (col1.b == col2.b) && (col1.a == col2.a))

◆ FONT_BITMAP_ALPHA_THRESHOLD

#define FONT_BITMAP_ALPHA_THRESHOLD   80

◆ FONT_SDF_CHAR_PADDING

#define FONT_SDF_CHAR_PADDING   4

◆ FONT_SDF_ON_EDGE_VALUE

#define FONT_SDF_ON_EDGE_VALUE   128

◆ FONT_SDF_PIXEL_DIST_SCALE

#define FONT_SDF_PIXEL_DIST_SCALE   64.0f

◆ FONT_TTF_DEFAULT_CHARS_PADDING

#define FONT_TTF_DEFAULT_CHARS_PADDING   4

◆ FONT_TTF_DEFAULT_FIRST_CHAR

#define FONT_TTF_DEFAULT_FIRST_CHAR   32

◆ FONT_TTF_DEFAULT_NUMCHARS

#define FONT_TTF_DEFAULT_NUMCHARS   95

◆ FONT_TTF_DEFAULT_SIZE

#define FONT_TTF_DEFAULT_SIZE   32

◆ GLYPH_NOTFOUND_CHAR_FALLBACK

#define GLYPH_NOTFOUND_CHAR_FALLBACK   63

◆ MAX_BUFFER_SIZE

#define MAX_BUFFER_SIZE   256

◆ MAX_FONT_DATA_SIZE

#define MAX_FONT_DATA_SIZE   1024*1024

◆ MAX_GLYPHS_FROM_IMAGE

#define MAX_GLYPHS_FROM_IMAGE   256

◆ MAX_TEXT_UNICODE_CHARS

#define MAX_TEXT_UNICODE_CHARS   512

Definition at line 87 of file rtext.c.

◆ MAX_TEXTFORMAT_BUFFERS

#define MAX_TEXTFORMAT_BUFFERS   4

◆ STB_RECT_PACK_IMPLEMENTATION

#define STB_RECT_PACK_IMPLEMENTATION

rtext - Basic functions to load fonts and draw text

CONFIGURATION:

#define SUPPORT_MODULE_RTEXT rtext module is included in the build

#define SUPPORT_FILEFORMAT_FNT #define SUPPORT_FILEFORMAT_TTF Selected desired fileformats to be supported for loading. Some of those formats are supported by default, to remove support, just comment unrequired #define in this module

#define SUPPORT_DEFAULT_FONT Load default raylib font on initialization to be used by DrawText() and MeasureText(). If no default font loaded, DrawTextEx() and MeasureTextEx() are required.

#define TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH TextSplit() function static buffer max size

#define MAX_TEXTSPLIT_COUNT TextSplit() function static substrings pointers array (pointing to static buffer)

DEPENDENCIES: stb_truetype - Load TTF file and rasterize characters data stb_rect_pack - Rectangles packing algorythms, required for font atlas generation

LICENSE: zlib/libpng

Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)

This software is provided "as-is", without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

Definition at line 71 of file rtext.c.

◆ STB_TRUETYPE_IMPLEMENTATION

#define STB_TRUETYPE_IMPLEMENTATION

Definition at line 75 of file rtext.c.

◆ STBTT_STATIC

#define STBTT_STATIC

Definition at line 74 of file rtext.c.

◆ SUPPORT_COMPRESSED_FONT_ATLAS

#define SUPPORT_COMPRESSED_FONT_ATLAS

◆ SUPPORT_UNORDERED_CHARSET

#define SUPPORT_UNORDERED_CHARSET

◆ TEXT_BYTES_PER_LINE

#define TEXT_BYTES_PER_LINE   20

Function Documentation

◆ CodepointToUTF8()

RLAPI const char * CodepointToUTF8 ( int  codepoint,
int *  byteSize 
)

Definition at line 1645 of file rtext.c.

+ Here is the caller graph for this function:

◆ DrawFPS()

void DrawFPS ( int  posX,
int  posY 
)

Definition at line 993 of file rtext.c.

+ Here is the call graph for this function:

◆ DrawText()

void DrawText ( const char *  text,
int  posX,
int  posY,
int  fontSize,
Color  color 
)

Definition at line 1007 of file rtext.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DrawTextCodepoint()

void DrawTextCodepoint ( Font  font,
int  codepoint,
Vector2  position,
float  fontSize,
Color  tint 
)

Definition at line 1083 of file rtext.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DrawTextCodepoints()

void DrawTextCodepoints ( Font  font,
const int *  codepoints,
int  count,
Vector2  position,
float  fontSize,
float  spacing,
Color  tint 
)

Definition at line 1107 of file rtext.c.

+ Here is the call graph for this function:

◆ DrawTextEx()

void DrawTextEx ( Font  font,
const char *  text,
Vector2  position,
float  fontSize,
float  spacing,
Color  tint 
)

Definition at line 1024 of file rtext.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DrawTextPro()

void DrawTextPro ( Font  font,
const char *  text,
Vector2  position,
Vector2  origin,
float  rotation,
float  fontSize,
float  spacing,
Color  tint 
)

Definition at line 1069 of file rtext.c.

+ Here is the call graph for this function:

◆ ExportFontAsCode()

bool ExportFontAsCode ( Font  font,
const char *  fileName 
)

Definition at line 837 of file rtext.c.

+ Here is the call graph for this function:

◆ GenImageFontAtlas()

Image GenImageFontAtlas ( const GlyphInfo chars,
Rectangle **  charRecs,
int  glyphCount,
int  fontSize,
int  padding,
int  packMethod 
)

Definition at line 662 of file rtext.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCodepoint()

int GetCodepoint ( const char *  text,
int *  bytesProcessed 
)

Definition at line 1741 of file rtext.c.

+ Here is the caller graph for this function:

◆ GetCodepointCount()

int GetCodepointCount ( const char *  text)

Definition at line 1716 of file rtext.c.

+ Here is the call graph for this function:

◆ GetFontDefault()

Font GetFontDefault ( void  )

Definition at line 289 of file rtext.c.

+ Here is the caller graph for this function:

◆ GetGlyphAtlasRec()

Rectangle GetGlyphAtlasRec ( Font  font,
int  codepoint 
)

Definition at line 1251 of file rtext.c.

+ Here is the call graph for this function:

◆ GetGlyphIndex()

int GetGlyphIndex ( Font  font,
int  codepoint 
)

Definition at line 1212 of file rtext.c.

+ Here is the caller graph for this function:

◆ GetGlyphInfo()

GlyphInfo GetGlyphInfo ( Font  font,
int  codepoint 
)

Definition at line 1240 of file rtext.c.

+ Here is the call graph for this function:

◆ LoadCodepoints()

int * LoadCodepoints ( const char *  text,
int *  count 
)

Definition at line 1683 of file rtext.c.

+ Here is the call graph for this function:

◆ LoadFont()

Font LoadFont ( const char *  fileName)

Definition at line 300 of file rtext.c.

+ Here is the call graph for this function:

◆ LoadFontData()

GlyphInfo * LoadFontData ( const unsigned char *  fileData,
int  dataSize,
int  fontSize,
int *  fontChars,
int  glyphCount,
int  type 
)

Definition at line 536 of file rtext.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadFontDefault()

void LoadFontDefault ( void  )

Definition at line 130 of file rtext.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadFontEx()

Font LoadFontEx ( const char *  fileName,
int  fontSize,
int *  fontChars,
int  glyphCount 
)

Definition at line 345 of file rtext.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadFontFromImage()

Font LoadFontFromImage ( Image  image,
Color  key,
int  firstChar 
)

Definition at line 366 of file rtext.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadFontFromMemory()

Font LoadFontFromMemory ( const char *  fileType,
const unsigned char *  fileData,
int  dataSize,
int  fontSize,
int *  fontChars,
int  glyphCount 
)

Definition at line 491 of file rtext.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MeasureText()

int MeasureText ( const char *  text,
int  fontSize 
)

Definition at line 1139 of file rtext.c.

+ Here is the call graph for this function:

◆ MeasureTextEx()

Vector2 MeasureTextEx ( Font  font,
const char *  text,
float  fontSize,
float  spacing 
)

Definition at line 1157 of file rtext.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TextAppend()

void TextAppend ( char *  text,
const char *  append,
int *  position 
)

Definition at line 1529 of file rtext.c.

+ Here is the call graph for this function:

◆ TextCodepointsToUTF8()

char * TextCodepointsToUTF8 ( const int *  codepoints,
int  length 
)

Definition at line 1620 of file rtext.c.

+ Here is the call graph for this function:

◆ TextCopy()

int TextCopy ( char *  dst,
const char *  src 
)

Definition at line 1322 of file rtext.c.

◆ TextFindIndex()

int TextFindIndex ( const char *  text,
const char *  find 
)

Definition at line 1537 of file rtext.c.

◆ TextFormat()

const char * TextFormat ( const char *  text,
  ... 
)

Definition at line 1278 of file rtext.c.

+ Here is the caller graph for this function:

◆ TextInsert()

char * TextInsert ( const char *  text,
const char *  insert,
int  position 
)

Definition at line 1436 of file rtext.c.

+ Here is the call graph for this function:

◆ TextIsEqual()

bool TextIsEqual ( const char *  text1,
const char *  text2 
)

Definition at line 1345 of file rtext.c.

+ Here is the caller graph for this function:

◆ TextJoin()

const char * TextJoin ( const char **  textList,
int  count,
const char *  delimiter 
)

Definition at line 1454 of file rtext.c.

+ Here is the call graph for this function:

◆ TextLength()

unsigned int TextLength ( const char *  text)

Definition at line 1264 of file rtext.c.

+ Here is the caller graph for this function:

◆ TextReplace()

char * TextReplace ( char *  text,
const char *  replace,
const char *  by 
)

Definition at line 1387 of file rtext.c.

+ Here is the call graph for this function:

◆ TextSplit()

const char ** TextSplit ( const char *  text,
char  delimiter,
int *  count 
)

Definition at line 1488 of file rtext.c.

+ Here is the caller graph for this function:

◆ TextSubtext()

const char * TextSubtext ( const char *  text,
int  position,
int  length 
)

Definition at line 1358 of file rtext.c.

+ Here is the call graph for this function:

◆ TextToInteger()

int TextToInteger ( const char *  text)

Definition at line 1304 of file rtext.c.

◆ TextToLower()

const char * TextToLower ( const char *  text)

Definition at line 1573 of file rtext.c.

+ Here is the caller graph for this function:

◆ TextToPascal()

const char * TextToPascal ( const char *  text)

Definition at line 1593 of file rtext.c.

+ Here is the caller graph for this function:

◆ TextToUpper()

const char * TextToUpper ( const char *  text)

Definition at line 1550 of file rtext.c.

+ Here is the caller graph for this function:

◆ UnloadCodepoints()

void UnloadCodepoints ( int *  codepoints)

Definition at line 1709 of file rtext.c.

◆ UnloadFont()

void UnloadFont ( Font  font)

Definition at line 823 of file rtext.c.

+ Here is the call graph for this function:

◆ UnloadFontData()

void UnloadFontData ( GlyphInfo glyphs,
int  glyphCount 
)

Definition at line 815 of file rtext.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UnloadFontDefault()

void UnloadFontDefault ( void  )

Definition at line 279 of file rtext.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: