[FFmpeg-devel] [PATCH] doc/filters: drawtext: add example of printing texts on same baseline

Andrey Utkin andrey_utkin at fastmail.com
Tue Nov 29 20:55:46 EET 2016


On Tue, Nov 29, 2016 at 09:31:08AM -0900, lou at lrcd.com wrote:
> On Mon, Nov 28, 2016, at 07:29 AM, Andrey Utkin wrote:
> > Dimensions of canvas drawtext produces vary depending on symbols in
> > text, so add example for printing multiple texts aligned horizontally.
> 
> I don't really understand the use case. Can you explain?

The point is that with more naive approach to printing parts of text,
using just same vertical offset (code given below), it will look fine in
some cases (e.g. all capital letters), but case of printing part with
capital letter(s) and part without capitals, the parts won't be aligned.

With the following script, you'll see the dot floating at the top of "A"
letter:

#!/bin/sh
FONTFILE=font.ttf
FONTSIZE=32
Y=10 # vertical offset of texts
X1=10 # horizontal offset of first text
X2=30 # horizontal offset of second text
TEXT1="A"
TEXT2="."
ffplay -f lavfi -i "color=color=white,
drawtext=fontfile=$FONTFILE:text=$TEXT1:fontsize=$FONTSIZE:x=$X1:y=$Y,
drawtext=fontfile=$FONTFILE:text=$TEXT2:fontsize=$FONTSIZE:x=$X2:y=$Y"


More information about the ffmpeg-devel mailing list