17.1 Escape sequences

##
17.1 Escape sequences

A text string may contain escape characters that control its appearance. The escape sequences all start with the letter ```/`''. Thus, to display ```/`'' itself, you must write ```//`''.

> Restrictions: `/h`, `/v`, and `/a` must appear in the beginning of a string.

`/add`
  Specifies the angle of the text. Parameter dd is a number between -360 to 360. Value 0 means left-to-right text, 90 means bottom-to-up, etc. If you want to print numbers right after an angle specification, put `{` between the angle and the number. For example, the below code shows string "`"100"`" at a 60-degree angle.

      "/a60{}100"

`/h`A:
  Specifies horizontal alignment of the text. A is one of "`L`" (left alignment), "`R`" (right alignment), or "`C`" (center alignment).

`/v`A:
  Specifies vertical alignment of the text. A is one of "`B`" (bottom), "`T`" (top), or "`M`" (middle).

`/T`
  : Switch to Times font family.

`/H`:
  Switch to Helvetica font family.
`/C`:
  Switch to Courier font family.
`/B`:
  Switch to Bookman-Demi font family.
`/A`:
  Switch to AvantGarde-Book font family.
`/P`:
  Switch to Palatino font family.
`/S`:
  Switch to Symbol font family.
`/F{family}`:
  Switch to family font family. The below example draws string "Funny" using ZapfDingbat font (which produces some meaningless output).

      canvas.show(100, 200, "/F{ZapfDingbat}Funny")

  The list of available fonts are the following:

  > Bookman-Demi Bookman-Light Courier AvantGarde-Book AvantGarde-Demi Helvetica Helvetica-Narrow Palatino NewCenturySchlbk Times Symbol ZapfChancery-MediumItalic ZapfChancery-Medium-Italic ZapfDingbats

`/b`:
  Switch to bold typeface.
`/i`:
  Switch to italic typeface.
`/o`:
  Switch to oblique typeface.
`/`dd:
  Set font size to dd points.

      "/20{}2001 space odyssey!"

`/c`dd:
  Set gray-scale to 0.dd. Gray-scale of 0 means black, 1 means white.

`//`, `/{`, `/}`:
  Display `/', `}', or `{'.
`{ ... }`:
  Limit the scope of escape sequences. For example, `"{/10{/20Big text} and small text}"` will display `"Big Text"` using a 20-point font, and `"and small text"` using a 10-point font.

`n`:
  Break the line.

Font usage example

Below is the source code that produces the above chart. ../demos/fonttest.py

    from pychart import *
    can = canvas.default_canvas()
    x, y = (100, 500)

    def show_text(str):
        global x, y
        can.show(x, y, str)
        can.show(x + 200, y, "/12/C" + font.quotemeta(str))
        y -= 20

    show_text("/12/hLLeft align")
    show_text("/12/hRRight align")
    show_text("/12/hCCenter align")
    show_text("/a20/12/hRAngled text")

    def show_textv(str):
        global x, y
        can.show(x, y, str)
        x += 150

    y -= 40
    x = 100
    show_textv("/12/vT//12//vTTop align")
    show_textv("/12/vM//12//vT/12Middle align")
    show_textv("/12/vB//12//vT/12Bottom align")

    y -= 40
    x = 100
    show_text("/16/HHelvetica")
    show_text("/12/CCourier")
    show_text("/12/NHelvetica-Narrow")
    show_text("/12/PPalatino-Roman")
    show_text("/12/AAvantgarde")
    show_text("/12/T/iTimes-Italic")
    show_text("/12/F{ZapfDingbats}ZapfDingbats")