Page 1 of 1

Using two colours in a text to image conversion

Posted: 2008-09-26T06:18:12-07:00
by mthomsit
Hi,

I am trying to create an image which will be used as the title in a web page. The font is non-standard, hence the need to use an image.

What I would like to be able to do is append a different coloured fullstop on the end of the text string but I don't think it's possible using just one caption. If the title is long the text might wrap over a number of lines so the full stop would have to be positioned on the right line in the right place.

Would anyone be able to offer me some assistance? The current image is generated using rmagick (for ruby) but it should be clear:

Code: Select all

title = "caption:"+self.title
		img = Image.read(title) do
			self.size = "435x"
			self.pointsize = 26
			self.font = "GriffithGothic-Ultra"
			self.fill = "#006bcc"
		end
Thank you for any help you can offer
Mark

Re: Using two colours in a text to image conversion

Posted: 2008-09-26T10:30:08-07:00
by fmw42
As far as I know, you cannot change color, pointsize, font, etc within ONE instance of caption: or label:

You will need to do it twice and append the results.

Re: Using two colours in a text to image conversion

Posted: 2008-09-26T11:15:34-07:00
by mthomsit
Hi, yes that is what I suspected. Does anyone have an example like that which shows attaching text in the right place?

Re: Using two colours in a text to image conversion

Posted: 2008-09-26T13:27:34-07:00
by fmw42
search the archives

read http://www.imagemagick.org/Usage/text/

consider using annotate

Re: Using two colours in a text to image conversion

Posted: 2008-09-27T15:17:13-07:00
by rmagick
Since you're already using RMagick, you've got RVG. You can use the RVG::Tspan and RVG::Text classes to draw text in different styles. Check out the example at http://studio.imagemagick.org/RMagick/d ... n.html#new.

No automatic line-wrapping, though. :(

You can post questions about RMagick to the RMagick Forum on RubyForge: http://rubyforge.org/forum/?group_id=12 or email me directly at rmagick AT rubyforge DOT org.

Good luck!