[FFmpeg-devel] [PATCH 2/2] vf_drawtext: fontconfig support.

Clément Bœsch ubitux at gmail.com
Sun Apr 8 11:29:11 CEST 2012


On Sat, Apr 07, 2012 at 04:46:49PM +0200, Nicolas George wrote:
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  configure                 |    3 +
>  doc/filters.texi          |    9 ++++
>  libavfilter/vf_drawtext.c |  104 +++++++++++++++++++++++++++++++++++++++++---
>  3 files changed, 108 insertions(+), 8 deletions(-)
> 
[...]
> +#if CONFIG_FONTCONFIG
> +static int load_font_fontconfig(AVFilterContext *ctx, const char **error)
> +{
> +    DrawTextContext *dtext = ctx->priv;
> +    FcConfig *fontconfig;
> +    FcPattern *pattern, *fpat;
> +    FcResult result = FcResultMatch;
> +    FcChar8 *filename;
> +    int err, index;
> +    double size;
> +
> +    fontconfig = FcInitLoadConfigAndFonts();
> +    if (!fontconfig) {
> +        *error = "impossible to init fontconfig.\n";
> +        return AVERROR(EINVAL);
> +    }
> +    pattern = FcNameParse(dtext->fontfile ? dtext->fontfile :
> +                          (uint8_t *)(intptr_t)"default");
> +    if (!pattern) {
> +        *error = "error parsing fontconfig pattern";
> +        return AVERROR(EINVAL);
> +    }
> +    if (!FcConfigSubstitute(fontconfig, pattern, FcMatchPattern)) {
> +        *error = "error substuting fontconfig options"; /* very unlikely */

I think you meant "substituting"

> +        return AVERROR(EINVAL);
> +    }

[...]

>  
> -    /* load the face, and set up the encoding, which is by default UTF-8 */
> -    if ((err = FT_New_Face(dtext->library, dtext->fontfile, 0, &dtext->face))) {
> -        av_log(ctx, AV_LOG_ERROR, "Could not load fontface from file '%s': %s\n",
> -               dtext->fontfile, FT_ERRMSG(err));
> -        return AVERROR(EINVAL);
> -    }
> +    err = load_font(ctx);
> +    if (err)
> +        return err;
> +    if (!dtext->fontsize)
> +        dtext->fontsize = 16;
>      if ((err = FT_Set_Pixel_Sizes(dtext->face, 0, dtext->fontsize))) {
>          av_log(ctx, AV_LOG_ERROR, "Could not set font size to %d pixels: %s\n",
>                 dtext->fontsize, FT_ERRMSG(err));
>          return AVERROR(EINVAL);
>      }
> +    return 0;
>  
>      dtext->use_kerning = FT_HAS_KERNING(dtext->face);
>  

huh? why is there a return 0 here?


-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120408/99ad6559/attachment.asc>


More information about the ffmpeg-devel mailing list