Some formatting tweaks
This commit is contained in:
parent
9a7d4ccb79
commit
d21422687a
2 changed files with 60 additions and 41 deletions
61
src/text.c
61
src/text.c
|
@ -686,10 +686,8 @@ void UnloadFont(Font font)
|
||||||
// NOTE: Make sure spriteFont is not default font (fallback)
|
// NOTE: Make sure spriteFont is not default font (fallback)
|
||||||
if (font.texture.id != GetFontDefault().texture.id)
|
if (font.texture.id != GetFontDefault().texture.id)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < font.charsCount; i++)
|
for (int i = 0; i < font.charsCount; i++) RL_FREE(font.chars[i].data);
|
||||||
{
|
|
||||||
RL_FREE(font.chars[i].data);
|
|
||||||
}
|
|
||||||
UnloadTexture(font.texture);
|
UnloadTexture(font.texture);
|
||||||
RL_FREE(font.chars);
|
RL_FREE(font.chars);
|
||||||
|
|
||||||
|
@ -753,8 +751,10 @@ int GetNextCodepoint(const char* text, int* count)
|
||||||
// Two octets
|
// Two octets
|
||||||
// [0]xC2-DF [1]UTF8-tail(x80-BF)
|
// [0]xC2-DF [1]UTF8-tail(x80-BF)
|
||||||
unsigned char o1 = text[1];
|
unsigned char o1 = text[1];
|
||||||
if(o1 == '\0' || (o1 >> 6) != 2 ) {*count = 2; return c; } // Unexpected sequence
|
|
||||||
if(o >= 0xc2 && o <= 0xdf)
|
if ((o1 == '\0') || ((o1 >> 6) != 2)) { *count = 2; return c; } // Unexpected sequence
|
||||||
|
|
||||||
|
if ((o >= 0xc2) && (o <= 0xdf))
|
||||||
{
|
{
|
||||||
c = ((o & 0x1f) << 6) | (o1 & 0x3f);
|
c = ((o & 0x1f) << 6) | (o1 & 0x3f);
|
||||||
*count = 2;
|
*count = 2;
|
||||||
|
@ -763,19 +763,26 @@ int GetNextCodepoint(const char* text, int* count)
|
||||||
else if ((o & 0xf0) == 0xe0)
|
else if ((o & 0xf0) == 0xe0)
|
||||||
{
|
{
|
||||||
// Three octets
|
// Three octets
|
||||||
unsigned char o1 = text[1], o2 = '\0';
|
unsigned char o1 = text[1];
|
||||||
if(o1 == '\0' || (o1 >> 6) != 2) { *count = 2; return c; } // Unexpected sequence
|
unsigned char o2 = '\0';
|
||||||
o2 = text[2];
|
|
||||||
if(o2 == '\0' || (o2 >> 6) != 2) {*count = 3; return c; } // Unexpected sequence
|
|
||||||
|
|
||||||
/* [0]xE0 [1]xA0-BF [2]UTF8-tail(x80-BF)
|
if ((o1 == '\0') || ((o1 >> 6) != 2)) { *count = 2; return c; } // Unexpected sequence
|
||||||
|
|
||||||
|
o2 = text[2];
|
||||||
|
|
||||||
|
if ((o2 == '\0') || ((o2 >> 6) != 2)) { *count = 3; return c; } // Unexpected sequence
|
||||||
|
|
||||||
|
/*
|
||||||
|
[0]xE0 [1]xA0-BF [2]UTF8-tail(x80-BF)
|
||||||
[0]xE1-EC [1]UTF8-tail [2]UTF8-tail(x80-BF)
|
[0]xE1-EC [1]UTF8-tail [2]UTF8-tail(x80-BF)
|
||||||
[0]xED [1]x80-9F [2]UTF8-tail(x80-BF)
|
[0]xED [1]x80-9F [2]UTF8-tail(x80-BF)
|
||||||
[0]xEE-EF [1]UTF8-tail [2]UTF8-tail(x80-BF)
|
[0]xEE-EF [1]UTF8-tail [2]UTF8-tail(x80-BF)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if((o == 0xe0 && !(o1 >= 0xa0 && o1 <= 0xbf)) || (o == 0xed && !(o1 >= 0x80 && o1 <= 0x9f)) ) {*count = 2; return c;}
|
if (((o == 0xe0) && !((o1 >= 0xa0) && (o1 <= 0xbf))) ||
|
||||||
if(o >= 0xe0 && 0 <= 0xef)
|
((o == 0xed) && !((o1 >= 0x80) && (o1 <= 0x9f)))) { *count = 2; return c; }
|
||||||
|
|
||||||
|
if ((o >= 0xe0) && (0 <= 0xef))
|
||||||
{
|
{
|
||||||
c = ((o & 0xf) << 12) | ((o1 & 0x3f) << 6) | (o2 & 0x3f);
|
c = ((o & 0xf) << 12) | ((o1 & 0x3f) << 6) | (o2 & 0x3f);
|
||||||
*count = 3;
|
*count = 3;
|
||||||
|
@ -786,18 +793,29 @@ int GetNextCodepoint(const char* text, int* count)
|
||||||
// Four octets
|
// Four octets
|
||||||
if (o > 0xf4) return c;
|
if (o > 0xf4) return c;
|
||||||
|
|
||||||
unsigned char o1 = text[1], o2 = '\0', o3 = '\0';
|
unsigned char o1 = text[1];
|
||||||
if(o1 == '\0' || (o1 >> 6) != 2) { *count = 2; return c; } // Unexpected sequence
|
unsigned char o2 = '\0';
|
||||||
o2 = text[2];
|
unsigned char o3 = '\0';
|
||||||
if(o2 == '\0' || (o2 >> 6) != 2) { *count = 3; return c; } // Unexpected sequence
|
|
||||||
o3 = text[3];
|
|
||||||
if(o3 == '\0' || (o3 >> 6) != 2) { *count = 4; return c; } // Unexpected sequence
|
|
||||||
|
|
||||||
/* [0]xF0 [1]x90-BF [2]UTF8-tail [3]UTF8-tail
|
if ((o1 == '\0') || ((o1 >> 6) != 2)) { *count = 2; return c; } // Unexpected sequence
|
||||||
|
|
||||||
|
o2 = text[2];
|
||||||
|
|
||||||
|
if ((o2 == '\0') || ((o2 >> 6) != 2)) { *count = 3; return c; } // Unexpected sequence
|
||||||
|
|
||||||
|
o3 = text[3];
|
||||||
|
|
||||||
|
if ((o3 == '\0') || ((o3 >> 6) != 2)) { *count = 4; return c; } // Unexpected sequence
|
||||||
|
|
||||||
|
/*
|
||||||
|
[0]xF0 [1]x90-BF [2]UTF8-tail [3]UTF8-tail
|
||||||
[0]xF1-F3 [1]UTF8-tail [2]UTF8-tail [3]UTF8-tail
|
[0]xF1-F3 [1]UTF8-tail [2]UTF8-tail [3]UTF8-tail
|
||||||
[0]xF4 [1]x80-8F [2]UTF8-tail [3]UTF8-tail
|
[0]xF4 [1]x80-8F [2]UTF8-tail [3]UTF8-tail
|
||||||
*/
|
*/
|
||||||
if((o == 0xf0 && !(o1 >= 0x90 && o1 <= 0xbf)) || (o == 0xf4 && !( o1 >= 0x80 && o1 <= 0x8f)) ) { *count = 2; return c; } // Unexpected sequence
|
|
||||||
|
if (((o == 0xf0) && !((o1 >= 0x90) && (o1 <= 0xbf))) ||
|
||||||
|
((o == 0xf4) && !((o1 >= 0x80) && (o1 <= 0x8f)))) { *count = 2; return c; } // Unexpected sequence
|
||||||
|
|
||||||
if (o >= 0xf0)
|
if (o >= 0xf0)
|
||||||
{
|
{
|
||||||
c = ((o & 0x7) << 18) | ((o1 & 0x3f) << 12) | ((o2 & 0x3f) << 6) | (o3 & 0x3f);
|
c = ((o & 0x7) << 18) | ((o1 & 0x3f) << 12) | ((o2 & 0x3f) << 6) | (o3 & 0x3f);
|
||||||
|
@ -806,6 +824,7 @@ int GetNextCodepoint(const char* text, int* count)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c > 0x10ffff) c = 0x3f; // Codepoints after U+10ffff are invalid
|
if (c > 0x10ffff) c = 0x3f; // Codepoints after U+10ffff are invalid
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -746,7 +746,7 @@ Image GetTextureData(Texture2D texture)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get pixel data from GPU frontbuffer and return an Image (screenshot)
|
// Get pixel data from GPU frontbuffer and return an Image (screenshot)
|
||||||
RLAPI Image GetScreenData(void)
|
Image GetScreenData(void)
|
||||||
{
|
{
|
||||||
Image image = { 0 };
|
Image image = { 0 };
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue