[FFmpeg-devel] [PATCH 1/2] lavfi/drawtext: get bitmap from glyph in a separate step

Stefano Sabatini stefasab at gmail.com
Fri Jan 10 09:40:21 CET 2014


On date Friday 2014-01-10 04:36:14 -0200, Ramiro Polla encoded:
> This change makes it possible to transform the glyph or get its border before
> turning it into a bitmap.

> From cdc01d133828f2222cc7e6fb2c0ffe7ecfd95d56 Mon Sep 17 00:00:00 2001
> From: Ramiro Polla <ramiro.polla at gmail.com>
> Date: Thu, 9 Jan 2014 18:47:17 -0200
> Subject: [PATCH 1/2] lavfi/drawtext: get bitmap from glyph in a separate step
> 
> This change makes it possible to transform the glyph or get its border before
> turning it into a bitmap.
> ---
>  libavfilter/vf_drawtext.c |   14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
> index 91b8218..2dd95ce 100644
> --- a/libavfilter/vf_drawtext.c
> +++ b/libavfilter/vf_drawtext.c
> @@ -206,7 +206,7 @@ static const AVOption drawtext_options[]= {
>      {"start_number", "start frame number for n/frame_num variable", OFFSET(start_number), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS},
>  
>      /* FT_LOAD_* flags */
> -    { "ft_load_flags", "set font loading flags for libfreetype", OFFSET(ft_load_flags), AV_OPT_TYPE_FLAGS, { .i64 = FT_LOAD_DEFAULT | FT_LOAD_RENDER}, 0, INT_MAX, FLAGS, "ft_load_flags" },
> +    { "ft_load_flags", "set font loading flags for libfreetype", OFFSET(ft_load_flags), AV_OPT_TYPE_FLAGS, { .i64 = FT_LOAD_DEFAULT }, 0, INT_MAX, FLAGS, "ft_load_flags" },
>          { "default",                     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FT_LOAD_DEFAULT },                     .flags = FLAGS, .unit = "ft_load_flags" },
>          { "no_scale",                    NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FT_LOAD_NO_SCALE },                    .flags = FLAGS, .unit = "ft_load_flags" },
>          { "no_hinting",                  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FT_LOAD_NO_HINTING },                  .flags = FLAGS, .unit = "ft_load_flags" },

Please update docs accordingly.

Also I wonder if we should remove the render flag altogether.

Previously it could be used to skip rendering, but since it is now a
two-steps process (load the glyph, render it), the render flags makes
no much sense and could indeed result in improper behavior.

What happens if you load glyph with +render and then convert it to a
glyph?

> @@ -264,6 +264,7 @@ static int glyph_cmp(void *key, const void *b)
>  static int load_glyph(AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code)
>  {
>      DrawTextContext *s = ctx->priv;
> +    FT_BitmapGlyph bitmapglyph;
>      Glyph *glyph;
>      struct AVTreeNode *node = NULL;
>      int ret;
> @@ -284,10 +285,15 @@ static int load_glyph(AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code)
>          ret = AVERROR(EINVAL);
>          goto error;
>      }

> +    if (FT_Glyph_To_Bitmap(glyph->glyph, FT_RENDER_MODE_NORMAL, 0, 1)) {
> +        ret = AVERROR(EINVAL);

AVERROR_EXTERNAL

[...]
-- 
FFmpeg = Fabulous & Foolish Magical Programmable Ecumenical Gospel


More information about the ffmpeg-devel mailing list