Page 1 of 1

Apply font style to portion of caption text

Posted: 2016-09-07T17:34:05-07:00
by ACIDSTEALTH
Hi everyone,

I'm a relatively new ImageMagick user so I hope my question makes sense. What I would like to know is if it is possible to style a portion of text in a caption. More specifically, I want to be able to create a multi-line caption representing a series of questions and answers, where the questions are bolded. Is this possible, and if so, how? I'm using RMagick.

So for example, I might have the following string of text:

var string = "This is a question?\nThis is an answer.\nThis is another question?\nThis is another answer."

Which should yield a caption like this:
This is a question?
This is an answer.

This is another question?
This is another answer.
I'm open to other approaches other than a caption as long as they support multiple lines of text and auto font sizing.

Thanks!

Re: Apply font style to portion of caption text

Posted: 2016-09-07T17:57:00-07:00
by snibgo
With ImageMagic, the two most flexible mechanisms for text are SVG and Pango.

For Pango, see http://www.imagemagick.org/Usage/text/#pango

For SVG, see the SVG standard: https://www.w3.org/TR/SVG/

However, for some purposes you can build up a text image from smaller images, one per paragraph, setting each paragraph in whatever font, size, weight etc that you want.

Re: Apply font style to portion of caption text

Posted: 2016-09-07T18:17:33-07:00
by ACIDSTEALTH
Thanks, that's helpful! I wasn't even aware of Pango but it seems like a viable solution for what I'm trying to do.