How to fill in the background of a text box?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to fill in the background of a text box?

xxfire3d
Currently the text tool simply embeds the typed out text using the Foreground color. Is there an option to fill the entire text box (apart from the text) with the Background color?

So, for example, my foreground color is black and background is white and I have a blank image of uniform color (say, blue). I want to choose the text tool, drag out the text box, type in what I want, hit Ctrl+D and the result is a white rectangle filled with black text.

Thank you for any help.

Vad
Reply | Threaded
Open this post in threaded view
|

Re: How to fill in the background of a text box?

Rasband, Wayne (NIH/NIMH) [E]
On May 11, 2011, at 10:35 AM, xxfire3d wrote:

> Currently the text tool simply embeds the typed out text using the Foreground
> color. Is there an option to fill the entire text box (apart from the text)
> with the Background color?
>
> So, for example, my foreground color is black and background is white and I
> have a blank image of uniform color (say, blue). I want to choose the text
> tool, drag out the text box, type in what I want, hit Ctrl+D and the result
> is a white rectangle filled with black text.

To draw text with a background, create a text selection, run the Edit>Clear command and then press ctrl+d. To do this by pressing a single key (F1), add this macro to the end of the ImageJ/macros/StartupMacros.txt file.

  macro "Draw Text with Background [f1]" {
     run("Clear", "slice");
     run("Draw");
  }

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: How to fill in the background of a text box?

xxfire3d
Mr. Rasband,

Thank you for the response!

Your suggestion works but I have a slight issue. It seems that the size of the text within the Text Tool overlay is slightly different than the actual text that gets drawn into the image. When using the method you suggested, this difference results in the drawn text overflowing the filled background. Is there any way to get the size of the overlay text to more closely mimic that of the final drawn text?

Vad