Commit 41070c9c authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠
Browse files

ext/cairo/gsttextoverlay.c: Implement minimal parsing of the passed pango font...

ext/cairo/gsttextoverlay.c: Implement minimal parsing of the passed pango font description string, so passing a font ...

Original commit message from CVS:
* ext/cairo/gsttextoverlay.c: (gst_text_overlay_font_init):
Implement minimal parsing of the passed pango font description
string, so passing a font size works the same as with the
pango textoverlay plugin; fixes #455086.
(Maybe we could just use pangocairo here at some point).
parent 561bfe04
2007-11-13 Tim-Philipp Müller <tim at centricular dot net>
* ext/cairo/gsttextoverlay.c: (gst_text_overlay_font_init):
Implement minimal parsing of the passed pango font description
string, so passing a font size works the same as with the
pango textoverlay plugin; fixes #455086.
(Maybe we could just use pangocairo here at some point).
2007-11-13 Stefan Kost <ensonic@users.sf.net>
 
* gst/avi/gstavidemux.c:
......
......@@ -67,6 +67,8 @@ enum
#define DEFAULT_XPAD 25
#define DEFAULT_FONT "sans"
#define GST_CAIRO_TEXT_OVERLAY_DEFAULT_SCALE 20.0
static GstStaticPadTemplate cairo_text_overlay_src_template_factory =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
......@@ -248,9 +250,6 @@ gst_text_overlay_init (GstCairoTextOverlay * overlay,
overlay->need_render = TRUE;
overlay->font = g_strdup (DEFAULT_FONT);
overlay->slant = CAIRO_FONT_SLANT_NORMAL;
overlay->weight = CAIRO_FONT_WEIGHT_NORMAL;
overlay->scale = 20;
gst_text_overlay_font_init (overlay);
overlay->fps_n = 0;
......@@ -274,6 +273,33 @@ gst_text_overlay_font_init (GstCairoTextOverlay * overlay)
cairo_font_extents_t font_extents;
cairo_surface_t *surface;
cairo_t *cr;
gchar *font_desc, *sep;
font_desc = g_ascii_strdown (overlay->font, -1);
/* cairo_select_font_face() does not parse the size at the end, so we have
* to do that ourselves; same for slate and weight */
sep = MAX (strrchr (font_desc, ' '), strrchr (font_desc, ','));
if (sep != NULL && g_strtod (sep, NULL) > 0.0) {
/* there may be a suffix such as 'px', but we just ignore that for now */
overlay->scale = g_strtod (sep, NULL);
} else {
overlay->scale = GST_CAIRO_TEXT_OVERLAY_DEFAULT_SCALE;
}
if (strstr (font_desc, "bold"))
overlay->weight = CAIRO_FONT_WEIGHT_BOLD;
else
overlay->weight = CAIRO_FONT_WEIGHT_NORMAL;
if (strstr (font_desc, "italic"))
overlay->slant = CAIRO_FONT_SLANT_ITALIC;
else if (strstr (font_desc, "oblique"))
overlay->slant = CAIRO_FONT_SLANT_OBLIQUE;
else
overlay->slant = CAIRO_FONT_SLANT_NORMAL;
GST_LOG_OBJECT (overlay, "Font desc: '%s', scale=%f, weight=%d, slant=%d",
overlay->font, overlay->scale, overlay->weight, overlay->slant);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 256, 256);
cr = cairo_create (surface);
......@@ -290,6 +316,7 @@ gst_text_overlay_font_init (GstCairoTextOverlay * overlay)
cairo_destroy (cr);
cairo_surface_destroy (surface);
g_free (font_desc);
}
static void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment