55#if !defined(EXTERNAL_CONFIG_FLAGS)
59#if defined(SUPPORT_MODULE_RTEXT)
70#if defined(SUPPORT_FILEFORMAT_TTF)
71 #define STB_RECT_PACK_IMPLEMENTATION
75 #define STB_TRUETYPE_IMPLEMENTATION
82#ifndef MAX_TEXT_BUFFER_LENGTH
83 #define MAX_TEXT_BUFFER_LENGTH 1024
86#ifndef MAX_TEXT_UNICODE_CHARS
87 #define MAX_TEXT_UNICODE_CHARS 512
89#ifndef MAX_TEXTSPLIT_COUNT
90 #define MAX_TEXTSPLIT_COUNT 128
101#if defined(SUPPORT_DEFAULT_FONT)
104static Font defaultFont = { 0 };
115#if defined(SUPPORT_FILEFORMAT_FNT)
116static Font LoadBMFont(
const char *fileName);
119#if defined(SUPPORT_DEFAULT_FONT)
127#if defined(SUPPORT_DEFAULT_FONT)
132 #define BIT_CHECK(a,b) ((a) & (1u << (b)))
143 unsigned int defaultFontData[512] = {
144 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00200020, 0x0001b000, 0x00000000, 0x00000000, 0x8ef92520, 0x00020a00, 0x7dbe8000, 0x1f7df45f,
145 0x4a2bf2a0, 0x0852091e, 0x41224000, 0x10041450, 0x2e292020, 0x08220812, 0x41222000, 0x10041450, 0x10f92020, 0x3efa084c, 0x7d22103c, 0x107df7de,
146 0xe8a12020, 0x08220832, 0x05220800, 0x10450410, 0xa4a3f000, 0x08520832, 0x05220400, 0x10450410, 0xe2f92020, 0x0002085e, 0x7d3e0281, 0x107df41f,
147 0x00200000, 0x8001b000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
148 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xc0000fbe, 0xfbf7e00f, 0x5fbf7e7d, 0x0050bee8, 0x440808a2, 0x0a142fe8, 0x50810285, 0x0050a048,
149 0x49e428a2, 0x0a142828, 0x40810284, 0x0048a048, 0x10020fbe, 0x09f7ebaf, 0xd89f3e84, 0x0047a04f, 0x09e48822, 0x0a142aa1, 0x50810284, 0x0048a048,
150 0x04082822, 0x0a142fa0, 0x50810285, 0x0050a248, 0x00008fbe, 0xfbf42021, 0x5f817e7d, 0x07d09ce8, 0x00008000, 0x00000fe0, 0x00000000, 0x00000000,
151 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000c0180,
152 0xdfbf4282, 0x0bfbf7ef, 0x42850505, 0x004804bf, 0x50a142c6, 0x08401428, 0x42852505, 0x00a808a0, 0x50a146aa, 0x08401428, 0x42852505, 0x00081090,
153 0x5fa14a92, 0x0843f7e8, 0x7e792505, 0x00082088, 0x40a15282, 0x08420128, 0x40852489, 0x00084084, 0x40a16282, 0x0842022a, 0x40852451, 0x00088082,
154 0xc0bf4282, 0xf843f42f, 0x7e85fc21, 0x3e0900bf, 0x00000000, 0x00000004, 0x00000000, 0x000c0180, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
155 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04000402, 0x41482000, 0x00000000, 0x00000800,
156 0x04000404, 0x4100203c, 0x00000000, 0x00000800, 0xf7df7df0, 0x514bef85, 0xbefbefbe, 0x04513bef, 0x14414500, 0x494a2885, 0xa28a28aa, 0x04510820,
157 0xf44145f0, 0x474a289d, 0xa28a28aa, 0x04510be0, 0x14414510, 0x494a2884, 0xa28a28aa, 0x02910a00, 0xf7df7df0, 0xd14a2f85, 0xbefbe8aa, 0x011f7be0,
158 0x00000000, 0x00400804, 0x20080000, 0x00000000, 0x00000000, 0x00600f84, 0x20080000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
159 0xac000000, 0x00000f01, 0x00000000, 0x00000000, 0x24000000, 0x00000f01, 0x00000000, 0x06000000, 0x24000000, 0x00000f01, 0x00000000, 0x09108000,
160 0x24fa28a2, 0x00000f01, 0x00000000, 0x013e0000, 0x2242252a, 0x00000f52, 0x00000000, 0x038a8000, 0x2422222a, 0x00000f29, 0x00000000, 0x010a8000,
161 0x2412252a, 0x00000f01, 0x00000000, 0x010a8000, 0x24fbe8be, 0x00000f01, 0x00000000, 0x0ebe8000, 0xac020000, 0x00000f01, 0x00000000, 0x00048000,
162 0x0003e000, 0x00000f00, 0x00000000, 0x00008000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000038, 0x8443b80e, 0x00203a03,
163 0x02bea080, 0xf0000020, 0xc452208a, 0x04202b02, 0xf8029122, 0x07f0003b, 0xe44b388e, 0x02203a02, 0x081e8a1c, 0x0411e92a, 0xf4420be0, 0x01248202,
164 0xe8140414, 0x05d104ba, 0xe7c3b880, 0x00893a0a, 0x283c0e1c, 0x04500902, 0xc4400080, 0x00448002, 0xe8208422, 0x04500002, 0x80400000, 0x05200002,
165 0x083e8e00, 0x04100002, 0x804003e0, 0x07000042, 0xf8008400, 0x07f00003, 0x80400000, 0x04000022, 0x00000000, 0x00000000, 0x80400000, 0x04000002,
166 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00800702, 0x1848a0c2, 0x84010000, 0x02920921, 0x01042642, 0x00005121, 0x42023f7f, 0x00291002,
167 0xefc01422, 0x7efdfbf7, 0xefdfa109, 0x03bbbbf7, 0x28440f12, 0x42850a14, 0x20408109, 0x01111010, 0x28440408, 0x42850a14, 0x2040817f, 0x01111010,
168 0xefc78204, 0x7efdfbf7, 0xe7cf8109, 0x011111f3, 0x2850a932, 0x42850a14, 0x2040a109, 0x01111010, 0x2850b840, 0x42850a14, 0xefdfbf79, 0x03bbbbf7,
169 0x001fa020, 0x00000000, 0x00001000, 0x00000000, 0x00002070, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
170 0x08022800, 0x00012283, 0x02430802, 0x01010001, 0x8404147c, 0x20000144, 0x80048404, 0x00823f08, 0xdfbf4284, 0x7e03f7ef, 0x142850a1, 0x0000210a,
171 0x50a14684, 0x528a1428, 0x142850a1, 0x03efa17a, 0x50a14a9e, 0x52521428, 0x142850a1, 0x02081f4a, 0x50a15284, 0x4a221428, 0xf42850a1, 0x03efa14b,
172 0x50a16284, 0x4a521428, 0x042850a1, 0x0228a17a, 0xdfbf427c, 0x7e8bf7ef, 0xf7efdfbf, 0x03efbd0b, 0x00000000, 0x04000000, 0x00000000, 0x00000008,
173 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00200508, 0x00840400, 0x11458122, 0x00014210,
174 0x00514294, 0x51420800, 0x20a22a94, 0x0050a508, 0x00200000, 0x00000000, 0x00050000, 0x08000000, 0xfefbefbe, 0xfbefbefb, 0xfbeb9114, 0x00fbefbe,
175 0x20820820, 0x8a28a20a, 0x8a289114, 0x3e8a28a2, 0xfefbefbe, 0xfbefbe0b, 0x8a289114, 0x008a28a2, 0x228a28a2, 0x08208208, 0x8a289114, 0x088a28a2,
176 0xfefbefbe, 0xfbefbefb, 0xfa2f9114, 0x00fbefbe, 0x00000000, 0x00000040, 0x00000000, 0x00000000, 0x00000000, 0x00000020, 0x00000000, 0x00000000,
177 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00210100, 0x00000004, 0x00000000, 0x00000000, 0x14508200, 0x00001402, 0x00000000, 0x00000000,
178 0x00000010, 0x00000020, 0x00000000, 0x00000000, 0xa28a28be, 0x00002228, 0x00000000, 0x00000000, 0xa28a28aa, 0x000022e8, 0x00000000, 0x00000000,
179 0xa28a28aa, 0x000022a8, 0x00000000, 0x00000000, 0xa28a28aa, 0x000022e8, 0x00000000, 0x00000000, 0xbefbefbe, 0x00003e2f, 0x00000000, 0x00000000,
180 0x00000004, 0x00002028, 0x00000000, 0x00000000, 0x80000000, 0x00003e0f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
181 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
182 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
183 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
184 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
185 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
186 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 };
188 int charsHeight = 10;
189 int charsDivisor = 1;
191 int charsWidth[224] = { 3, 1, 4, 6, 5, 7, 6, 2, 3, 3, 5, 5, 2, 4, 1, 7, 5, 2, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 3, 4, 3, 6,
192 7, 6, 6, 6, 6, 6, 6, 6, 6, 3, 5, 6, 5, 7, 6, 6, 6, 6, 6, 6, 7, 6, 7, 7, 6, 6, 6, 2, 7, 2, 3, 5,
193 2, 5, 5, 5, 5, 5, 4, 5, 5, 1, 2, 5, 2, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 3, 1, 3, 4, 4,
194 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
195 1, 1, 5, 5, 5, 7, 1, 5, 3, 7, 3, 5, 4, 1, 7, 4, 3, 5, 3, 3, 2, 5, 6, 1, 2, 2, 3, 5, 6, 6, 6, 6,
196 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 3, 3, 3, 3, 7, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 4, 6,
197 5, 5, 5, 5, 5, 5, 9, 5, 5, 5, 5, 5, 2, 2, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 5 };
202 .
data = calloc(128*128, 2),
210 for (
int i = 0, counter = 0; i < imFont.
width*imFont.
height; i += 32)
212 for (
int j = 31; j >= 0; j--)
214 if (
BIT_CHECK(defaultFontData[counter], j))
218 ((
unsigned short *)imFont.
data)[i + j] = 0xffff;
220 else ((
unsigned short *)imFont.
data)[i + j] = 0x00ff;
237 int currentPosX = charsDivisor;
238 int testPosX = charsDivisor;
240 for (
int i = 0; i < defaultFont.
glyphCount; i++)
244 defaultFont.
recs[i].
x = (float)currentPosX;
245 defaultFont.
recs[i].
y = (float)(charsDivisor + currentLine*(charsHeight + charsDivisor));
246 defaultFont.
recs[i].
width = (float)charsWidth[i];
247 defaultFont.
recs[i].
height = (float)charsHeight;
249 testPosX += (int)(defaultFont.
recs[i].
width + (
float)charsDivisor);
254 currentPosX = 2*charsDivisor + charsWidth[i];
255 testPosX = currentPosX;
257 defaultFont.
recs[i].
x = (float)charsDivisor;
258 defaultFont.
recs[i].
y = (float)(charsDivisor + currentLine*(charsHeight + charsDivisor));
260 else currentPosX = testPosX;
291#if defined(SUPPORT_DEFAULT_FONT)
303#ifndef FONT_TTF_DEFAULT_SIZE
304 #define FONT_TTF_DEFAULT_SIZE 32
306#ifndef FONT_TTF_DEFAULT_NUMCHARS
307 #define FONT_TTF_DEFAULT_NUMCHARS 95
309#ifndef FONT_TTF_DEFAULT_FIRST_CHAR
310 #define FONT_TTF_DEFAULT_FIRST_CHAR 32
312#ifndef FONT_TTF_DEFAULT_CHARS_PADDING
313 #define FONT_TTF_DEFAULT_CHARS_PADDING 4
318#if defined(SUPPORT_FILEFORMAT_TTF)
322#if defined(SUPPORT_FILEFORMAT_FNT)
334 TRACELOG(
LOG_WARNING,
"FONT: [%s] Failed to load font texture -> Using default font", fileName);
345Font LoadFontEx(
const char *fileName,
int fontSize,
int *fontChars,
int glyphCount)
350 unsigned int fileSize = 0;
351 unsigned char *fileData =
LoadFileData(fileName, &fileSize);
353 if (fileData !=
NULL)
368#ifndef MAX_GLYPHS_FROM_IMAGE
369 #define MAX_GLYPHS_FROM_IMAGE 256
372 #define COLOR_EQUAL(col1, col2) ((col1.r == col2.r) && (col1.g == col2.g) && (col1.b == col2.b) && (col1.a == col2.a))
390 for (y = 0; y < image.
height; y++)
392 for (x = 0; x < image.
width; x++)
400 if ((x == 0) || (y == 0))
return font;
408 while (!
COLOR_EQUAL(pixels[(lineSpacing + j)*image.
width + charSpacing], key)) j++;
415 int xPosToRead = charSpacing;
418 while ((lineSpacing + lineToRead*(charHeight + lineSpacing)) < image.
height)
420 while ((xPosToRead < image.
width) &&
421 !
COLOR_EQUAL((pixels[(lineSpacing + (charHeight+lineSpacing)*lineToRead)*image.
width + xPosToRead]), key))
423 tempCharValues[index] = firstChar + index;
425 tempCharRecs[index].
x = (float)xPosToRead;
426 tempCharRecs[index].
y = (float)(lineSpacing + lineToRead*(charHeight + lineSpacing));
427 tempCharRecs[index].
height = (float)charHeight;
431 while (!
COLOR_EQUAL(pixels[(lineSpacing + (charHeight+lineSpacing)*lineToRead)*image.
width + xPosToRead + charWidth], key)) charWidth++;
433 tempCharRecs[index].
width = (float)charWidth;
437 xPosToRead += (charWidth + charSpacing);
441 xPosToRead = charSpacing;
451 .width = image.
width,
472 font.
recs[i] = tempCharRecs[i];
491Font LoadFontFromMemory(
const char *fileType,
const unsigned char *fileData,
int dataSize,
int fontSize,
int *fontChars,
int glyphCount)
495 char fileExtLower[16] = { 0 };
498#if defined(SUPPORT_FILEFORMAT_TTF)
503 font.
glyphCount = (glyphCount > 0)? glyphCount : 95;
536GlyphInfo *
LoadFontData(
const unsigned char *fileData,
int dataSize,
int fontSize,
int *fontChars,
int glyphCount,
int type)
540#ifndef FONT_SDF_CHAR_PADDING
541 #define FONT_SDF_CHAR_PADDING 4
543#ifndef FONT_SDF_ON_EDGE_VALUE
544 #define FONT_SDF_ON_EDGE_VALUE 128
546#ifndef FONT_SDF_PIXEL_DIST_SCALE
547 #define FONT_SDF_PIXEL_DIST_SCALE 64.0f
549#ifndef FONT_BITMAP_ALPHA_THRESHOLD
550 #define FONT_BITMAP_ALPHA_THRESHOLD 80
555#if defined(SUPPORT_FILEFORMAT_TTF)
558 if (fileData !=
NULL)
560 bool genFontChars =
false;
570 int ascent, descent, lineGap;
574 glyphCount = (glyphCount > 0)? glyphCount : 95;
579 if (fontChars ==
NULL)
581 fontChars = (
int *)
RL_MALLOC(glyphCount*
sizeof(
int));
582 for (
int i = 0; i < glyphCount; i++) fontChars[i] = i + 32;
589 for (
int i = 0; i < glyphCount; i++)
591 int chw = 0, chh = 0;
592 int ch = fontChars[i];
613 chars[i].
offsetY += (int)((
float)ascent*scaleFactor);
619 .
data = calloc(chars[i].advanceX*fontSize, 2),
626 chars[i].
image = imSpace;
633 for (
int p = 0; p < chw*chh; p++)
636 else ((
unsigned char *)chars[i].
image.
data)[p] = 255;
652 if (genFontChars)
RL_FREE(fontChars);
661#if defined(SUPPORT_FILEFORMAT_TTF)
675 glyphCount = (glyphCount > 0)? glyphCount : 95;
684 float requiredArea = 0;
685 for (
int i = 0; i < glyphCount; i++) requiredArea += ((chars[i].image.width + 2*padding)*(chars[i].
image.
height + 2*padding));
686 float guessSize = sqrtf(requiredArea)*1.4f;
687 int imageSize = (int)powf(2, ceilf(logf((
float)guessSize)/logf(2)));
689 atlas.
width = imageSize;
700 int offsetX = padding;
701 int offsetY = padding;
704 for (
int i = 0; i < glyphCount; i++)
709 for (
int x = 0; x < chars[i].
image.
width; x++)
711 ((
unsigned char *)atlas.
data)[(offsetY + y)*atlas.
width + (offsetX + x)] = ((
unsigned char *)chars[i].image.data)[y*chars[i].
image.
width + x];
716 recs[i].
x = (float)offsetX;
717 recs[i].
y = (float)offsetY;
718 recs[i].
width = (float)chars[i].image.width;
722 offsetX += (chars[i].
image.
width + 2*padding);
731 offsetY += (fontSize + 2*padding);
733 if (offsetY > (atlas.
height - fontSize - padding))
735 for(
int j = i + 1; j < glyphCount; j++)
749 else if (packMethod == 1)
758 for (
int i = 0; i < glyphCount; i++)
768 for (
int i = 0; i < glyphCount; i++)
771 recs[i].
x = rects[i].
x + (float)padding;
772 recs[i].
y = rects[i].
y + (float)padding;
773 recs[i].
width = (float)chars[i].image.width;
776 if (rects[i].was_packed)
781 for (
int x = 0; x < chars[i].
image.
width; x++)
783 ((
unsigned char *)atlas.
data)[(rects[i].
y + padding + y)*atlas.
width + (rects[i].
x + padding + x)] = ((
unsigned char *)chars[i].image.data)[y*chars[i].
image.
width + x];
796 unsigned char *dataGrayAlpha = (
unsigned char *)
RL_MALLOC(atlas.
width*atlas.
height*
sizeof(
unsigned char)*2);
798 for (
int i = 0, k = 0; i < atlas.
width*atlas.
height; i++, k += 2)
800 dataGrayAlpha[k] = 255;
801 dataGrayAlpha[k + 1] = ((
unsigned char *)atlas.
data)[i];
805 atlas.
data = dataGrayAlpha;
817 for (
int i = 0; i < glyphCount; i++)
UnloadImage(glyphs[i].image);
832 TRACELOGD(
"FONT: Unloaded font data from RAM and VRAM");
839 bool success =
false;
841#ifndef TEXT_BYTES_PER_LINE
842 #define TEXT_BYTES_PER_LINE 20
845 #define MAX_FONT_DATA_SIZE 1024*1024
848 char fileNamePascal[256] = { 0 };
856 byteCount += sprintf(txtData + byteCount,
"////////////////////////////////////////////////////////////////////////////////////////\n");
857 byteCount += sprintf(txtData + byteCount,
"// //\n");
858 byteCount += sprintf(txtData + byteCount,
"// FontAsCode exporter v1.0 - Font data exported as an array of bytes //\n");
859 byteCount += sprintf(txtData + byteCount,
"// //\n");
860 byteCount += sprintf(txtData + byteCount,
"// more info and bugs-report: github.com/raysan5/raylib //\n");
861 byteCount += sprintf(txtData + byteCount,
"// feedback and support: ray[at]raylib.com //\n");
862 byteCount += sprintf(txtData + byteCount,
"// //\n");
863 byteCount += sprintf(txtData + byteCount,
"// Copyright (c) 2018-2022 Ramon Santamaria (@raysan5) //\n");
864 byteCount += sprintf(txtData + byteCount,
"// //\n");
865 byteCount += sprintf(txtData + byteCount,
"// ---------------------------------------------------------------------------------- //\n");
866 byteCount += sprintf(txtData + byteCount,
"// //\n");
867 byteCount += sprintf(txtData + byteCount,
"// TODO: Fill the information and license of the exported font here: //\n");
868 byteCount += sprintf(txtData + byteCount,
"// //\n");
869 byteCount += sprintf(txtData + byteCount,
"// Font name: .... //\n");
870 byteCount += sprintf(txtData + byteCount,
"// Font creator: .... //\n");
871 byteCount += sprintf(txtData + byteCount,
"// Font LICENSE: .... //\n");
872 byteCount += sprintf(txtData + byteCount,
"// //\n");
873 byteCount += sprintf(txtData + byteCount,
"////////////////////////////////////////////////////////////////////////////////////////\n\n");
884#define SUPPORT_COMPRESSED_FONT_ATLAS
885#if defined(SUPPORT_COMPRESSED_FONT_ATLAS)
891 int compDataSize = 0;
892 unsigned char *compData =
CompressData(image.
data, imageDataSize, &compDataSize);
895 byteCount += sprintf(txtData + byteCount,
"#define COMPRESSED_DATA_SIZE_FONT_%s %i\n\n",
TextToUpper(fileNamePascal), compDataSize);
896 byteCount += sprintf(txtData + byteCount,
"// Font image pixels data compressed (DEFLATE)\n");
897 byteCount += sprintf(txtData + byteCount,
"// NOTE: Original pixel data simplified to GRAYSCALE\n");
898 byteCount += sprintf(txtData + byteCount,
"static unsigned char fontData_%s[COMPRESSED_DATA_SIZE_FONT_%s] = { ", fileNamePascal,
TextToUpper(fileNamePascal));
899 for (
int i = 0; i < compDataSize - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%
TEXT_BYTES_PER_LINE == 0)?
"0x%02x,\n " :
"0x%02x, "), compData[i]);
900 byteCount += sprintf(txtData + byteCount,
"0x%02x };\n\n", compData[compDataSize - 1]);
904 byteCount += sprintf(txtData + byteCount,
"// Font image pixels data\n");
905 byteCount += sprintf(txtData + byteCount,
"// NOTE: 2 bytes per pixel, GRAY + ALPHA channels\n");
906 byteCount += sprintf(txtData + byteCount,
"static unsigned char fontImageData_%s[%i] = { ", fileNamePascal, imageDataSize);
907 for (
int i = 0; i < imageDataSize - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%
TEXT_BYTES_PER_LINE == 0)?
"0x%02x,\n " :
"0x%02x, "), ((
unsigned char *)imFont.data)[i]);
908 byteCount += sprintf(txtData + byteCount,
"0x%02x };\n\n", ((
unsigned char *)imFont.data)[imageDataSize - 1]);
912 byteCount += sprintf(txtData + byteCount,
"// Font characters rectangles data\n");
913 byteCount += sprintf(txtData + byteCount,
"static const Rectangle fontRecs_%s[%i] = {\n", fileNamePascal, font.
glyphCount);
916 byteCount += sprintf(txtData + byteCount,
" { %1.0f, %1.0f, %1.0f , %1.0f },\n", font.
recs[i].
x, font.
recs[i].
y, font.
recs[i].
width, font.
recs[i].
height);
918 byteCount += sprintf(txtData + byteCount,
"};\n\n");
923 byteCount += sprintf(txtData + byteCount,
"// Font glyphs info data\n");
924 byteCount += sprintf(txtData + byteCount,
"// NOTE: No glyphs.image data provided\n");
925 byteCount += sprintf(txtData + byteCount,
"static const GlyphInfo fontGlyphs_%s[%i] = {\n", fileNamePascal, font.
glyphCount);
928 byteCount += sprintf(txtData + byteCount,
" { %i, %i, %i, %i, { 0 }},\n", font.
glyphs[i].
value, font.
glyphs[i].
offsetX, font.
glyphs[i].
offsetY, font.
glyphs[i].
advanceX);
930 byteCount += sprintf(txtData + byteCount,
"};\n\n");
933 byteCount += sprintf(txtData + byteCount,
"// Font loading function: %s\n", fileNamePascal);
934 byteCount += sprintf(txtData + byteCount,
"static Font LoadFont_%s(void)\n{\n", fileNamePascal);
935 byteCount += sprintf(txtData + byteCount,
" Font font = { 0 };\n\n");
936 byteCount += sprintf(txtData + byteCount,
" font.baseSize = %i;\n", font.
baseSize);
937 byteCount += sprintf(txtData + byteCount,
" font.glyphCount = %i;\n", font.
glyphCount);
939 byteCount += sprintf(txtData + byteCount,
" // Custom font loading\n");
940#if defined(SUPPORT_COMPRESSED_FONT_ATLAS)
941 byteCount += sprintf(txtData + byteCount,
" // NOTE: Compressed font image data (DEFLATE), it requires DecompressData() function\n");
942 byteCount += sprintf(txtData + byteCount,
" int fontDataSize_%s = 0;\n", fileNamePascal);
943 byteCount += sprintf(txtData + byteCount,
" unsigned char *data = DecompressData(fontData_%s, COMPRESSED_DATA_SIZE_FONT_%s, &fontDataSize_%s);\n", fileNamePascal,
TextToUpper(fileNamePascal), fileNamePascal);
944 byteCount += sprintf(txtData + byteCount,
" Image imFont = { data, %i, %i, 1, %i };\n\n", image.
width, image.
height, image.
format);
946 byteCount += sprintf(txtData + byteCount,
" Image imFont = { fontImageData_%s, %i, %i, 1, %i };\n\n", styleName, image.
width, image.
height, image.
format);
948 byteCount += sprintf(txtData + byteCount,
" // Load texture from image\n");
949 byteCount += sprintf(txtData + byteCount,
" font.texture = LoadTextureFromImage(imFont);\n");
950#if defined(SUPPORT_COMPRESSED_FONT_ATLAS)
951 byteCount += sprintf(txtData + byteCount,
" UnloadImage(imFont); // Uncompressed data can be unloaded from memory\n\n");
958#if defined(SUPPORT_FONT_DATA_COPY)
959 byteCount += sprintf(txtData + byteCount,
" // Copy glyph recs data from global fontRecs\n");
960 byteCount += sprintf(txtData + byteCount,
" // NOTE: Required to avoid issues if trying to free font\n");
961 byteCount += sprintf(txtData + byteCount,
" font.recs = (Rectangle *)malloc(font.glyphCount*sizeof(Rectangle));\n");
962 byteCount += sprintf(txtData + byteCount,
" memcpy(font.recs, fontRecs_%s, font.glyphCount*sizeof(Rectangle));\n\n", fileNamePascal);
964 byteCount += sprintf(txtData + byteCount,
" // Copy font glyph info data from global fontChars\n");
965 byteCount += sprintf(txtData + byteCount,
" // NOTE: Required to avoid issues if trying to free font\n");
966 byteCount += sprintf(txtData + byteCount,
" font.glyphs = (GlyphInfo *)malloc(font.glyphCount*sizeof(GlyphInfo));\n");
967 byteCount += sprintf(txtData + byteCount,
" memcpy(font.glyphs, fontGlyphs_%s, font.glyphCount*sizeof(GlyphInfo));\n\n", fileNamePascal);
969 byteCount += sprintf(txtData + byteCount,
" // Assign glyph recs and info data directly\n");
970 byteCount += sprintf(txtData + byteCount,
" // WARNING: This font data must not be unloaded\n");
971 byteCount += sprintf(txtData + byteCount,
" font.recs = fontRecs_%s;\n", fileNamePascal);
972 byteCount += sprintf(txtData + byteCount,
" font.glyphs = fontGlyphs_%s;\n\n", fileNamePascal);
974 byteCount += sprintf(txtData + byteCount,
" return font;\n");
975 byteCount += sprintf(txtData + byteCount,
"}\n");
984 if (success != 0)
TRACELOG(
LOG_INFO,
"FILEIO: [%s] Font as code exported successfully", fileName);
998 if ((fps < 30) && (fps >= 15)) color =
ORANGE;
999 else if (fps < 15) color =
RED;
1012 Vector2 position = { (float)posX, (
float)posY };
1014 int defaultFontSize = 10;
1015 if (fontSize < defaultFontSize) fontSize = defaultFontSize;
1016 int spacing = fontSize/defaultFontSize;
1030 int textOffsetY = 0;
1031 float textOffsetX = 0.0f;
1033 float scaleFactor = fontSize/font.
baseSize;
1035 for (
int i = 0; i < size;)
1038 int codepointByteCount = 0;
1039 int codepoint =
GetCodepoint(&text[i], &codepointByteCount);
1044 if (codepoint == 0x3f) codepointByteCount = 1;
1046 if (codepoint ==
'\n')
1055 if ((codepoint !=
' ') && (codepoint !=
'\t'))
1061 else textOffsetX += ((float)font.
glyphs[index].
advanceX*scaleFactor + spacing);
1064 i += codepointByteCount;
1088 float scaleFactor = fontSize/font.
baseSize;
1109 int textOffsetY = 0;
1110 float textOffsetX = 0.0f;
1112 float scaleFactor = fontSize/font.
baseSize;
1114 for (
int i = 0; i < count; i++)
1118 if (codepoints[i] ==
'\n')
1127 if ((codepoints[i] !=
' ') && (codepoints[i] !=
'\t'))
1133 else textOffsetX += ((float)font.
glyphs[index].
advanceX*scaleFactor + spacing);
1146 int defaultFontSize = 10;
1147 if (fontSize < defaultFontSize) fontSize = defaultFontSize;
1148 int spacing = fontSize/defaultFontSize;
1160 int tempByteCounter = 0;
1161 int byteCounter = 0;
1163 float textWidth = 0.0f;
1164 float tempTextWidth = 0.0f;
1166 float textHeight = (float)font.
baseSize;
1167 float scaleFactor = fontSize/(
float)font.
baseSize;
1172 for (
int i = 0; i < size; i++)
1182 if (letter == 0x3f) next = 1;
1192 if (tempTextWidth < textWidth) tempTextWidth = textWidth;
1195 textHeight += ((float)font.
baseSize*1.5f);
1198 if (tempByteCounter < byteCounter) tempByteCounter = byteCounter;
1201 if (tempTextWidth < textWidth) tempTextWidth = textWidth;
1204 vec.
x = tempTextWidth*scaleFactor + (float)((tempByteCounter - 1)*spacing);
1205 vec.
y = textHeight*scaleFactor;
1214#ifndef GLYPH_NOTFOUND_CHAR_FALLBACK
1215 #define GLYPH_NOTFOUND_CHAR_FALLBACK 63
1219#define SUPPORT_UNORDERED_CHARSET
1220#if defined(SUPPORT_UNORDERED_CHARSET)
1234 return (codepoint - 32);
1266 unsigned int length = 0;
1270 while (*text++) length++;
1280#ifndef MAX_TEXTFORMAT_BUFFERS
1281 #define MAX_TEXTFORMAT_BUFFERS 4
1286 static int index = 0;
1288 char *currentBuffer = buffers[index];
1292 va_start(args, text);
1299 return currentBuffer;
1309 if ((text[0] ==
'+') || (text[0] ==
'-'))
1311 if (text[0] ==
'-') sign = -1;
1315 for (
int i = 0; ((text[i] >=
'0') && (text[i] <=
'9')); ++i) value = value*10 + (
int)(text[i] -
'0');
1320#if defined(SUPPORT_TEXT_MANIPULATION)
1328 while (*src !=
'\0')
1347 bool result =
false;
1349 if ((text1 !=
NULL) && (text2 !=
NULL))
1351 if (strcmp(text1, text2) == 0) result =
true;
1365 if (position >= textLength)
1367 position = textLength - 1;
1371 if (length >= textLength) length = textLength;
1373 for (
int c = 0 ; c < length ; c++)
1375 *(buffer + c) = *(text + position);
1379 *(buffer + length) =
'\0';
1390 if (!text || !replace || !by)
return NULL;
1392 char *result =
NULL;
1394 char *insertPoint =
NULL;
1398 int lastReplacePos = 0;
1402 if (replaceLen == 0)
return NULL;
1408 for (count = 0; (temp = strstr(insertPoint, replace)); count++) insertPoint = temp + replaceLen;
1413 if (!result)
return NULL;
1421 insertPoint = strstr(text, replace);
1422 lastReplacePos = (int)(insertPoint - text);
1423 temp = strncpy(temp, text, lastReplacePos) + lastReplacePos;
1424 temp = strcpy(temp, by) + byLen;
1425 text += lastReplacePos + replaceLen;
1436char *
TextInsert(
const char *text,
const char *insert,
int position)
1441 char *result = (
char *)
RL_MALLOC(textLen + insertLen + 1);
1443 for (
int i = 0; i < position; i++) result[i] = text[i];
1444 for (
int i = position; i < insertLen + position; i++) result[i] = insert[i];
1445 for (
int i = (insertLen + position); i < (textLen + insertLen); i++) result[i] = text[i];
1447 result[textLen + insertLen] =
'\0';
1454const char *
TextJoin(
const char **textList,
int count,
const char *delimiter)
1458 char *textPtr = buffer;
1460 int totalLength = 0;
1463 for (
int i = 0; i < count; i++)
1470 memcpy(textPtr, textList[i], textLength);
1471 totalLength += textLength;
1472 textPtr += textLength;
1474 if ((delimiterLen > 0) && (i < (count - 1)))
1476 memcpy(textPtr, delimiter, delimiterLen);
1477 totalLength += delimiterLen;
1478 textPtr += delimiterLen;
1488const char **
TextSplit(
const char *text,
char delimiter,
int *count)
1510 buffer[i] = text[i];
1511 if (buffer[i] ==
'\0')
break;
1512 else if (buffer[i] == delimiter)
1515 result[counter] = buffer + i + 1;
1531 strcpy(text + *position, append);
1541 char *ptr = strstr(text, find);
1543 if (ptr !=
NULL) position = (int)(ptr - text);
1557 if (text[i] !=
'\0')
1559 buffer[i] = (char)toupper(text[i]);
1565 else { buffer[i] =
'\0';
break; }
1580 if (text[i] !=
'\0')
1582 buffer[i] = (char)tolower(text[i]);
1585 else { buffer[i] =
'\0';
break; }
1598 buffer[0] = (char)toupper(text[0]);
1602 if (text[j] !=
'\0')
1604 if (text[j] !=
'_') buffer[i] = text[j];
1608 buffer[i] = (char)toupper(text[j]);
1611 else { buffer[i] =
'\0';
break; }
1624 char *text = (
char *)
RL_CALLOC(length*5, 1);
1625 const char *utf8 =
NULL;
1628 for (
int i = 0, bytes = 0; i < length; i++)
1631 memcpy(text + size, utf8, bytes);
1638 if (ptr !=
NULL) text = (
char *)ptr;
1647 static char utf8[6] = { 0 };
1650 if (codepoint <= 0x7f)
1652 utf8[0] = (char)codepoint;
1655 else if (codepoint <= 0x7ff)
1657 utf8[0] = (char)(((codepoint >> 6) & 0x1f) | 0xc0);
1658 utf8[1] = (char)((codepoint & 0x3f) | 0x80);
1661 else if (codepoint <= 0xffff)
1663 utf8[0] = (char)(((codepoint >> 12) & 0x0f) | 0xe0);
1664 utf8[1] = (char)(((codepoint >> 6) & 0x3f) | 0x80);
1665 utf8[2] = (char)((codepoint & 0x3f) | 0x80);
1668 else if (codepoint <= 0x10ffff)
1670 utf8[0] = (char)(((codepoint >> 18) & 0x07) | 0xf0);
1671 utf8[1] = (char)(((codepoint >> 12) & 0x3f) | 0x80);
1672 utf8[2] = (char)(((codepoint >> 6) & 0x3f) | 0x80);
1673 utf8[3] = (char)((codepoint & 0x3f) | 0x80);
1687 int bytesProcessed = 0;
1688 int codepointCount = 0;
1691 int *codepoints =
RL_CALLOC(textLength,
sizeof(
int));
1693 for (
int i = 0; i < textLength; codepointCount++)
1695 codepoints[codepointCount] =
GetCodepoint(text + i, &bytesProcessed);
1696 i += bytesProcessed;
1700 void *temp =
RL_REALLOC(codepoints, codepointCount*
sizeof(
int));
1701 if (temp !=
NULL) codepoints = temp;
1703 *count = codepointCount;
1718 unsigned int length = 0;
1719 char *ptr = (
char *)&text[0];
1721 while (*ptr !=
'\0')
1726 if (letter == 0x3f) ptr += 1;
1757 int octet = (
unsigned char)(text[0]);
1758 *bytesProcessed = 1;
1765 else if ((octet & 0xe0) == 0xc0)
1770 unsigned char octet1 = text[1];
1772 if ((octet1 ==
'\0') || ((octet1 >> 6) != 2)) { *bytesProcessed = 2;
return code; }
1774 if ((octet >= 0xc2) && (octet <= 0xdf))
1776 code = ((octet & 0x1f) << 6) | (octet1 & 0x3f);
1777 *bytesProcessed = 2;
1780 else if ((octet & 0xf0) == 0xe0)
1783 unsigned char octet1 = text[1];
1784 unsigned char octet2 =
'\0';
1786 if ((octet1 ==
'\0') || ((octet1 >> 6) != 2)) { *bytesProcessed = 2;
return code; }
1790 if ((octet2 ==
'\0') || ((octet2 >> 6) != 2)) { *bytesProcessed = 3;
return code; }
1797 if (((octet == 0xe0) && !((octet1 >= 0xa0) && (octet1 <= 0xbf))) ||
1798 ((octet == 0xed) && !((octet1 >= 0x80) && (octet1 <= 0x9f)))) { *bytesProcessed = 2;
return code; }
1800 if ((octet >= 0xe0) && (octet <= 0xef))
1802 code = ((octet & 0xf) << 12) | ((octet1 & 0x3f) << 6) | (octet2 & 0x3f);
1803 *bytesProcessed = 3;
1806 else if ((octet & 0xf8) == 0xf0)
1809 if (octet > 0xf4)
return code;
1811 unsigned char octet1 = text[1];
1812 unsigned char octet2 =
'\0';
1813 unsigned char octet3 =
'\0';
1815 if ((octet1 ==
'\0') || ((octet1 >> 6) != 2)) { *bytesProcessed = 2;
return code; }
1819 if ((octet2 ==
'\0') || ((octet2 >> 6) != 2)) { *bytesProcessed = 3;
return code; }
1823 if ((octet3 ==
'\0') || ((octet3 >> 6) != 2)) { *bytesProcessed = 4;
return code; }
1829 if (((octet == 0xf0) && !((octet1 >= 0x90) && (octet1 <= 0xbf))) ||
1830 ((octet == 0xf4) && !((octet1 >= 0x80) && (octet1 <= 0x8f)))) { *bytesProcessed = 2;
return code; }
1834 code = ((octet & 0x7) << 18) | ((octet1 & 0x3f) << 12) | ((octet2 & 0x3f) << 6) | (octet3 & 0x3f);
1835 *bytesProcessed = 4;
1839 if (code > 0x10ffff) code = 0x3f;
1847#if defined(SUPPORT_FILEFORMAT_FNT)
1852static int GetLine(
const char *origin,
char *buffer,
int maxLength)
1855 for (; count < maxLength; count++)
if (origin[count] ==
'\n')
break;
1856 memcpy(buffer, origin, count);
1862static Font LoadBMFont(
const char *fileName)
1864 #define MAX_BUFFER_SIZE 256
1869 char *searchPoint =
NULL;
1876 char imFileName[129] = { 0 };
1882 if (fileText ==
NULL)
return font;
1884 char *fileTextPtr = fileText;
1888 fileTextPtr += (lineBytes + 1);
1892 searchPoint = strstr(buffer,
"lineHeight");
1893 sscanf(searchPoint,
"lineHeight=%i base=%i scaleW=%i scaleH=%i", &fontSize, &base, &imWidth, &imHeight);
1894 fileTextPtr += (lineBytes + 1);
1896 TRACELOGD(
"FONT: [%s] Loaded font info:", fileName);
1897 TRACELOGD(
" > Base size: %i", fontSize);
1898 TRACELOGD(
" > Texture scale: %ix%i", imWidth, imHeight);
1901 searchPoint = strstr(buffer,
"file");
1902 sscanf(searchPoint,
"file=\"%128[^\"]\"", imFileName);
1903 fileTextPtr += (lineBytes + 1);
1905 TRACELOGD(
" > Texture filename: %s", imFileName);
1908 searchPoint = strstr(buffer,
"count");
1909 sscanf(searchPoint,
"count=%i", &glyphCount);
1910 fileTextPtr += (lineBytes + 1);
1912 TRACELOGD(
" > Chars count: %i", glyphCount);
1915 char *imPath =
NULL;
1916 char *lastSlash =
NULL;
1918 lastSlash = strrchr(fileName,
'/');
1919 if (lastSlash ==
NULL) lastSlash = strrchr(fileName,
'\\');
1921 if (lastSlash !=
NULL)
1928 else imPath = imFileName;
1930 TRACELOGD(
" > Image loading path: %s", imPath);
1937 Image imFontAlpha = {
1939 .width = imFont.
width,
1945 for (
int p = 0, i = 0; p < (imFont.
width*imFont.
height*2); p += 2, i++)
1947 ((
unsigned char *)(imFontAlpha.
data))[p] = 0xff;
1948 ((
unsigned char *)(imFontAlpha.
data))[p + 1] = ((
unsigned char *)imFont.
data)[i];
1952 imFont = imFontAlpha;
1966 int charId, charX, charY, charWidth, charHeight, charOffsetX, charOffsetY, charAdvanceX;
1968 for (
int i = 0; i < glyphCount; i++)
1971 sscanf(buffer,
"char id=%i x=%i y=%i width=%i height=%i xoffset=%i yoffset=%i xadvance=%i",
1972 &charId, &charX, &charY, &charWidth, &charHeight, &charOffsetX, &charOffsetY, &charAdvanceX);
1973 fileTextPtr += (lineBytes + 1);
1976 font.
recs[i] = (
Rectangle){ (float)charX, (
float)charY, (float)charWidth, (
float)charHeight };
1995 TRACELOG(
LOG_WARNING,
"FONT: [%s] Failed to load texture, reverted to default font", fileName);
#define MAX_TEXT_BUFFER_LENGTH
#define MAX_TEXTSPLIT_COUNT
#define RL_MALLOC(sz)
raudio v1.0 - A simple and easy-to-use audio library based on miniaudio
#define TRACELOG(level,...)
RLAPI void MemFree(void *ptr)
RLAPI Color * LoadImageColors(Image image)
RLAPI void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint)
RLAPI unsigned char * CompressData(const unsigned char *data, int dataSize, int *compDataSize)
@ PIXELFORMAT_UNCOMPRESSED_GRAYSCALE
@ PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
@ PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA
RLAPI unsigned char * LoadFileData(const char *fileName, unsigned int *bytesRead)
#define RL_REALLOC(ptr, sz)
RLAPI Image ImageFromImage(Image image, Rectangle rec)
RLAPI void UnloadTexture(Texture2D texture)
RLAPI void TraceLog(int logLevel, const char *text,...)
RLAPI Image LoadImage(const char *fileName)
RLAPI bool SaveFileText(const char *fileName, char *text)
RLAPI const char * GetFileNameWithoutExt(const char *filePath)
RLAPI void UnloadImage(Image image)
RLAPI int GetPixelDataSize(int width, int height, int format)
RLAPI void UnloadFileText(char *text)
RLAPI void SetTextureFilter(Texture2D texture, int filter)
RLAPI const char * GetFileExtension(const char *fileName)
RLAPI Texture2D LoadTextureFromImage(Image image)
RLAPI bool IsFileExtension(const char *fileName, const char *ext)
RLAPI char * LoadFileText(const char *fileName)
RLAPI Image LoadImageFromTexture(Texture2D texture)
RLAPI void rlPushMatrix(void)
RLAPI void rlRotatef(float angle, float x, float y, float z)
RLAPI void rlPopMatrix(void)
RLAPI void rlTranslatef(float x, float y, float z)
const char ** TextSplit(const char *text, char delimiter, int *count)
void DrawTextCodepoints(Font font, const int *codepoints, int count, Vector2 position, float fontSize, float spacing, Color tint)
Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount)
int * LoadCodepoints(const char *text, int *count)
GlyphInfo * LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount, int type)
void UnloadFontDefault(void)
int TextCopy(char *dst, const char *src)
bool TextIsEqual(const char *text1, const char *text2)
Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphCount, int fontSize, int padding, int packMethod)
void TextAppend(char *text, const char *append, int *position)
int MeasureText(const char *text, int fontSize)
int GetGlyphIndex(Font font, int codepoint)
Font LoadFont(const char *fileName)
int TextToInteger(const char *text)
Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing)
Font LoadFontFromImage(Image image, Color key, int firstChar)
unsigned int TextLength(const char *text)
#define COLOR_EQUAL(col1, col2)
const char * TextToLower(const char *text)
Rectangle GetGlyphAtlasRec(Font font, int codepoint)
#define FONT_SDF_CHAR_PADDING
#define MAX_GLYPHS_FROM_IMAGE
void DrawTextPro(Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint)
char * TextReplace(char *text, const char *replace, const char *by)
const char * TextToPascal(const char *text)
void DrawFPS(int posX, int posY)
void LoadFontDefault(void)
RLAPI const char * CodepointToUTF8(int codepoint, int *byteSize)
void UnloadCodepoints(int *codepoints)
#define FONT_BITMAP_ALPHA_THRESHOLD
const char * TextJoin(const char **textList, int count, const char *delimiter)
#define FONT_SDF_ON_EDGE_VALUE
char * TextInsert(const char *text, const char *insert, int position)
#define FONT_SDF_PIXEL_DIST_SCALE
#define MAX_FONT_DATA_SIZE
#define TEXT_BYTES_PER_LINE
int GetCodepointCount(const char *text)
#define FONT_TTF_DEFAULT_NUMCHARS
#define FONT_TTF_DEFAULT_FIRST_CHAR
const char * TextSubtext(const char *text, int position, int length)
Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int glyphCount)
void DrawText(const char *text, int posX, int posY, int fontSize, Color color)
void UnloadFont(Font font)
char * TextCodepointsToUTF8(const int *codepoints, int length)
void UnloadFontData(GlyphInfo *glyphs, int glyphCount)
const char * TextFormat(const char *text,...)
GlyphInfo GetGlyphInfo(Font font, int codepoint)
#define FONT_TTF_DEFAULT_SIZE
#define MAX_TEXTFORMAT_BUFFERS
#define GLYPH_NOTFOUND_CHAR_FALLBACK
#define FONT_TTF_DEFAULT_CHARS_PADDING
bool ExportFontAsCode(Font font, const char *fileName)
const char * TextToUpper(const char *text)
void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSize, Color tint)
int GetCodepoint(const char *text, int *bytesProcessed)
int TextFindIndex(const char *text, const char *find)
STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing)
STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap)
STBTT_DEF unsigned char * stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels)
STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset)
STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff)