mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2024-12-29 13:03:36 +01:00
Added a text_length() function.
This commit is contained in:
parent
a50ae4f38a
commit
8965590b12
3 changed files with 28 additions and 1 deletions
|
@ -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.
|
||||
|
|
21
src/tales/text_length.c
Normal file
21
src/tales/text_length.c
Normal file
|
@ -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;
|
||||
}
|
2
version
2
version
|
@ -1 +1 @@
|
|||
beta-0.9-303
|
||||
beta-0.9-305
|
||||
|
|
Loading…
Reference in a new issue