aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2019-10-22 00:37:10 +0200
committerRay <raysan5@gmail.com>2019-10-22 00:37:10 +0200
commitca92f43c27d202a0c3ac3a90e76e891639c4b6d3 (patch)
treee514fa9f3bf3b480d8afe3bfd03a857004dd85aa
parentea70c47a1a8cfcdaa61688f37675b5e877ebb903 (diff)
downloadraylib-ca92f43c27d202a0c3ac3a90e76e891639c4b6d3.tar.gz
raylib-ca92f43c27d202a0c3ac3a90e76e891639c4b6d3.zip
Review some defines
-rw-r--r--src/text.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/text.c b/src/text.c
index 7b828384..1c06fe96 100644
--- a/src/text.c
+++ b/src/text.c
@@ -10,6 +10,15 @@
* 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 TEXTSPLIT_MAX_SUBSTRINGS_COUNT
+* TextSplit() function static substrings pointers array (pointing to static buffer)
+*
*
* DEPENDENCIES:
* stb_truetype - Load TTF file and rasterize characters data
@@ -63,10 +72,19 @@
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
-#define MAX_TEXT_BUFFER_LENGTH 1024 // Size of internal static buffers of some Text*() functions
+#define MAX_TEXT_BUFFER_LENGTH 1024 // Size of internal static buffers used on some functions:
+ // TextFormat(), TextSubtext(), TextToUpper(), TextToLower(), TextToPascal()
#define MAX_TEXT_UNICODE_CHARS 512 // Maximum number of unicode codepoints
+#if !defined(TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH)
+ #define TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH 1024 // Size of static buffer: TextSplit()
+#endif
+
+#if !defined(TEXTSPLIT_MAX_SUBSTRINGS_COUNT)
+ #define TEXTSPLIT_MAX_SUBSTRINGS_COUNT 128 // Size of static pointers array: TextSplit()
+#endif
+
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
@@ -1384,14 +1402,12 @@ const char **TextSplit(const char *text, char delimiter, int *count)
// NOTE: Current implementation returns a copy of the provided string with '\0' (string end delimiter)
// inserted between strings defined by "delimiter" parameter. No memory is dynamically allocated,
// all used memory is static... it has some limitations:
- // 1. Maximum number of possible split strings is set by MAX_SUBSTRINGS_COUNT
- // 2. Maximum size of text to split is MAX_TEXT_BUFFER_LENGTH
+ // 1. Maximum number of possible split strings is set by TEXTSPLIT_MAX_SUBSTRINGS_COUNT
+ // 2. Maximum size of text to split is TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH
- #define MAX_SUBSTRINGS_COUNT 64
-
- static const char *result[MAX_SUBSTRINGS_COUNT] = { NULL };
- static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
- memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
+ static const char *result[TEXTSPLIT_MAX_SUBSTRINGS_COUNT] = { NULL };
+ static char buffer[TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH] = { 0 };
+ memset(buffer, 0, TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH);
result[0] = buffer;
int counter = 0;
@@ -1411,7 +1427,7 @@ const char **TextSplit(const char *text, char delimiter, int *count)
result[counter] = buffer + i + 1;
counter++;
- if (counter == MAX_SUBSTRINGS_COUNT) break;
+ if (counter == TEXTSPLIT_MAX_SUBSTRINGS_COUNT) break;
}
}
}