From patchwork Thu Jul 20 08:42:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: efren yang X-Patchwork-Id: 4380 X-Patchwork-Delegate: root@ffmpeg.org Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.76 with SMTP id 73csp1858838vsb; Thu, 20 Jul 2017 01:42:44 -0700 (PDT) X-Received: by 10.223.162.217 with SMTP id t25mr1071769wra.68.1500540164891; Thu, 20 Jul 2017 01:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500540164; cv=none; d=google.com; s=arc-20160816; b=AAgfXvJ720xMh03XIs5uhjbO2G7H9AGaRXjFU1VSmJuBSZ44I8wwluLBjHuiLAHL3y 7B08VW210wyMa+e8Bed5F2yNx5DoWgiELYOBLL9dzOrrFHgxl9IGS4D5NZJ9WqFuqUG8 rPAllMGPO/fLw+DdVyJ8leR52mclbOKfQ1FwH1Yp0DbhuvFJfL0HlVJumdufbYdPBsbO 5RCv5vTOZh9axK1yR0bvj1vv8u8ksmh9guU5Smo0dITrBNAs6ZG7/P1dRMyRWtPg53Oi uS+UBDXx26Jz9CuLOicdBhN+Kf7h9rZei24/PxuoqkKbmC+ljiFNE1aS/aUDKdCI8pdu bCxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:content-language:thread-index:mime-version :message-id:date:in-reply-to:references:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=Wz7nzGj0a7S0AW95CkFW5v+/gn8qm9ZwP57Goko456M=; b=ear9JVO4C0xMHe0P3BREH4CccaR5ijYSB1zGVwBQRbH3+LqT1dKLBMndbNbLCFWXk6 AdkyUuXbv9uxHBtmoHFDfvQCX4goojWQi6Fe6mnkuPi+/dB9uU7s9mEX5KNVyvYPyGwC t8PFDxl5w8BLmrUpeB62lCYFonI2xNzQl8jl34fF8ltYEJodR4J/CiuNQjsoHP4OiVf2 lLh+HQL4sbrTZvLS0wW8CqzZ4rdX9KUEwWRhUmcvAsAiiqF42WOXmLx+Xt3l+gJ5GBFz Ts0Gc46KeYlcSgLVFfpAyS/vDoQGmFJZ0WHiRZ8M8kWTb313zcRpYjBTCkFxKHVVTvtA HYXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@163.com header.b=X5XCQy+y; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t7si1311897wmb.275.2017.07.20.01.42.44; Thu, 20 Jul 2017 01:42:44 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@163.com header.b=X5XCQy+y; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2AD896891D9; Thu, 20 Jul 2017 11:42:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from m12-15.163.com (m12-15.163.com [220.181.12.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A575D6882DB for ; Thu, 20 Jul 2017 11:42:26 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=PvI6a WVThKOwLfobwCc1D4P8zs2+2Dw1bBoFPj0jamk=; b=X5XCQy+ytAZrA1aP8C8Ab Wrbdtl3xAEYF735HWO+2mrdZtzSeb+x3lacZVIIZH+klVBpz9C3lCFXlNnce+OZ9 IjlDvGuVPjp/Y+X/P4L//a1vogq+rP8+gSnVXDOkvPU1nDq0GlddwKXYlAmy6ikw ffjfajahpu+0SmquFFyh3g= Received: from YWA2526D (unknown [101.227.12.253]) by smtp11 (Coremail) with SMTP id D8CowABXX1P3bHBZhopPQA--.34016S2; Thu, 20 Jul 2017 16:42:32 +0800 (CST) From: "efren_yang" To: "'FFmpeg development discussions and patches'" References: <20170720080814.GA3621537@phare.normalesup.org> In-Reply-To: <20170720080814.GA3621537@phare.normalesup.org> Date: Thu, 20 Jul 2017 16:42:32 +0800 Message-ID: <018a01d30134$211185c0$63349140$@163.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQI2bSW0nQWpwkxJ1G/E9Qxa5TnragGUk9l4oYjgxlA= Content-Language: zh-cn X-CM-TRANSID: D8CowABXX1P3bHBZhopPQA--.34016S2 X-Coremail-Antispam: 1Uf129KBjvJXoW3Wry7Ar1DKF1xWw4DZFWkJFb_yoW7uFWxpF 45Wa1xXws5G3WxC34rZF1DX3WYvwn7Xa48K3s3Z3yxJFn0y3WkWFnIkFy5Cwn3Zr4xA3yY vFWF9F47GwsxtaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jmHq7UUUUU= X-Originating-IP: [101.227.12.253] X-CM-SenderInfo: phiuv0xb1d0wi6rwjhhfrp/xtbBXhgbF1aDrLnVlgAAsJ Subject: [FFmpeg-devel] =?utf-8?b?562U5aSNOiAgW1BBVENIXSB2Zl9kcmF3dGV4dDog?= =?utf-8?q?support_to_set_word_spacing_while_drawing_text=2E_=2E/ff?= =?utf-8?q?mpeg_-i_input_-vf_drawtext=3D=22word=5Fspacing=3D10=3Ate?= =?utf-8?q?xtfile=3D1=2Etxt=3Afontfile=3Ddemo=2Ettf=22_-f_flv_1=2Ef?= =?utf-8?q?lv_could_set_word_spacing_10_pixel=2E?= X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 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 --- 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);