mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-21 05:38:04 +00:00
Compare commits
4 Commits
da381445c5
...
02cbfba4d7
Author | SHA1 | Date | |
---|---|---|---|
|
02cbfba4d7 | ||
|
5391a259f3 | ||
|
fe2d44a888 | ||
|
d7e072fe25 |
@ -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);
|
||||||
@ -157,7 +163,7 @@ void Clay_Raylib_Render(Clay_RenderCommandArray renderCommands, Font* fonts)
|
|||||||
if(strlen > temp_render_buffer_len) {
|
if(strlen > temp_render_buffer_len) {
|
||||||
// Grow the temp buffer if we need a larger string
|
// Grow the temp buffer if we need a larger string
|
||||||
if(temp_render_buffer) free(temp_render_buffer);
|
if(temp_render_buffer) free(temp_render_buffer);
|
||||||
temp_render_buffer = malloc(strlen);
|
temp_render_buffer = (char *) malloc(strlen);
|
||||||
temp_render_buffer_len = strlen;
|
temp_render_buffer_len = strlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +231,7 @@ void Clay_Raylib_Render(Clay_RenderCommandArray renderCommands, Font* fonts)
|
|||||||
DrawRing((Vector2) { roundf(boundingBox.x + boundingBox.width - config->cornerRadius.topRight), roundf(boundingBox.y + config->cornerRadius.topRight) }, roundf(config->cornerRadius.topRight - config->width.top), config->cornerRadius.topRight, 270, 360, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
DrawRing((Vector2) { roundf(boundingBox.x + boundingBox.width - config->cornerRadius.topRight), roundf(boundingBox.y + config->cornerRadius.topRight) }, roundf(config->cornerRadius.topRight - config->width.top), config->cornerRadius.topRight, 270, 360, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||||
}
|
}
|
||||||
if (config->cornerRadius.bottomLeft > 0) {
|
if (config->cornerRadius.bottomLeft > 0) {
|
||||||
DrawRing((Vector2) { roundf(boundingBox.x + config->cornerRadius.bottomLeft), roundf(boundingBox.y + boundingBox.height - config->cornerRadius.bottomLeft) }, roundf(config->cornerRadius.bottomLeft - config->width.top), config->cornerRadius.bottomLeft, 90, 180, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
DrawRing((Vector2) { roundf(boundingBox.x + config->cornerRadius.bottomLeft), roundf(boundingBox.y + boundingBox.height - config->cornerRadius.bottomLeft) }, roundf(config->cornerRadius.bottomLeft - config->width.bottom), config->cornerRadius.bottomLeft, 90, 180, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||||
}
|
}
|
||||||
if (config->cornerRadius.bottomRight > 0) {
|
if (config->cornerRadius.bottomRight > 0) {
|
||||||
DrawRing((Vector2) { roundf(boundingBox.x + boundingBox.width - config->cornerRadius.bottomRight), roundf(boundingBox.y + boundingBox.height - config->cornerRadius.bottomRight) }, roundf(config->cornerRadius.bottomRight - config->width.bottom), config->cornerRadius.bottomRight, 0.1, 90, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
DrawRing((Vector2) { roundf(boundingBox.x + boundingBox.width - config->cornerRadius.bottomRight), roundf(boundingBox.y + boundingBox.height - config->cornerRadius.bottomRight) }, roundf(config->cornerRadius.bottomRight - config->width.bottom), config->cornerRadius.bottomRight, 0.1, 90, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||||
|
Loading…
Reference in New Issue
Block a user