Personal tools
You are here: Home CDAT Tips and Tricks Text and Primitives Tips The Fonts in CDAT
Document Actions

The Fonts in CDAT

by Charles Doutriaux last modified 2007-07-10 08:35

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.

Fonts description in CDAT














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
3Courier
4 Helvetica
5 Adelon
6 Times
7 Arabic
8 Chinese
9 Greek
10 Hebrew
11 Russian
12Maths1Mostly Equivalence Symbols
13Maths2Brackets, Square roots, Sum, Products, ...
14Maths3Integrals, and some astro symbols
15Maths4Misc, 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 file

Added 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 user

x.setdefaultfont("myfont")

# or number
switches 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 name

x.getfontname(4)

# returns name associated with font number

x.getfont(arg)

# returns either the font name or number associated with a number/name

x.gettextextent(tx)

# where tx is a text object, returns the surrounding box for each string drawn by the object
Usefull 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)



Powered by Plone