Multi colored text.. font metrics?

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?".
Locked
dognose
Posts: 268
Joined: 2005-03-08T22:16:37-07:00

Multi colored text.. font metrics?

Post by dognose »

Hi,

I'm trying to add multicolored text (ie. each letter a different color) to an image, I'm using the command line tools.

How would I do this?

I'd Image I'd have to draw out each letter of the text indivually, but how do I get the spacing to do that properly, programmatically?

User avatar
anthony
Posts: 8884
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

For different colors and styles the only way is to draw each letter (or word) seperatally, then append them together as appropriate. If you are using the same font and font size, straight append should work perfectly fine. If you chnage fonts, pointsizes, or change stroke widths, or do other effects to the letters then direct appending will nolonger work.

Basically IM is NOT as Wordprocessor, it is a Image processor. Though it can (with difficulty) get simular results.

For examples of this type of handling see...
Creating Lines of Mixed Font Styles
http://www.cit.gu.edu.au/~anthony/graph ... font_lines
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

dognose
Posts: 268
Joined: 2005-03-08T22:16:37-07:00

Post by dognose »

Append would be nice, but the kerning isn't right. It spaces out the letters more.

Image

Image

Image

User avatar
anthony
Posts: 8884
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

If this is typical of what you are attempting, you could try recoloring the color gradient in a specific reagion. the offset and size of the region could be determined by finding the text lengths.

Basically what this shows is that the bounding box of the font has the stroke width extra space added to the bounds.

Hmm do you have the font and commands you used for the above?
Mail it to me so I can show this as a problem on the IM examples web pages.
Mail as I am dissappearing for the whole of april overseas. (Austrialia to Europen via Korea)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

dognose
Posts: 268
Joined: 2005-03-08T22:16:37-07:00

Post by dognose »

Well, I'm not sure if the region painting would work... some letters may overlap in strange ways... and, if I could get the dimentions of the letters, I could draw them seperately.

how would I properly get the dimensions of the letters? Is there another program outside of IM command line tools?

User avatar
anthony
Posts: 8884
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

If you are using an API you can get the bounds of a string directly.
This includes the outside bounds and the 'movement of the cursor'
which is what you are needing.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Locked