Login  Register

Changing fonts in macros for the Series Labeler

Posted by dscho on Nov 08, 2012; 11:40pm
URL: http://imagej.273.s1.nabble.com/Changing-fonts-in-macros-for-the-Series-Labeler-tp5000755.html

Hi all,

it was recently brought to my attention that the following macro does not
do what you think it does:

        setFont("SansSerif", 48, "antialiased");
        run("Series Labeler", ...);

The reason is that setFont() only changes the current slice's font, while
the Series Labeler accesses the font properties as specified via
Edit>Options>Fonts, i.e. the TextRoi settings.

The workaround is to use Javascript (which you should consider anyway,
given that it is such a powerful scripting language):

        eval("script", "importClass(Packages.ij.gui.TextRoi);"
                + "importClass(Packages.java.awt.Font);"
                + "TextRoi.setFont('Serif', 28, Font.ITALIC, true);");
        run("Series Labeler", ...);

Hopefully this information helps more people do what they need to do!

Ciao,
Johannes

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html