Corrected several issues...

This commit is contained in:
Ray 2018-01-28 16:52:18 +01:00
parent f955b2255d
commit 1ce8c80de9
2 changed files with 14 additions and 16 deletions

View File

@ -66,8 +66,8 @@
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
#define MAX_FORMATTEXT_LENGTH 64
#define MAX_SUBTEXT_LENGTH 64
#define MAX_FORMATTEXT_LENGTH 256
#define MAX_SUBTEXT_LENGTH 256
//----------------------------------------------------------------------------------
// Types and Structures Definition
@ -318,21 +318,20 @@ SpriteFont LoadSpriteFont(const char *fileName)
SpriteFont LoadSpriteFontEx(const char *fileName, int fontSize, int charsCount, int *fontChars)
{
SpriteFont spriteFont = { 0 };
int totalChars = 95; // Default charset [32..126]
#if defined(SUPPORT_FILEFORMAT_TTF)
if (IsFileExtension(fileName, ".ttf"))
{
if ((fontChars == NULL) || (charsCount == 0))
if (charsCount != 0) totalChars = charsCount;
if (fontChars == NULL)
{
int totalChars = 95; // Default charset [32..126]
int *defaultFontChars = (int *)malloc(totalChars*sizeof(int));
for (int i = 0; i < totalChars; i++) defaultFontChars[i] = i + 32; // Default first character: SPACE[32]
spriteFont = LoadTTF(fileName, fontSize, totalChars, defaultFontChars);
fontChars = (int *)malloc(totalChars*sizeof(int));
for (int i = 0; i < totalChars; i++) fontChars[i] = i + 32; // Default first character: SPACE[32]
}
else spriteFont = LoadTTF(fileName, fontSize, charsCount, fontChars);
spriteFont = LoadTTF(fileName, fontSize, totalChars, fontChars);
}
#endif

View File

@ -1377,12 +1377,11 @@ Image ImageTextEx(SpriteFont font, const char *text, float fontSize, int spacing
Vector2 imSize = MeasureTextEx(font, text, font.baseSize, spacing);
TraceLog(LOG_WARNING, "Text Image size: %f, %f", imSize.x, imSize.y);
TraceLog(LOG_DEBUG, "Text Image size: %f, %f", imSize.x, imSize.y);
// NOTE: glGetTexImage() not available in OpenGL ES
Image imFont = GetTextureData(font.texture);
ImageFormat(&imFont, UNCOMPRESSED_R8G8B8A8); // Convert to 32 bit for color tint
ImageColorTint(&imFont, tint); // Apply color tint to font
// Create image to store text
@ -1405,7 +1404,7 @@ Image ImageTextEx(SpriteFont font, const char *text, float fontSize, int spacing
if (fontSize > imSize.y)
{
float scaleFactor = fontSize/imSize.y;
TraceLog(LOG_INFO, "Scalefactor: %f", scaleFactor);
TraceLog(LOG_INFO, "Image text scaled by factor: %f", scaleFactor);
// Using nearest-neighbor scaling algorithm for default font
if (font.texture.id == GetDefaultFont().texture.id) ImageResizeNN(&imText, (int)(imSize.x*scaleFactor), (int)(imSize.y*scaleFactor));