Hi, devel

        Thanks for reply.  As you see, it is applied to every glyph. There is 
no space between all words in some languages, for example Chinese, Japanese and 
so on. So a sentence will look very compactly. I think if we could set glyph 
spacing, it would be more useful to adapt to more different scenarios.  I'm not 
saying accurately. I fix it.

From d9b680e8e90236c5807f1df5e258d8632d3c9619 Mon Sep 17 00:00:00 2001
From: efren yang <efren_y...@163.com>
Date: Thu, 20 Jul 2017 16:37:06 +0800
Subject: [PATCH] vf_drawtext: support to set glyph spacing while drawing text.
 ./ffmpeg -i input -vf
 drawtext="glyph_spacing=10:textfile=1.txt:fontfile=demo.ttf" -f flv 1.flv
 could set glyph spacing 10 pixel.

Signed-off-by: efren yang <efren_y...@163.com>
---
 libavfilter/vf_drawtext.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 137ae5891e..ceeee96c5a 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -162,7 +162,7 @@ typedef struct DrawTextContext {
     unsigned int default_fontsize;  ///< default font size to use
 
     int line_spacing;               ///< lines spacing in pixels
-    int word_spacing;               ///< word spacing in pixels
+    int glyph_spacing;               ///< glyph spacing in pixels
     short int draw_box;             ///< draw box around text - true or false
     int boxborderw;                 ///< box border width
     int use_kerning;                ///< font kerning is used - true/false
@@ -215,7 +215,7 @@ static const AVOption drawtext_options[]= {
     {"box",         "set box",              OFFSET(draw_box),           
AV_OPT_TYPE_BOOL,   {.i64=0},     0,        1       , FLAGS},
     {"boxborderw",  "set box border width", OFFSET(boxborderw),         
AV_OPT_TYPE_INT,    {.i64=0},     INT_MIN,  INT_MAX , FLAGS},
     {"line_spacing",  "set line spacing in pixels", OFFSET(line_spacing),   
AV_OPT_TYPE_INT,    {.i64=0},     INT_MIN,  INT_MAX,FLAGS},
-    {"word_spacing",  "set word spacing in pixels", OFFSET(word_spacing),   
AV_OPT_TYPE_INT,{ .i64 = 0 },     INT_MIN,  INT_MAX,FLAGS },
+    {"glyph_spacing",  "set glyph spacing in pixels", OFFSET(glyph_spacing),   
AV_OPT_TYPE_INT,{ .i64 = 0 },     INT_MIN,  INT_MAX,FLAGS },
     {"fontsize",    "set font size",        OFFSET(fontsize_expr),      
AV_OPT_TYPE_STRING, {.str=NULL},  CHAR_MIN, CHAR_MAX , FLAGS},
     {"x",           "set x expression",     OFFSET(x_expr),             
AV_OPT_TYPE_STRING, {.str="0"},   CHAR_MIN, CHAR_MAX, FLAGS},
     {"y",           "set y expression",     OFFSET(y_expr),             
AV_OPT_TYPE_STRING, {.str="0"},   CHAR_MIN, CHAR_MAX, FLAGS},
@@ -1376,7 +1376,7 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame,
         s->positions[i].y = y - glyph->bitmap_top + y_max;
         if (code == '\t') x  = (x / s->tabsize + 1)*s->tabsize;
         else              x += glyph->advance;
-        x += s->word_spacing;
+        x += s->glyph_spacing;
     }
 
     max_text_line_w = FFMAX(x, max_text_line_w);
-- 
2.13.0.windows.1

-----邮件原件-----
发件人: geo...@phare.normalesup.org [mailto:geo...@phare.normalesup.org] 代表 
Nicolas George
发送时间: 2017年7月20日 16:08
收件人: FFmpeg development discussions and patches
抄送: efren_y...@163.com
主题: Re: [FFmpeg-devel] [PATCH] vf_drawtext: support to set word spacing while 
drawing text. ./ffmpeg -i input -vf 
drawtext="word_spacing=10:textfile=1.txt:fontfile=demo.ttf" -f flv 1.flv could 
set word spacing 10 pixel.

Hi. Thanks for the patch. See comments below.

Le duodi 2 thermidor, an CCXXV, efren yang a écrit :
> Subject: Re: [FFmpeg-devel] [PATCH] vf_drawtext: support to set word 
> spacing  while drawing text. ./ffmpeg -i input -vf  
> drawtext="word_spacing=10:textfile=1.txt:fontfile=demo.ttf" -f flv 
> 1.flv  could set word spacing 10 pixel.

The commit message will need fixing before commit.

> Signed-off-by: efren yang <efren_y...@163.com>
> ---

>  libavfilter/vf_drawtext.c | 3 +++
>  1 file changed, 3 insertions(+)

The documentation needs to be updated.

> 
> diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c 
> index f6151443bb..137ae5891e 100644
> --- a/libavfilter/vf_drawtext.c
> +++ b/libavfilter/vf_drawtext.c
> @@ -162,6 +162,7 @@ typedef struct DrawTextContext {
>      unsigned int default_fontsize;  ///< default font size to use
>  
>      int line_spacing;               ///< lines spacing in pixels
> +    int word_spacing;               ///< word spacing in pixels
>      short int draw_box;             ///< draw box around text - true or false
>      int boxborderw;                 ///< box border width
>      int use_kerning;                ///< font kerning is used - true/false
> @@ -214,6 +215,7 @@ static const AVOption drawtext_options[]= {
>      {"box",         "set box",              OFFSET(draw_box),           
> AV_OPT_TYPE_BOOL,   {.i64=0},     0,        1       , FLAGS},
>      {"boxborderw",  "set box border width", OFFSET(boxborderw),         
> AV_OPT_TYPE_INT,    {.i64=0},     INT_MIN,  INT_MAX , FLAGS},
>      {"line_spacing",  "set line spacing in pixels", OFFSET(line_spacing),   
> AV_OPT_TYPE_INT,    {.i64=0},     INT_MIN,  INT_MAX,FLAGS},
> +    {"word_spacing",  "set word spacing in pixels", OFFSET(word_spacing),   
> AV_OPT_TYPE_INT,{ .i64 = 0 },     INT_MIN,  INT_MAX,FLAGS },
>      {"fontsize",    "set font size",        OFFSET(fontsize_expr),      
> AV_OPT_TYPE_STRING, {.str=NULL},  CHAR_MIN, CHAR_MAX , FLAGS},
>      {"x",           "set x expression",     OFFSET(x_expr),             
> AV_OPT_TYPE_STRING, {.str="0"},   CHAR_MIN, CHAR_MAX, FLAGS},
>      {"y",           "set y expression",     OFFSET(y_expr),             
> AV_OPT_TYPE_STRING, {.str="0"},   CHAR_MIN, CHAR_MAX, FLAGS},
> @@ -1374,6 +1376,7 @@ static int draw_text(AVFilterContext *ctx, AVFrame 
> *frame,
>          s->positions[i].y = y - glyph->bitmap_top + y_max;
>          if (code == '\t') x  = (x / s->tabsize + 1)*s->tabsize;
>          else              x += glyph->advance;

> +        x += s->word_spacing;

It says "word" spacing, but it is applied to every glyph. Is there something I 
am missing?

>      }
>  
>      max_text_line_w = FFMAX(x, max_text_line_w);

Regards,

--
  Nicolas George


_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to