Merge pull request #3301 from KasinSparks/freetype-outline-shadow-bounds-calc
text-freetype2: Fix x,y bounds for text outline and shadowmaster
commit
d229a56dab
|
@ -125,14 +125,14 @@ static uint32_t ft2_source_get_width(void *data)
|
|||
{
|
||||
struct ft2_source *srcdata = data;
|
||||
|
||||
return srcdata->cx;
|
||||
return srcdata->cx + srcdata->outline_width;
|
||||
}
|
||||
|
||||
static uint32_t ft2_source_get_height(void *data)
|
||||
{
|
||||
struct ft2_source *srcdata = data;
|
||||
|
||||
return srcdata->cy;
|
||||
return srcdata->cy + srcdata->outline_width;
|
||||
}
|
||||
|
||||
static obs_properties_t *ft2_source_properties(void *unused)
|
||||
|
@ -325,8 +325,16 @@ static void ft2_source_update(void *data, obs_data_t *settings)
|
|||
if (!font_obj)
|
||||
return;
|
||||
|
||||
srcdata->outline_width = 0;
|
||||
|
||||
srcdata->drop_shadow = obs_data_get_bool(settings, "drop_shadow");
|
||||
srcdata->outline_text = obs_data_get_bool(settings, "outline");
|
||||
|
||||
if (srcdata->outline_text && srcdata->drop_shadow)
|
||||
srcdata->outline_width = 6;
|
||||
else if (srcdata->outline_text || srcdata->drop_shadow)
|
||||
srcdata->outline_width = 4;
|
||||
|
||||
word_wrap = obs_data_get_bool(settings, "word_wrap");
|
||||
|
||||
color[0] = (uint32_t)obs_data_get_int(settings, "color1");
|
||||
|
|
|
@ -45,6 +45,7 @@ struct ft2_source {
|
|||
uint64_t last_checked;
|
||||
|
||||
uint32_t cx, cy, max_h, custom_width;
|
||||
uint32_t outline_width;
|
||||
uint32_t texbuf_x, texbuf_y;
|
||||
uint32_t color[2];
|
||||
uint32_t *colorbuf;
|
||||
|
|
|
@ -162,8 +162,14 @@ void fill_vertex_buffer(struct ft2_source *srcdata)
|
|||
|
||||
uint32_t dx = 0, dy = srcdata->max_h, max_y = dy;
|
||||
uint32_t cur_glyph = 0;
|
||||
uint32_t offset = 0;
|
||||
size_t len = wcslen(srcdata->text);
|
||||
|
||||
if (srcdata->outline_text) {
|
||||
offset = 2;
|
||||
dx = offset;
|
||||
}
|
||||
|
||||
if (srcdata->colorbuf != NULL) {
|
||||
bfree(srcdata->colorbuf);
|
||||
srcdata->colorbuf = NULL;
|
||||
|
@ -178,7 +184,7 @@ void fill_vertex_buffer(struct ft2_source *srcdata)
|
|||
add_linebreak:;
|
||||
if (srcdata->text[i] != L'\n')
|
||||
goto draw_glyph;
|
||||
dx = 0;
|
||||
dx = offset;
|
||||
i++;
|
||||
dy += srcdata->max_h + 4;
|
||||
if (i == wcslen(srcdata->text))
|
||||
|
@ -199,7 +205,7 @@ void fill_vertex_buffer(struct ft2_source *srcdata)
|
|||
goto skip_custom_width;
|
||||
|
||||
if (dx + src_glyph->xadv > srcdata->custom_width) {
|
||||
dx = 0;
|
||||
dx = offset;
|
||||
dy += srcdata->max_h + 4;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue