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

Ramiro Polla ramiro.polla at gmail.com
Fri Jan 10 14:08:37 CET 2014


On Fri, Jan 10, 2014 at 6:40 AM, Stefano Sabatini <stefasab at gmail.com> wrote:
> 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.

Done.

> 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.

I don't see why use those flags except for allowing the user to tinker
with the library and possible get some misbehaving code. I'd suggest
removing them altogether.

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

It still works for the text, but not for the border afterwards.

>> @@ -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

Done. There are many others around this one to fix afterwards.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavfi-drawtext-get-bitmap-from-glyph-in-a-separate-s.patch
Type: text/x-patch
Size: 3166 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140110/13ba101e/attachment.bin>


More information about the ffmpeg-devel mailing list