National Oceanic and
Atmospheric Administration
United States Department of Commerce

Changing to another font from ASCII font

Changing to another font from ASCII font

Question:

How can I use the character fontAS and also characters from a symbol font together? Can I change toanother font within a label once I'm in ASCII font?

Example:

The ASCII font is useful to let special characters like the underscoreappear in the label and prevent their use by PPLUS as specialformatting characters (@ to change fonts, ^ for superscripts, _ forsubscripts and so on). In this example we will use the ASCII font so wecan include the underscore character as part of the label. But then, ifwe want to use a special character in its PPLUS sense, for instance the@ character to change to another font, it is not recognized as thespecial character that changes fonts. Here we want to use character 09from the map font CA. If we try:


 

yes? label/nouser 3 2 0 0 0.15 "@AStemp_01@CA09(Centigrade_scale)"

The command produces a label that reads:

temp_01@CA09Centigrade_scale

Solution:

In PyFerret the SET TEXT command makes settings for the text in labels on the plot page. This includes a choice of font, chosen from those available to the Python packages. In Python library fonts, special characters are embedded in text using an html-style coding. The label discussed below is drawn as follows:

> pyferret

yes? SET TEXT/FONT=arial
yes? plot myvar 
yes?label/nouser 3 2 0 0 0.15 "temp_01 <&deg>(Centigrade_scale)"/i=1:15 i

In PyFerret, the font may be set as /SET TEXT/FONT=HERSHEY. With this setting, all of the classic-Ferret controls for fonts is in effect and the syntax below is valid.

When we are in ASCII font, the ESCAPE character allows the characterimmediately following it to be recognized as a special character toPPLUS. Placing ESCAPE it in front of the @CA lets us access the mapfont, and a second ESCAPE character in front of another @AS changesback to ASCII font so we can use an underscore in Centigrade_scale.

yes? ! Here the ESCAPE character appears as a square.
yes? label/nouser 3 2 0 0 0.15 "@AStemp_01@CA09@AS(Centigrade_scale)"

The ESCAPE character is decimal character 27, and may be enteredinto a script with some text editors. A trick to have easy access tothe ESCAPE character is to keep it in a file. (See below the figure toget the file). Then in a Ferret session or script, read the characterinto a string variable, and use the Ferret STRCAT function to put itinto the label string.

For Example

yes? go ptest ! just an example plot to put a user-defined label on

yes? ! Define a character variable containing the ESCAPE character
yes? columns/type=text/var=escchar escapeit.dat

yes? ! Use STRCAT to put the character into a label
yes? let mylab1 = strcat ("@AStemp_01", escchar)
yes? let mylab2 = strcat (mylab1, "@CA09")
yes? let mylab3 = strcat (mylab2, escchar)
yes? let mylabel = strcat (mylab3, "@AS(Centigrade_scale)")
yes? label/nouser 4 5 0 0 0.15 `mylabel`

ascii example

 

For convenience, the escape character is in a file escapeit.dat, inthe tar file escape_character.tar, which you may download here.escape_character.tar