Code style
This commit is contained in:
parent
7d9d0a2772
commit
c756ac46bc
37
src/rtext.c
37
src/rtext.c
|
|
@ -381,20 +381,47 @@ Font LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepoi
|
|||
// Reload the font after adding the new characters to the list of desired characters
|
||||
void AddNewCharsToFontEx(Font *font, const char *fileName, int fontSize, char *newChars)
|
||||
{
|
||||
// Get the codepoints of the newChars
|
||||
int codepointCount = 0;
|
||||
int *codepoints = LoadCodepoints(newChars, &codepointCount);
|
||||
|
||||
// Maximum value of the number of codepoints in the updated Font
|
||||
int newCount = font->glyphCount + codepointCount;
|
||||
|
||||
// Allocate space for the new codepoints and populate it
|
||||
int *newCodepoints = MemAlloc(newCount * sizeof(int));
|
||||
for (int i=0; i<font->glyphCount; i++) {
|
||||
|
||||
int codepointCountWithNoDupes = 0; // We don't need to assign chars that already exist in the Font
|
||||
for (int i = 0; i < font->glyphCount; i++)
|
||||
{
|
||||
newCodepoints[i] = font->glyphs[i].value;
|
||||
}
|
||||
for (int i=font->glyphCount; i<newCount; i++) {
|
||||
newCodepoints[i] = codepoints[i-font->glyphCount];
|
||||
codepointCountWithNoDupes += 1;
|
||||
}
|
||||
|
||||
*font = LoadFontEx(fileName, fontSize, newCodepoints, newCount);
|
||||
for (int i = font->glyphCount; i < newCount; i++)
|
||||
{
|
||||
bool codepointIsUnique = true;
|
||||
int cp = codepoints[i-font->glyphCount];
|
||||
|
||||
// This loop checks for the existence for the existence of the newChars in the input Font
|
||||
for (int j = 0; j < font->glyphCount; j++)
|
||||
{
|
||||
if (cp == font->glyphs[j].value)
|
||||
{
|
||||
codepointIsUnique = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (codepointIsUnique)
|
||||
{
|
||||
newCodepoints[codepointCountWithNoDupes] = cp;
|
||||
codepointCountWithNoDupes += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Unload the Font and then reassign the newly built Font
|
||||
UnloadFont(*font);
|
||||
*font = LoadFontEx(fileName, fontSize, newCodepoints, codepointCountWithNoDupes);
|
||||
|
||||
MemFree(newCodepoints);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user