mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-22 06:08:03 +00:00
Compare commits
4 Commits
02cbfba4d7
...
83b69cba59
Author | SHA1 | Date | |
---|---|---|---|
|
83b69cba59 | ||
|
b33ba4ff62 | ||
|
f88f0517f7 | ||
|
d7e072fe25 |
12
README.md
12
README.md
@ -1787,7 +1787,8 @@ Note: when using the debug tools, their internal colors are represented as 0-255
|
|||||||
|
|
||||||
```C
|
```C
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int length;
|
bool isStaticallyAllocated;
|
||||||
|
int32_t length;
|
||||||
const char *chars;
|
const char *chars;
|
||||||
} Clay_String;
|
} Clay_String;
|
||||||
```
|
```
|
||||||
@ -1796,7 +1797,14 @@ typedef struct {
|
|||||||
|
|
||||||
**Fields**
|
**Fields**
|
||||||
|
|
||||||
**`.length`** - `int`
|
**`.isStaticallyAllocated`** - `bool`
|
||||||
|
|
||||||
|
Whether or not the string is statically allocated, or in other words, whether
|
||||||
|
or not it lives for the entire lifetime of the program.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**`.length`** - `int32_t`
|
||||||
|
|
||||||
The number of characters in the string, _not including an optional null terminator._
|
The number of characters in the string, _not including an optional null terminator._
|
||||||
|
|
||||||
|
2
clay.h
2
clay.h
@ -1392,6 +1392,7 @@ uint64_t Clay__HashData(const uint8_t* data, size_t length) {
|
|||||||
Clay__SIMDARXMix(&v2, &v3);
|
Clay__SIMDARXMix(&v2, &v3);
|
||||||
v0 = _mm_add_epi64(v0, v2);
|
v0 = _mm_add_epi64(v0, v2);
|
||||||
v1 = _mm_add_epi64(v1, v3);
|
v1 = _mm_add_epi64(v1, v3);
|
||||||
|
v0 = _mm_add_epi64(v0, v1);
|
||||||
|
|
||||||
uint64_t result[2];
|
uint64_t result[2];
|
||||||
_mm_storeu_si128((__m128i*)result, v0);
|
_mm_storeu_si128((__m128i*)result, v0);
|
||||||
@ -1445,6 +1446,7 @@ uint64_t Clay__HashData(const uint8_t* data, size_t length) {
|
|||||||
Clay__SIMDARXMix(&v2, &v3);
|
Clay__SIMDARXMix(&v2, &v3);
|
||||||
v0 = vaddq_u64(v0, v2);
|
v0 = vaddq_u64(v0, v2);
|
||||||
v1 = vaddq_u64(v1, v3);
|
v1 = vaddq_u64(v1, v3);
|
||||||
|
v0 = vaddq_u64(v0, v1);
|
||||||
|
|
||||||
uint64_t result[2];
|
uint64_t result[2];
|
||||||
vst1q_u64(result, v0);
|
vst1q_u64(result, v0);
|
||||||
|
@ -22,7 +22,7 @@ FetchContent_MakeAvailable(fontstash)
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
sokol
|
sokol
|
||||||
GIT_REPOSITORY "https://github.com/floooh/sokol.git"
|
GIT_REPOSITORY "https://github.com/floooh/sokol.git"
|
||||||
GIT_TAG "da9de496f938b7575eff7f01ab774d77469bd390"
|
GIT_TAG "master"
|
||||||
GIT_PROGRESS TRUE
|
GIT_PROGRESS TRUE
|
||||||
GIT_SHALLOW TRUE
|
GIT_SHALLOW TRUE
|
||||||
)
|
)
|
||||||
|
@ -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