Working on line clamping in vn text box

This commit is contained in:
2021-07-18 14:09:44 -07:00
parent f619b7c9d2
commit 027907d5a4
4 changed files with 58 additions and 31 deletions

View File

@ -163,4 +163,17 @@ void fontTextClamp(font_t *font, fonttextinfo_t *info, char *text,
info->width = mathMax(info->width, quad->x1);
info->height = mathMax(info->height, quad->y1);
}
}
int32_t fontGetLineCharCount(fonttextinfo_t *info,int32_t start,int32_t count) {
int32_t charCount, i, m;
m = mathMin(start+count, info->lineCount);
charCount = 0;
for(i = start; i < m; i++) {
charCount += info->lines[i].length;
}
return charCount;
}

View File

@ -56,4 +56,15 @@ void fontTextInit(font_t *font, primitive_t *primitive, fonttextinfo_t *info);
*/
void fontTextClamp(font_t *font, fonttextinfo_t *info, char *text,
float maxWidth
);
);
/**
* Returns the number of real characters on the lines specified. Useful when
* attempting to clamp to a set of lines.
*
* @param info Info to get the character counts from.
* @param start Starting line index.
* @param count Count of lines, this method will clamp to info's line length.
* @returns The count of characters in those lines summed.
*/
int32_t fontGetLineCharCount(fonttextinfo_t *info, int32_t start,int32_t count);