示例#1
0
void blf_font_width_and_height(
        FontBLF *font, const char *str, size_t len,
        float *r_width, float *r_height, struct ResultBLF *r_info)
{
	float xa, ya;
	rctf box;

	if (font->flags & BLF_ASPECT) {
		xa = font->aspect[0];
		ya = font->aspect[1];
	}
	else {
		xa = 1.0f;
		ya = 1.0f;
	}

	if (font->flags & BLF_WORD_WRAP) {
		blf_font_boundbox__wrap(font, str, len, &box, r_info);
	}
	else {
		blf_font_boundbox(font, str, len, &box, r_info);
	}
	*r_width  = (BLI_rctf_size_x(&box) * xa);
	*r_height = (BLI_rctf_size_y(&box) * ya);
}
示例#2
0
void BLF_boundbox_ex(
        int fontid, const char *str, size_t len, rctf *r_box,
        struct ResultBLF *r_info)
{
	FontBLF *font = blf_get(fontid);

	BLF_RESULT_CHECK_INIT(r_info);

	if (font) {
		if (font->flags & BLF_WORD_WRAP) {
			blf_font_boundbox__wrap(font, str, len, r_box, r_info);
		}
		else {
			blf_font_boundbox(font, str, len, r_box, r_info);
		}
	}
}
示例#3
0
float blf_font_height(FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info)
{
	float ya;
	rctf box;

	if (font->flags & BLF_ASPECT)
		ya = font->aspect[1];
	else
		ya = 1.0f;

	if (font->flags & BLF_WORD_WRAP) {
		blf_font_boundbox__wrap(font, str, len, &box, r_info);
	}
	else {
		blf_font_boundbox(font, str, len, &box, r_info);
	}
	return BLI_rctf_size_y(&box) * ya;
}
示例#4
0
float blf_font_width(FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info)
{
	float xa;
	rctf box;

	if (font->flags & BLF_ASPECT)
		xa = font->aspect[0];
	else
		xa = 1.0f;

	if (font->flags & BLF_WORD_WRAP) {
		blf_font_boundbox__wrap(font, str, len, &box, r_info);
	}
	else {
		blf_font_boundbox(font, str, len, &box, r_info);
	}
	return BLI_rctf_size_x(&box) * xa;
}