This is a read-only mirror of pymolwiki.org

Difference between revisions of "Label font id"

From PyMOL Wiki
Jump to navigation Jump to search
 
m (Fixed Unicdoe)
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
== Overview ==
 
== Overview ==
Set which fonts PyMol uses to render labels.
+
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 ==
 
== Syntax ==
Line 9: Line 9:
 
</source>
 
</source>
  
Note: available font ids 10-16.
+
== UTF-8 Fonts ==
 +
[[Image:New_fonts.jpeg|thumb|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:
 +
<source lang="python">
 +
# 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
 +
</source>
 +
 
 +
==Unicode Fonts==
 +
[[Image:Font_ex.png|300px|thumb|right|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 [http://www.unicode.org/charts Unicode Charts].  The Angstrom character, <math>\textrm{\AA}</math> is u"\u00c5" and <math>\pm</math> 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,
 +
<source lang="python">
 +
# 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')
 +
</source>
 +
 
 +
 
 +
 
 +
[[Category:Settings|Label font id]]
 +
[[Category:Labeling|Label font id]]

Revision as of 00:05, 11 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, <math>\textrm{\AA}</math> is u"\u00c5" and <math>\pm</math> 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')