Login  Register

Re: ImageJ's fonts and a New Image suggestion

Posted by Gabriel Landini on May 10, 2006; 10:43am
URL: http://imagej.273.s1.nabble.com/ImageJ-s-fonts-tp3702798p3702800.html

On Wednesday 10 May 2006 10:14, Jerome Mutterer wrote:
> The font.txt macro demonstrates the getFontList() macro function.
> The fonts listed by this function are possible arguments to the
> setFont() macro function that sets the font used by the drawString()
> macro function.
> Thus, so far, extra fonts can only be used from within a macro, and
> can not be used by the Text tool from the tool bar. This tool uses the
> font set by the Edit/Options/Fonts... dialog which displays only 5
> fonts.

For some reason, the macro gives an error half the way through when showing
all fonts:

java.lang.IllegalArgumentException: Width (0) and height (30) cannot be <= 0
        at
java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:999)
        at
sun.awt.X11GraphicsConfig.createAcceleratedImage(X11GraphicsConfig.java:365)
        at sun.awt.X11.XComponentPeer.createImage(XComponentPeer.java:819)
        at java.awt.Component.createImage(Component.java:3147)
        at ij.process.ImageProcessor.drawString(ImageProcessor.java:876)
        at ij.process.ImageProcessor.drawString(ImageProcessor.java:928)
        at ij.macro.Functions.drawString(Functions.java:783)
        at ij.macro.Functions.doFunction(Functions.java:87)
        at ij.macro.Interpreter.doStatement(Interpreter.java:195)
        at ij.macro.Interpreter.doBlock(Interpreter.java:503)
        at ij.macro.Interpreter.doStatement(Interpreter.java:231)
        at ij.macro.Interpreter.doFor(Interpreter.java:449)
        at ij.macro.Interpreter.doStatement(Interpreter.java:213)
        at ij.macro.Interpreter.doStatements(Interpreter.java:185)
        at ij.macro.Interpreter.run(Interpreter.java:90)
        at ij.macro.Interpreter.run(Interpreter.java:56)
        at ij.macro.MacroRunner.run(MacroRunner.java:65)
        at java.lang.Thread.run(Thread.java:626)

I traced it down to a PostScript Type 1 font called "Cursor, Medium". which
seems to return the wrong dimensions.

I added a line to the macro so skip the font if the name is "Cursor".

I also wanted to suggest the following.
The New Image IJ command and the newImage macro command can have a "Black",
"White" and "Ramp" options.
It may be useful to add a "Foreground" and "Background" options which fill the
images with the current foreground or background colours as set in the colour
picker.
Since some (me included) set the default IJ with a black background and a
white foreground, the Fonts macro assumes the opposite and so the result is
all white (you can't see the fonts which are written in the foreground colour
(currently white), with the background assumed to be the IJ default white).
Having "Foreground" and "Background" (in adition to the Black, White and Ramp)
would avoid this kind of problem.
 
Cheers,

Gabriel