mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-15 10:48:04 +00:00
Merge d7e072fe25
into 06167b4f4b
This commit is contained in:
commit
da381445c5
@ -99,16 +99,22 @@ static inline Clay_Dimensions Raylib_MeasureText(Clay_StringSlice text, Clay_Tex
|
|||||||
|
|
||||||
float scaleFactor = config->fontSize/(float)fontToUse.baseSize;
|
float scaleFactor = config->fontSize/(float)fontToUse.baseSize;
|
||||||
|
|
||||||
for (int i = 0; i < text.length; ++i)
|
int byte_index = 0;
|
||||||
{
|
while (byte_index < text.length) {
|
||||||
if (text.chars[i] == '\n') {
|
if (text.chars[byte_index] == '\n') {
|
||||||
maxTextWidth = fmax(maxTextWidth, lineTextWidth);
|
maxTextWidth = fmax(maxTextWidth, lineTextWidth);
|
||||||
lineTextWidth = 0;
|
lineTextWidth = 0;
|
||||||
|
byte_index++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int index = text.chars[i] - 32;
|
|
||||||
if (fontToUse.glyphs[index].advanceX != 0) lineTextWidth += fontToUse.glyphs[index].advanceX;
|
int codepoint_bytes = 0;
|
||||||
else lineTextWidth += (fontToUse.recs[index].width + fontToUse.glyphs[index].offsetX);
|
int codepoint = GetCodepoint(&text.chars[byte_index], &codepoint_bytes);
|
||||||
|
int glyph_index = GetGlyphIndex(fontToUse, codepoint);
|
||||||
|
byte_index += codepoint_bytes;
|
||||||
|
|
||||||
|
if (fontToUse.glyphs[glyph_index].advanceX != 0) lineTextWidth += fontToUse.glyphs[glyph_index].advanceX;
|
||||||
|
else lineTextWidth += (fontToUse.recs[glyph_index].width + fontToUse.glyphs[glyph_index].offsetX);
|
||||||
}
|
}
|
||||||
|
|
||||||
maxTextWidth = fmax(maxTextWidth, lineTextWidth);
|
maxTextWidth = fmax(maxTextWidth, lineTextWidth);
|
||||||
|
Loading…
Reference in New Issue
Block a user