Skip to content

Granny Text Strings

Jeremy Faden edited this page Oct 13, 2021 · 9 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

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.

Clone this wiki locally