handle whitespace + get batch vertex count
parent
e45aed1daa
commit
51a8fe333d
|
@ -174,6 +174,7 @@ WELLSPRINGAPI uint8_t Wellspring_Draw(
|
||||||
|
|
||||||
WELLSPRINGAPI void Wellspring_GetBufferData(
|
WELLSPRINGAPI void Wellspring_GetBufferData(
|
||||||
Wellspring_TextBatch *textBatch,
|
Wellspring_TextBatch *textBatch,
|
||||||
|
uint32_t* pVertexCount,
|
||||||
Wellspring_Vertex **pVertexBuffer,
|
Wellspring_Vertex **pVertexBuffer,
|
||||||
uint32_t *pVertexBufferLengthInBytes,
|
uint32_t *pVertexBufferLengthInBytes,
|
||||||
uint32_t **pIndexBuffer,
|
uint32_t **pIndexBuffer,
|
||||||
|
|
|
@ -362,6 +362,28 @@ static float Wellspring_INTERNAL_GetVerticalAlignOffset(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline uint32_t IsWhitespace(uint32_t codepoint)
|
||||||
|
{
|
||||||
|
switch (codepoint)
|
||||||
|
{
|
||||||
|
case 0x0020:
|
||||||
|
case 0x00A0:
|
||||||
|
case 0x1680:
|
||||||
|
case 0x202F:
|
||||||
|
case 0x205F:
|
||||||
|
case 0x3000:
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (codepoint > 0x2000 && codepoint <= 0x200A)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t Wellspring_TextBounds(
|
uint8_t Wellspring_TextBounds(
|
||||||
Wellspring_TextBatch* textBatch,
|
Wellspring_TextBatch* textBatch,
|
||||||
float x,
|
float x,
|
||||||
|
@ -405,6 +427,15 @@ uint8_t Wellspring_TextBounds(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsWhitespace(codepoint))
|
||||||
|
{
|
||||||
|
int32_t ws_adv, ws_bearing;
|
||||||
|
stbtt_GetCodepointHMetrics(&myPacker->font->fontInfo, codepoint, &ws_adv, &ws_bearing);
|
||||||
|
x += myPacker->scale * ws_adv;
|
||||||
|
maxX += myPacker->scale * ws_adv;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
rangeData = NULL;
|
rangeData = NULL;
|
||||||
|
|
||||||
/* Find the packed char data */
|
/* Find the packed char data */
|
||||||
|
@ -537,6 +568,14 @@ uint8_t Wellspring_Draw(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsWhitespace(codepoint))
|
||||||
|
{
|
||||||
|
int32_t ws_adv, ws_bearing;
|
||||||
|
stbtt_GetCodepointHMetrics(&myPacker->font->fontInfo, codepoint, &ws_adv, &ws_bearing);
|
||||||
|
x += myPacker->scale * ws_adv;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
rangeData = NULL;
|
rangeData = NULL;
|
||||||
|
|
||||||
/* Find the packed char data */
|
/* Find the packed char data */
|
||||||
|
@ -652,12 +691,14 @@ uint8_t Wellspring_Draw(
|
||||||
|
|
||||||
void Wellspring_GetBufferData(
|
void Wellspring_GetBufferData(
|
||||||
Wellspring_TextBatch *textBatch,
|
Wellspring_TextBatch *textBatch,
|
||||||
|
uint32_t *pVertexCount,
|
||||||
Wellspring_Vertex **pVertexBuffer,
|
Wellspring_Vertex **pVertexBuffer,
|
||||||
uint32_t *pVertexBufferLengthInBytes,
|
uint32_t *pVertexBufferLengthInBytes,
|
||||||
uint32_t **pIndexBuffer,
|
uint32_t **pIndexBuffer,
|
||||||
uint32_t *pIndexBufferLengthInBytes
|
uint32_t *pIndexBufferLengthInBytes
|
||||||
) {
|
) {
|
||||||
Batch *batch = (Batch*) textBatch;
|
Batch *batch = (Batch*) textBatch;
|
||||||
|
*pVertexCount = batch->vertexCount;
|
||||||
*pVertexBuffer = batch->vertices;
|
*pVertexBuffer = batch->vertices;
|
||||||
*pVertexBufferLengthInBytes = batch->vertexCount * sizeof(Wellspring_Vertex);
|
*pVertexBufferLengthInBytes = batch->vertexCount * sizeof(Wellspring_Vertex);
|
||||||
*pIndexBuffer = batch->indices;
|
*pIndexBuffer = batch->indices;
|
||||||
|
|
Loading…
Reference in New Issue