Apply font style to portion of caption text

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
KristyStevens
Posts: 1
Joined: 2019-06-24T20:54:31-07:00
Authentication code: 1152

Apply font style to portion of caption text

Post by KristyStevens »

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!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Apply font style to portion of caption text

Post by fmw42 »

You cannot change the style or font in the same caption: text. You would either have to use Pango styling (probably the most direct method) or write each line separately with label: and append or just use -annotate, once per line. See https://imagemagick.org/Usage/text/
Post Reply