[FFmpeg-devel] [PATCH] drawtext: unescape fontconfig patterns
bn
aval57 at yahoo.com
Mon Jun 3 03:27:57 CEST 2013
Hi,
This fixes drawtext's handling of fontconfig patterns with ':' attached properties, e.g. 'Times-12:italic' which when escaped to get past the options parser ('Times-12\:italic') will naturally fail in fontconfig itself unless unescaped again.
Please note that I took the expedient approach of altering the string in-place, which may or may not be ideal.
cheers,
Bahman
-----------------------------------------------------------
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 2358e35..6a54d46 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -322,6 +322,25 @@ static int load_font_file(AVFilterContext *ctx, const char *path, int index,
return 0;
}
+static char* unescape(char *text)
+{
+ char *p = text;
+ int shift = 0;
+
+ while (*p) {
+ if (*p == '\\' && p[1])) {
+ shift++;
+ p++;
+ }
+ if (shift) {
+ *(p - shift) = *p;
+ }
+ p++;
+ }
+ *(p - shift) = '\0';
+ return text;
+}
+
#if CONFIG_FONTCONFIG
static int load_font_fontconfig(AVFilterContext *ctx, const char **error)
{
@@ -338,7 +357,7 @@ static int load_font_fontconfig(AVFilterContext *ctx, const char **error)
*error = "impossible to init fontconfig\n";
return AVERROR(EINVAL);
}
- pattern = FcNameParse(dtext->fontfile ? dtext->fontfile :
+ pattern = FcNameParse(dtext->fontfile ? (uint8_t *)unescape(dtext->fontfile) :
(uint8_t *)(intptr_t)"default");
if (!pattern) {
*error = "could not parse fontconfig pattern";
More information about the ffmpeg-devel
mailing list