void draw_outlines(struct ft2_source *srcdata)
{
	// Horrible (hopefully temporary) solution for outlines.
	uint32_t *tmp;

	struct gs_vb_data *vdata = gs_vertexbuffer_get_data(srcdata->vbuf);

	if (!srcdata->text)
		return;

	tmp = vdata->colors;
	vdata->colors = srcdata->colorbuf;

	gs_matrix_push();
	for (int32_t i = 0; i < 8; i++) {
		gs_matrix_translate3f(offsets[i * 2], offsets[(i * 2) + 1],
			0.0f);
		draw_uv_vbuffer(srcdata->vbuf, srcdata->tex,
			srcdata->draw_effect,
			(uint32_t)wcslen(srcdata->text) * 6);
	}
	gs_matrix_identity();
	gs_matrix_pop();

	vdata->colors = tmp;
}
示例#2
0
void draw_drop_shadow(struct ft2_source *srcdata)
{
	// Horrible (hopefully temporary) solution for drop shadow.
	uint32_t *tmp;

	struct gs_vb_data *vdata = gs_vertexbuffer_get_data(srcdata->vbuf);
	tmp = vdata->colors;
	vdata->colors = srcdata->colorbuf;

	gs_matrix_push();
	gs_matrix_translate3f(4.0f, 4.0f, 0.0f);
	draw_uv_vbuffer(srcdata->vbuf, srcdata->tex,
		srcdata->draw_effect, (uint32_t)wcslen(srcdata->text) * 6);
	gs_matrix_identity();
	gs_matrix_pop();

	vdata->colors = tmp;
}
示例#3
0
void fill_vertex_buffer(struct ft2_source *srcdata)
{
	struct gs_vb_data *vdata = gs_vertexbuffer_get_data(srcdata->vbuf);
	if (vdata == NULL) return;
	struct vec2 *tvarray = (struct vec2 *)vdata->tvarray[0].array;
	uint32_t *col = (uint32_t *)vdata->colors;

	FT_UInt glyph_index = 0;

	uint32_t dx = 0, dy = srcdata->max_h, max_y = dy;
	uint32_t cur_glyph = 0;

	if (srcdata->colorbuf != NULL) {
		bfree(srcdata->colorbuf);
		srcdata->colorbuf = NULL;
	}
	srcdata->colorbuf = bzalloc(sizeof(uint32_t)*wcslen(srcdata->text) * 6);
	for (uint32_t i = 0; i < wcslen(srcdata->text) * 6; i++) {
		srcdata->colorbuf[i] = 0xFF000000;
	}

	for (uint32_t i = 0; i < wcslen(srcdata->text); i++) {
	add_linebreak:;
		if (srcdata->text[i] != L'\n') goto draw_glyph;
		dx = 0; i++;
		dy += srcdata->max_h + 4;
		if (i == wcslen(srcdata->text)) goto skip_glyph;
		if (srcdata->text[i] == L'\n') goto add_linebreak;
	draw_glyph:;
		// Skip filthy dual byte Windows line breaks
		if (srcdata->text[i] == L'\r') goto skip_glyph;

		glyph_index = FT_Get_Char_Index(srcdata->font_face,
			srcdata->text[i]);
		if (src_glyph == NULL)
			goto skip_glyph;

		if (srcdata->custom_width < 100) goto skip_custom_width;

		if (dx + src_glyph->xadv > srcdata->custom_width) {
			dx = 0;
			dy += srcdata->max_h + 4;
		}

	skip_custom_width:;

		set_v3_rect(vdata->points + (cur_glyph * 6),
			(float)dx + (float)src_glyph->xoff,
			(float)dy - (float)src_glyph->yoff,
			(float)src_glyph->w,
			(float)src_glyph->h);
		set_v2_uv(tvarray + (cur_glyph * 6),
			src_glyph->u,
			src_glyph->v,
			src_glyph->u2,
			src_glyph->v2);
		set_rect_colors2(col + (cur_glyph * 6),
			srcdata->color[0],
			srcdata->color[1]);
		dx += src_glyph->xadv;
		if (dy - (float)src_glyph->yoff + src_glyph->h > max_y)
			max_y = dy - src_glyph->yoff + src_glyph->h;
		cur_glyph++;
	skip_glyph:;
	}

	srcdata->cy = max_y;
}