Corrected issue with types
This commit is contained in:
parent
57dfe55759
commit
d0608b031a
12
src/text.c
12
src/text.c
@ -221,7 +221,7 @@ extern void LoadDefaultFont(void)
|
|||||||
defaultFont.chars[i].value = 32 + i; // First char is 32
|
defaultFont.chars[i].value = 32 + i; // First char is 32
|
||||||
|
|
||||||
defaultFont.chars[i].rec.x = (float)currentPosX;
|
defaultFont.chars[i].rec.x = (float)currentPosX;
|
||||||
defaultFont.chars[i].rec.y = (float)charsDivisor + currentLine*(charsHeight + charsDivisor);
|
defaultFont.chars[i].rec.y = (float)(charsDivisor + currentLine*(charsHeight + charsDivisor));
|
||||||
defaultFont.chars[i].rec.width = (float)charsWidth[i];
|
defaultFont.chars[i].rec.width = (float)charsWidth[i];
|
||||||
defaultFont.chars[i].rec.height = (float)charsHeight;
|
defaultFont.chars[i].rec.height = (float)charsHeight;
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ extern void LoadDefaultFont(void)
|
|||||||
testPosX = currentPosX;
|
testPosX = currentPosX;
|
||||||
|
|
||||||
defaultFont.chars[i].rec.x = (float)charsDivisor;
|
defaultFont.chars[i].rec.x = (float)charsDivisor;
|
||||||
defaultFont.chars[i].rec.y = (float)charsDivisor + currentLine*(charsHeight + charsDivisor);
|
defaultFont.chars[i].rec.y = (float)(charsDivisor + currentLine*(charsHeight + charsDivisor));
|
||||||
}
|
}
|
||||||
else currentPosX = testPosX;
|
else currentPosX = testPosX;
|
||||||
|
|
||||||
@ -367,8 +367,6 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c
|
|||||||
// NOTE: ascent is equivalent to font baseline
|
// NOTE: ascent is equivalent to font baseline
|
||||||
int ascent, descent, lineGap;
|
int ascent, descent, lineGap;
|
||||||
stbtt_GetFontVMetrics(&fontInfo, &ascent, &descent, &lineGap);
|
stbtt_GetFontVMetrics(&fontInfo, &ascent, &descent, &lineGap);
|
||||||
ascent *= (int) scaleFactor;
|
|
||||||
descent *= (int) scaleFactor;
|
|
||||||
|
|
||||||
// Fill fontChars in case not provided externally
|
// Fill fontChars in case not provided externally
|
||||||
// NOTE: By default we fill charsCount consecutevely, starting at 32 (Space)
|
// NOTE: By default we fill charsCount consecutevely, starting at 32 (Space)
|
||||||
@ -397,17 +395,17 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c
|
|||||||
|
|
||||||
chars[i].rec.width = (float)chw;
|
chars[i].rec.width = (float)chw;
|
||||||
chars[i].rec.height = (float)chh;
|
chars[i].rec.height = (float)chh;
|
||||||
chars[i].offsetY += ascent;
|
chars[i].offsetY += (int)((float)ascent*scaleFactor);
|
||||||
|
|
||||||
// Get bounding box for character (may be offset to account for chars that dip above or below the line)
|
// Get bounding box for character (may be offset to account for chars that dip above or below the line)
|
||||||
int chX1, chY1, chX2, chY2;
|
int chX1, chY1, chX2, chY2;
|
||||||
stbtt_GetCodepointBitmapBox(&fontInfo, ch, scaleFactor, scaleFactor, &chX1, &chY1, &chX2, &chY2);
|
stbtt_GetCodepointBitmapBox(&fontInfo, ch, scaleFactor, scaleFactor, &chX1, &chY1, &chX2, &chY2);
|
||||||
|
|
||||||
TraceLog(LOG_DEBUG, "Character box measures: %i, %i, %i, %i", chX1, chY1, chX2 - chX1, chY2 - chY1);
|
TraceLog(LOG_DEBUG, "Character box measures: %i, %i, %i, %i", chX1, chY1, chX2 - chX1, chY2 - chY1);
|
||||||
TraceLog(LOG_DEBUG, "Character offsetY: %i", ascent + chY1);
|
TraceLog(LOG_DEBUG, "Character offsetY: %i", (int)((float)ascent*scaleFactor) + chY1);
|
||||||
|
|
||||||
stbtt_GetCodepointHMetrics(&fontInfo, ch, &chars[i].advanceX, NULL);
|
stbtt_GetCodepointHMetrics(&fontInfo, ch, &chars[i].advanceX, NULL);
|
||||||
chars[i].advanceX *= (int) scaleFactor;
|
chars[i].advanceX *= scaleFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(fontBuffer);
|
free(fontBuffer);
|
||||||
|
Loading…
Reference in New Issue
Block a user