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
ACIDSTEALTH
Posts: 4
Joined: 2016-04-27T09:05:30-07:00
Authentication code: 1151

Apply font style to portion of caption text

Post 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!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Apply font style to portion of caption text

Post 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.
snibgo's IM pages: im.snibgo.com
ACIDSTEALTH
Posts: 4
Joined: 2016-04-27T09:05:30-07:00
Authentication code: 1151

Re: Apply font style to portion of caption text

Post 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.
Post Reply