OEFont
class OEFont
The OEFont class encapsulates properties that determine the display style of texts.
Currently the OEFont class stores the following properties:
Property |
Get method |
Set method |
Corresponding namespace/class/type |
|---|---|---|---|
alignment |
|||
color |
|||
font family |
|||
font size |
None |
||
font style |
|||
hyperlink |
string |
||
rotation angle |
floating point number in range of \([0.0^{\circ}, 360.0^{\circ}]\) |
See also
OEImageBase.DrawTextmethod
Constructors
OEFont() -> OEFont
Default constructor that initializes an OEFont object with the following properties: See example in Figure: Example of drawing text with default OEFont object.
Property |
Default value |
|---|---|
alignment |
|
color |
|
font family |
|
font size |
12 |
hyperlink |
empty string (i.e. no hyperlink) |
font style |
|
rotation angles |
0.0 (i.e. no rotation) |
Example of drawing text with default OEFont object
OEFont(color: OEColor) -> OEFont
Constructor that initializes an OEFont object with the default parameters and the given OEColor.
OEFont(family: int, style: int, size: int, align: int,
color: OEColor, rotangle: float = 0.0) -> OEFont
Constructor that initializes an OEFont object with the given parameters.
- family
The family of the font. This value has to be from the
OEFontFamilynamespace. See alsoOEFont.SetFamilymethod.- style
The style of the font. This value has to be from the
OEFontStylenamespace. See alsoOEFont.SetSizemethod.- size
The size of the font. See also
OEFont.SetSizemethod.- align
The alignment of the text. This value has to be from the
OEAlignmentnamespace. See alsoOEFont.SetAlignmentmethod.- color
The color of the font. See also
OEFont.SetColormethod.- rotangle
The rotation angle of the text. The default value is 0.0 which means no rotation is applied i.e. the text using the OEFont object is rendered horizontally. See also
OEFont.SetRotationAnglemethod.
OEFont(arg2: OEFont) -> OEFont
Copy constructors.
GetAlignment
GetAlignment() -> int
Returns the alignment property of the OEFont
object.
The returned value is taken from the OEAlignment
namespace.
See also
OEFont.SetAlignmentmethodOEAlignmentnamespace
GetColor
GetColor() -> OEColor
Returns the color of the OEFont object.
See also
OEFont.SetColormethodOEColor class
GetFamily
GetFamily() -> int
Returns the font family property of the OEFont
object.
The returned value is taken from the OEFontFamily
namespace.
See also
OEFont.SetFamilymethodOEFontFamilynamespace
GetHyperlink
GetHyperlink() -> str
Returns the URI string associated with the OEFont object.
See also
OEFont.HasHyperlinkmethodOEFont.SetHyperlinkmethod
GetRotationAngle
GetRotationAngle() -> float
Returns the angle of the rotation that is used to render a text when using the OEFont object.
See also
OEFont.SetRotationAnglemethod
GetSize
GetSize() -> int
Returns the size of the OEFont object.
See also
OEFont.SetSizemethod
GetStyle
GetStyle() -> int
Returns the font style property of the OEFont
object.
The returned value is taken from the OEFontStyle
namespace.
See also
OEFont.SetStylemethodOEFontStylenamespace
HasHyperlink
HasHyperlink() -> bool
Returns whether an URI string is associated with the OEFont object.
See also
OEFont.GetHyperlinkmethodOEFont.SetHyperlinkmethod
SetAlignment
SetAlignment(arg2: int) -> None
Sets the alignment property of the OEFont object.
- align
This value has to be from the
OEAlignmentnamespace.
Example (Figure: Example of using the SetAlignment method)
font = oedepict.OEFont()
font.SetAlignment(oedepict.OEAlignment_Right)
Example of using the SetAlignment method
See also
OEFont.GetAlignmentmethodOEAlignmentnamespace
SetColor
SetColor(color: OEColor) -> None
Sets the color of the OEFont object.
Example (Figure: Example of using the SetColor method)
font = oedepict.OEFont()
font.SetColor(oechem.OERed)
Example of using the SetColor method
See also
OEFont.GetColormethodOEColor class
SetFamily
SetFamily(arg2: int) -> None
Sets the font family property of the OEFont object.
- family
This value has to be from the
OEFontFamilynamespace.
Example (Figure: Example of using the SetFamily method)
font = oedepict.OEFont()
font.SetFamily(oedepict.OEFontFamily_Times)
Example of using the SetFamily method
See also
OEFont.GetFamilymethodOEFontFamilynamespace
SetHyperlink
SetHyperlink(link: str) -> None
Associates URI string with the OEFont object.
- uri
After associating a valid URI with a OEFont object, texts drawn with the given font become “click-able” and by clicking on them will send you to the given address.
Example (Figure: Example of using the SetHyperlink method)
mol = oechem.OEGraphMol()
oechem.OESmilesToMol(mol, "OC(=O)c1ccccc1")
oedepict.OEPrepareDepiction(mol)
width, height = 150.0, 150.0
image = oedepict.OEImage(width, height)
opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
opts.SetTitleLocation(oedepict.OETitleLocation_Bottom)
# associate font with URI
font = oedepict.OEFont(oedepict.OEFontFamily_Default, oedepict.OEFontStyle_Default, 10,
oedepict.OEAlignment_Center, oechem.OEBlue)
font.SetHyperlink("http://www.eyesopen.com/oedepict-tk")
opts.SetTitleFont(font)
mol.SetTitle("Generated by OEDepict")
disp = oedepict.OE2DMolDisplay(mol, opts)
oedepict.OERenderMolecule(image, disp)
oedepict.OEWriteImage("DepictMolWithHyperlink.pdf", image)
oedepict.OEWriteImage("DepictMolWithHyperlink.svg", image)
Example of using the SetHyperlink method
(Clicking on the blue text at the bottom send you to the OEDepict TK web page)
Note
Associating texts with hyperlinks is only available for .pdf
and .svg image formats.
Warning
OEDepict TK does not check whether the given string is a valid URI.
It is recommended to always keep the URI scheme
prefix of the URI string for the sake
of compatibility.
For example, some application can interpret the www.eyesopen.com string as a valid
URI,
others only work when using http://www.eyesopen.com.
See also
OEFont.GetHyperlinkmethodOEFont.GetHyperlinkmethod
SetRotationAngle
SetRotationAngle(arg2: float) -> None
Sets the rotation angle of the OEFont object.
- angle
The rotation angle of the text (in degrees). The value of the angle has to be in a range of \([0.0^{\circ}, 360.0^{\circ}]\).
Example (Figure: Example of using the SetRotationAngle method)
font = oedepict.OEFont()
font.SetRotationAngle(180.0)
Example of using the SetRotationAngle method
Note
The angles are interpreted in an anti-clockwise direction. The \(0.0^{\circ}\) and \(360.0^{\circ}\) degrees are at the 3 o’clock position i.e. the text is rendered horizontally. While the \(180.0^{\circ}\) degrees corresponds to rendering the text upside down. See examples in Figure: Example of drawing texts with various rotation angle.
Example of drawing texts with various rotation angles
See also
OEFont.GetRotationAnglemethod
SetSize
SetSize(arg2: int) -> None
Sets the size of the OEFont object.
Example (Figure: Example of using the SetSize method)
font = oedepict.OEFont()
font.SetSize(30)
Example of using the SetSize method
See also
OEFont.GetSizemethod
SetStyle
SetStyle(arg2: int) -> None
Sets the font style property (such as bold, italic etc.) of the OEFont object.
- style
This value has to be from the
OEFontStylenamespace.
Example (Figure: Example of using the SetStyle method)
font = oedepict.OEFont()
font.SetStyle(oedepict.OEFontStyle_Bold | oedepict.OEFontStyle_Italic)
Example of using the SetStyle method
See also
OEFont.GetStylemethodOEFontStylenamespace