Esempio n. 1
0
int textGetStringWidth(TEXT_FONT *font, const char *string) {
	int i, w;
	unsigned int glyph;

	for (i = w = 0; string[i] != 0; ) {
		glyph = utf8GetChar(&string[i]);
		i += utf8GetValidatedCharLength(&string[i]);
		w += textGetGlyphWidth(font, glyph);
	}

	return w;
}
Esempio n. 2
0
int textThisManyGlyphsWillFit(TEXT_SURFACE *surface, const char *str, unsigned int width) {
	int i, k;
	float j;
	unsigned int glyph;

	for (i = j = k = 0; str[i] != 0; k++) {
		glyph = utf8GetChar(&str[i]);
		j += textGetGlyphWidthf(surface->font, glyph);
		if (j > width)
			return k;
		i += utf8GetValidatedCharLength(&str[i]);
	}

	return k;
}
Esempio n. 3
0
int textStringWordLength(TEXT_FONT *font, const char *string, int *bytes) {
	int i, w;
	unsigned int glyph;
	
	if (bytes)
		*bytes = 0;
	if (!font)
		return 0;

	for (i = w = 0; string[i] != 0 && string[i] != ' ' && string[i] != '\n';) {
		glyph = utf8GetChar(&string[i]);
		i += utf8GetValidatedCharLength(&string[i]);
		w += textGetGlyphWidth(font, glyph);
	}
	
	if (bytes)
		*bytes = i;
	return w;
}
Esempio n. 4
0
int textStringBytesOnLine(TEXT_FONT *font, const char *string, int linelen, int *w_m) {
	int i, w;
	unsigned int glyph;

	if (!font)
		return 0;
	
	for (i = w = 0; string[i] != 0;) {
		glyph = utf8GetChar(&string[i]);
		if (textGetGlyphWidth(font, glyph) + w > linelen) {
			*w_m = w;
			return i;
		}
		w += textGetGlyphWidth(font, glyph);
		i += utf8GetValidatedCharLength(&string[i]);
	}

	*w_m = w;
	return i;
}
Esempio n. 5
0
unsigned int EXPORT_THIS d_font_glyph_w(void *font, const char *s) {
	unsigned int c;
	
	c = utf8GetChar(s);
	return textGetGlyphWidth(font, c);
}