The Fonts in CDAT
short page to describe font manipulation with the new font interface
What did NOT change
The way the fonts are described did not change, they can be split between the text"table" part and the text"orientation" part
The figure bellow describes the less obvious elements of a font.

as before fonts are still controlled via text table and textorientation
>>> tt=x.createtexttable('mytable')
>>> tt.list()
----------Text Table (Tt) member (attribute) listings ----------
Canvas Mode = 1
secondary method = Tt
name = mytable
font = 1
spacing = 2
expansion = 100
color = 1
>>> t0=x.createtextorientation('myorient')
>>> t0.list()
----------Text Orientation (To) member (attribute) listings ----------
Canvas Mode = 1
secondary method = To
name = myorient
height = 14
angle = 0
path = right
halign = left
valign = half
What changed
The font number is now not limited to 9, but it is UNlimited.
The new default font (and their associated font number at load time) are:
| ont # | Name | Comments |
|---|---|---|
| 1 | AvantGarde | |
| 2 | Clarendon | |
| 3 | Courier | |
| 4 | Helvetica | |
| 5 | Adelon | |
| 6 | Times | |
| 7 | Arabic | |
| 8 | Chinese | |
| 9 | Greek | |
| 10 | Hebrew | |
| 11 | Russian | |
| 12 | Maths1 | Mostly Equivalence Symbols |
| 13 | Maths2 | Brackets, Square roots, Sum, Products, ... |
| 14 | Maths3 | Integrals, and some astro symbols |
| 15 | Maths4 | Misc, some causality symbols |
After this all font in your PCMDI_GRAPHICS directory are loaded as well (but the numbers can change from one time to another depending on the number of font in your directory)
These fonts are loaded with their associated name in the font fileAdded FONT functions:
x.addfont(path,name)
Load a font file specified via path and associates it with the name "name"
*) If name is empty then the font name stored in the font file is used
*) If path pints to a directory then all font files (.ttf) in this directory are loaded and associated with their name in the file
*) additionally for directory loading you can specifiy "r" as secand arguments (instead of name) to browse recursively
x.listelements("font")
returns a list of all fonts loaded into CDAT and available to the userx.setdefaultfont("myfont")
# or numberswitches your font with font number 1, useful to simply change the font w/o editing all templates
x.switchfont(font1,font2)
# switch font numbers these allows you for example to make sure that your font named "myfont" always has number 4 (since template refer to font number and not name)x.switchfonts("myfont",4)
x.getfontnumber("myfont")
# returns number associated with font namex.getfontname(4)
# returns name associated with font numberx.getfont(arg)
# returns either the font name or number associated with a number/namex.gettextextent(tx)
# where tx is a text object, returns the surrounding box for each string drawn by the objectUsefull to place string with different fonts next to each other, or for equations building
NEW FEATURE: Superscript and Subscript
Text strings are now "sub/superscript" enabled.
To go "up" one level of superscript add the "!U" characters in your text string everything fllowing will be superscripted. You can even do "superscript in the superscript" by typing again "!U" (i.e. going Up once again)
The same apply to subscript, you can go Down one level using "!D"
example:
import vcs
x=vcs.init()
t=x.createtext("mytext")
t.x=[.1]
t.y=[.5]
t.string=["This is normal and now it is!Uin superscript!Dand back to normal with also some !Dsubscript!Dand subsubscript!D3times sub!U!U!Uback to normal"]
x.plot(t)