mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-01 11:49:17 -05:00
REVIEWED: CodepointToUTF8(), clean static buffer #4379
This commit is contained in:
11
src/rtext.c
11
src/rtext.c
@ -1302,15 +1302,15 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
|
|||||||
{
|
{
|
||||||
byteCounter++;
|
byteCounter++;
|
||||||
|
|
||||||
int next = 0;
|
int codepointByteCount = 0;
|
||||||
letter = GetCodepointNext(&text[i], &next);
|
letter = GetCodepointNext(&text[i], &codepointByteCount);
|
||||||
index = GetGlyphIndex(font, letter);
|
index = GetGlyphIndex(font, letter);
|
||||||
|
|
||||||
i += next;
|
i += codepointByteCount;
|
||||||
|
|
||||||
if (letter != '\n')
|
if (letter != '\n')
|
||||||
{
|
{
|
||||||
if (font.glyphs[index].advanceX != 0) textWidth += font.glyphs[index].advanceX;
|
if (font.glyphs[index].advanceX > 0) textWidth += font.glyphs[index].advanceX;
|
||||||
else textWidth += (font.recs[index].width + font.glyphs[index].offsetX);
|
else textWidth += (font.recs[index].width + font.glyphs[index].offsetX);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1930,7 +1930,8 @@ int GetCodepointCount(const char *text)
|
|||||||
const char *CodepointToUTF8(int codepoint, int *utf8Size)
|
const char *CodepointToUTF8(int codepoint, int *utf8Size)
|
||||||
{
|
{
|
||||||
static char utf8[6] = { 0 };
|
static char utf8[6] = { 0 };
|
||||||
int size = 0; // Byte size of codepoint
|
memset(utf8, 0, 6); // Clear static array
|
||||||
|
int size = 0; // Byte size of codepoint
|
||||||
|
|
||||||
if (codepoint <= 0x7f)
|
if (codepoint <= 0x7f)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user