mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 14:08:56 +00:00
textrender: Don't pass plaintext as pango markup to Pango
Otherwise e.g. & in the text will cause Pango to complain about invalid markup and render the text incorrectly. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3445>
This commit is contained in:
parent
5b1a1c41b6
commit
7af129b755
2 changed files with 22 additions and 1 deletions
|
@ -531,7 +531,10 @@ gst_text_render_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
|
||||||
|
|
||||||
/* render text */
|
/* render text */
|
||||||
GST_DEBUG ("rendering '%*s'", (gint) size, data);
|
GST_DEBUG ("rendering '%*s'", (gint) size, data);
|
||||||
pango_layout_set_markup (render->layout, (gchar *) data, size);
|
if (render->have_pango_markup)
|
||||||
|
pango_layout_set_markup (render->layout, (gchar *) data, size);
|
||||||
|
else
|
||||||
|
pango_layout_set_text (render->layout, (gchar *) data, size);
|
||||||
gst_text_render_render_pangocairo (render);
|
gst_text_render_render_pangocairo (render);
|
||||||
gst_buffer_unmap (inbuf, &map);
|
gst_buffer_unmap (inbuf, &map);
|
||||||
|
|
||||||
|
@ -630,6 +633,23 @@ gst_text_render_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case GST_EVENT_CAPS:
|
||||||
|
{
|
||||||
|
GstCaps *caps;
|
||||||
|
GstStructure *structure;
|
||||||
|
const gchar *format;
|
||||||
|
|
||||||
|
gst_event_parse_caps (event, &caps);
|
||||||
|
|
||||||
|
structure = gst_caps_get_structure (caps, 0);
|
||||||
|
format = gst_structure_get_string (structure, "format");
|
||||||
|
render->have_pango_markup = (strcmp (format, "pango-markup") == 0);
|
||||||
|
|
||||||
|
gst_event_unref (event);
|
||||||
|
ret = TRUE;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
ret = gst_pad_event_default (pad, parent, event);
|
ret = gst_pad_event_default (pad, parent, event);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -93,6 +93,7 @@ struct _GstTextRender {
|
||||||
gint ypad;
|
gint ypad;
|
||||||
|
|
||||||
GstEvent *segment_event;
|
GstEvent *segment_event;
|
||||||
|
gboolean have_pango_markup;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstTextRenderClass {
|
struct _GstTextRenderClass {
|
||||||
|
|
Loading…
Reference in a new issue