Difference between revisions of "Label font id"

From PyMOLWiki
Jump to navigation Jump to search
m (Fixed Unicdoe)
Line 29: Line 29:
 
</source>
 
</source>
  
==Unicdoe Fonts==
+
==Unicode Fonts==
 
[[Image:Font_ex.png|300px|thumb|right|Notice the Angstrom and superscript 2 characters.  You can add other characters as well.]]
 
[[Image:Font_ex.png|300px|thumb|right|Notice the Angstrom and superscript 2 characters.  You can add other characters as well.]]
  

Revision as of 20:05, 10 February 2010

Overview

Set which fonts PyMol uses to render labels. Font IDs 5—14 are normal fonts, while 15 and 16 are for unicode fonts (and can support many more characters).

Syntax

set label_font_id, 10 # use font no. 10
set label_font_id, 11 # use font no. 11
set label_font_id, 12 # use font no. 12

UTF-8 Fonts

New fonts in PyMol. Notice the alpha and beta characters.

Newer versions support UTF8 fonts; use label_font_id from above to 15 or 16. The good news about the UTF8 fonts is that they support the alpha and beta characters. (See image.)

Here's some example code for the image at right:

# roman
set label_font_id, 15
set label_shadow_mode, 3
label 5/CA, "\316\261-Helix"
label 10/CA, "\316\262-Sheet"

# italic
set label_font_id, 16

# make bigger
set label_size, 50

Unicode Fonts

Notice the Angstrom and superscript 2 characters. You can add other characters as well.

PyMOL gives you the flexibility to use encoded unicode fonts. This allows us to insert various symbols, like the symbol used for Angstrom. Here are the steps to insert a character from the unicode character set.

  • Find the code for your character at Unicode Charts. The Angstrom character, is u"\u00c5" and is u"\u00b1".
  • Label the selection. For simple strings, just type the string in double quote, -- "like this" -- and append to the end of that .encode('utf-8') -- "like this".encode('utf-8'). A working example is shown here,
# label residue 30 with "4.1 Ang^2 +/- 0.65 Ang^2; see the image at right
label i. 30, "4.1" + u"\u00c5\u00b2  \u00b1 0.65 \u00c5\u00b2 ".encode('utf-8')