Difference between revisions of "Label font id"

From PyMOLWiki
Jump to navigation Jump to search
(utf-8)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Overview ==
+
The [[label_font_id]] setting sets the typeface (font family) for atom [[label|labels]].
Set which fonts PyMol uses to render labels.
 
  
 
== Syntax ==
 
== Syntax ==
 +
 
<source lang="python">
 
<source lang="python">
set label_font_id, 10 # use font no. 10
+
# use "Serif Bold" font family
set label_font_id, 11 # use font no. 11
+
set label_font_id, 10
set label_font_id, 12 # use font no. 12
 
 
</source>
 
</source>
  
Note: available font ids 10-16.
+
== Available Font Families ==
 +
 
 +
''Font IDs 0-4 were fixed size GLUT fonts, their support was dropped in PyMOL 1.6.''
 +
 
 +
{| class="wikitable"
 +
!Name!!label_font_id
 +
|-
 +
|Sans||5
 +
|-
 +
|Sans Oblique||6
 +
|-
 +
|Sans Bold||7
 +
|-
 +
|Sans Bold Oblique||8
 +
|-
 +
|Serif||9
 +
|-
 +
|Serif Oblique||17
 +
|-
 +
|Serif Bold||10
 +
|-
 +
|Serif Bold Oblique||18
 +
|-
 +
|Mono||11
 +
|-
 +
|Mono Oblique||12
 +
|-
 +
|Mono Bold||13
 +
|-
 +
|Mono Bold Oblique||14
 +
|-
 +
|Gentium Roman||15
 +
|-
 +
|Gentium Italic||16
 +
|}
 +
 
 +
== Special Characters ==
 +
 
 +
Several [http://www.unicode.org/ Unicode] characters are supported.
 +
They can be entered with [https://docs.python.org/2/howto/unicode.html#unicode-literals-in-python-source-code unicode literals] as 4-digit hexadecimal escape sequences.
 +
 
 +
'''Example characters''' (find the code for your character at [http://www.unicode.org/charts Unicode Charts]):
 +
 
 +
{| class="wikitable"
 +
!Code!!Character!!Name
 +
|-
 +
|<code>u"\u03b1"</code>||α||Alpha
 +
|-
 +
|<code>u"\u03b2"</code>||β||Beta
 +
|-
 +
|<code>u"\u00c5"</code>||Å||Ångström
 +
|-
 +
|<code>u"\u00b1"</code>||±||plus/minus
 +
|-
 +
|<code>u"\u00b2"</code>||²||superscript 2
 +
|}
 +
 
 +
== Example 1 ==
 +
 
 +
[[Image:New_fonts.jpeg|thumb|The alpha and beta are Unicode characters.]]
 +
 
 +
<source lang="python">
 +
# if Python is configured with utf-8 default encoding (all incentive builds)
 +
label  5/CA, u"\u03b1-Helix"
 +
label 10/CA, u"\u03b2-Sheet"
 +
 
 +
# if Python is configured differently, explicit utf-8 encoding is necessary
 +
label  5/CA, u"\u03b1-Helix".encode("utf-8")
 +
label 10/CA, u"\u03b2-Sheet".encode("utf-8")
 +
 
 +
# italic
 +
set label_font_id, 16
 +
 
 +
# make bigger
 +
set label_size, 50
 +
 
 +
# cast shadows in ray tracing
 +
set label_shadow_mode, 3
 +
</source>
 +
 
 +
== Example 2 ==
 +
 
 +
[[Image:Font_ex.png|300px|thumb|right|Notice the Angstrom and superscript 2 characters.  You can add other characters as well.]]
 +
 
 +
<source lang="python">
 +
# label residue 30 with "4.1 Ang^2 +/- 0.65 Ang^2
 +
label i. 30, "4.1" + u"\u00c5\u00b2  \u00b1 0.65 \u00c5\u00b2 "
 +
</source>
 +
 
 +
== See Also ==
 +
 
 +
* [[label]]
 +
* [[label_size]]
 +
* [[label_shadow_mode]]
  
 
[[Category:Settings|Label font id]]
 
[[Category:Settings|Label font id]]
 
[[Category:Labeling|Label font id]]
 
[[Category:Labeling|Label font id]]

Latest revision as of 05:36, 2 August 2017

The label_font_id setting sets the typeface (font family) for atom labels.

Syntax

# use "Serif Bold" font family
set label_font_id, 10

Available Font Families

Font IDs 0-4 were fixed size GLUT fonts, their support was dropped in PyMOL 1.6.

Name label_font_id
Sans 5
Sans Oblique 6
Sans Bold 7
Sans Bold Oblique 8
Serif 9
Serif Oblique 17
Serif Bold 10
Serif Bold Oblique 18
Mono 11
Mono Oblique 12
Mono Bold 13
Mono Bold Oblique 14
Gentium Roman 15
Gentium Italic 16

Special Characters

Several Unicode characters are supported. They can be entered with unicode literals as 4-digit hexadecimal escape sequences.

Example characters (find the code for your character at Unicode Charts):

Code Character Name
u"\u03b1" α Alpha
u"\u03b2" β Beta
u"\u00c5" Å Ångström
u"\u00b1" ± plus/minus
u"\u00b2" ² superscript 2

Example 1

The alpha and beta are Unicode characters.
# if Python is configured with utf-8 default encoding (all incentive builds)
label  5/CA, u"\u03b1-Helix"
label 10/CA, u"\u03b2-Sheet"

# if Python is configured differently, explicit utf-8 encoding is necessary
label  5/CA, u"\u03b1-Helix".encode("utf-8")
label 10/CA, u"\u03b2-Sheet".encode("utf-8")

# italic
set label_font_id, 16

# make bigger
set label_size, 50

# cast shadows in ray tracing
set label_shadow_mode, 3

Example 2

Notice the Angstrom and superscript 2 characters. You can add other characters as well.
# label residue 30 with "4.1 Ang^2 +/- 0.65 Ang^2
label i. 30, "4.1" + u"\u00c5\u00b2  \u00b1 0.65 \u00c5\u00b2 "

See Also