Ejemplo n.º 1
0
int textStringGeometrics(TEXT_FONT *font, const char *string, int linelen, int *w_set) {
	int j,  w, w_max, t, b;

	if (!font)
		return 0;
	w_max = 0;
	w = *w_set;
	for (j = 0; *string; j++, w = 0) {
		for (; *string != 0 && *string != '\n';) {
			t = textStringWordLength(font, string, &b);
			if (t + w >= linelen) {
				if (w > 0)
					break;
				else 
					b = textStringBytesOnLine(font, string, linelen, &t);
			}

			string += b;
			w += t;

			if (*string == ' ') {
				if (textGetGlyphWidth(font, ' ') + w >= linelen) {
					string++;
					break;
				}

				w += textGetGlyphWidth(font, ' ');
				string++;
			}
		}
		if (w == 0 && *string != '\n') {	// We can't fit a single glyph. Meh. //
			*w_set = 0;
			return 0;
		}
			
		if (w > w_max)
			w_max = w;
		if (*string == '\n')
			string++;
	}

	if (w_set)
		*w_set = w_max;
	return j * textFontGetHS(font);
}
Ejemplo n.º 2
0
unsigned int EXPORT_THIS d_font_glyph_hs(void *font) {
	return textFontGetHS(font);
}