Skip to content

Granny Text Strings

Jeremy Faden edited this page Nov 21, 2025 · 12 revisions

"Granny Strings" are from IDL are supported, so !A will move the pen up, and !N will return to its original level. Over the years support for additional controls has been added, namely some support for HTML, like <br>, and LaTeX is planned.
Color control strings are added which can modify the graphics context. And beyond that, Java/Jython codes can be plugged in which allows any customization.

Code Description
!A shift up one half line
!B shift down one half line (e.g. !A3!n-!B4!n is 3/4).
!C newline
!D subscript 0.62 of old font size.
!U superscript of 0.62 of old font size.
!E superscript 0.44 of old font size.
!I subscript 0.44 of old font size.
!N return to the original font size.
!R restore position to last saved position
!S save the current position.
!K reduce the font size. (Not in IDL's set.)
!! the exclamation point (!)
!(ext;args) extension and arguments for the extension, examples follow.
!(color;saddleBrown) switch to color.
!(painter;codeId;codeArg1) Plug-in Java code for painting regions.
<br> newline (see also !c)
<b> bold, </b> returns.
<i> italics, </i> returns.

A table of example control strings and their rendering follows.

Label Text codes used Rendering
cm!A2 !A is shift up
cm!A2!nSM!BX!n !n is return, !B is shift down
Bulk!cFlow !c is newline
Bulk<br>Flow <br> is also newline
Flow !(color;blue)Positive!(color) !(color;red)Negative!(color) colors, note no argument
returns to default color
!(color;SaddleBrown)&#9608;!(color) Brown Points Unicode block used,
to show color
SVG Colors
&Delta;M Parameter HTML Entities Table
&#9742; 555-1212 HTML Entities
some <b>Bold</b> text Bold text

Standard Painters

Two standard painters are added to all GrannyTextRenderers. The painter;psym or painter;img identify the painter, and the arguments follow.

Code Arguments Description
!(painter;psym;boxes;size=0.5em) arg0 is non, triangles, circles, etc
size is ems or pts
connect is solid,none,or dots
lineThick is line thickness.
Draws a plot symbol at the position
!(painter;img;https://autoplot.org/Logo32.png) arg0 is the image URL
arg1 is the size in em or px.
Draws an image at the position

Granny Text Editor

An editor provides a GUI method for creating text strings.

Arbitrary Extensions Using Painters

These strings are rendered by an object called GrannyTextRenderer, and it allows for custom handlers to be plugged in. For example, you can plug in a code that draws a plot symbol, and then use plot symbols within the strings.

Here is an Autoplot Jython script showing how this is done, see https://github.com/autoplot/dev/blob/master/rfe/sf/625/latexPainter.jy. LaTeXPainter is a GrannyTextRenderer.Painter, which draws content onto the graphics and returns a bounding box showing where the content was drawn. This LaTeXPainter is then created and assigned the painter label "latex", so any time !(painter;latex;...) is found in the string, the painter is called upon to paint the content.

To Be Done

LaTeX rendering is an obvious feature, and is used in both IDL and Python, and has been used in special cases in Autoplot. There is a pure-Java LaTeX rendering engine, so this is quite possible.

Clone this wiki locally