forked from Lephenixnoir/gint
Added a text_length() function.
This commit is contained in:
parent
a50ae4f38a
commit
8965590b12
|
@ -97,6 +97,12 @@ typedef struct Font Font;
|
|||
*/
|
||||
void text_configure(struct Font *font, color_t operator);
|
||||
|
||||
/*
|
||||
text_length()
|
||||
Computes the length of a string using the currently configured font.
|
||||
*/
|
||||
size_t text_length(const char *str);
|
||||
|
||||
/*
|
||||
dtext()
|
||||
Prints the given string, without any analysis.
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#include <internals/tales.h>
|
||||
#include <tales.h>
|
||||
|
||||
/*
|
||||
text_length()
|
||||
Computes the length of a string using the currently configured font.
|
||||
*/
|
||||
size_t text_length(const char *str)
|
||||
{
|
||||
if(!str) return 0;
|
||||
size_t len = 0;
|
||||
|
||||
while(*str)
|
||||
{
|
||||
int index = getCharacterIndex(*str);
|
||||
len += font->glyphs[index] >> 24;
|
||||
if(*++str) len++;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
Loading…
Reference in New Issue