.. oe:namespace:: OEDepict

.. meta::
   :keywords: OEFont, Font


.. _OEDepict_OEFont:

.. oe:class:: OEFont

   .. oe:api::

      class OEFont

   The :ref:`OEFont <OEDepict_OEFont>` class encapsulates properties that determine
   the display style of texts.

   Currently the :ref:`OEFont <OEDepict_OEFont>` class stores the following properties:

   .. list-table::
      :widths: 60 100 100 150
      :header-rows: 1

      * - Property
        - Get method
        - Set method
        - Corresponding namespace/class/type
      * - alignment
        - :oe:meth:`GetAlignment<OEDepict::OEFont::GetAlignment>`
        - :oe:meth:`SetAlignment<OEDepict::OEFont::SetAlignment>`
        - :oe:constns:`OEDepict::OEAlignment`
      * - color
        - :oe:meth:`GetColor<OEDepict::OEFont::GetColor>`
        - :oe:meth:`SetColor<OEDepict::OEFont::SetColor>`
        - :ref:`OEColor <OESystem_OEColor>`
      * - font family
        - :oe:meth:`GetFamily<OEDepict::OEFont::GetFamily>`
        - :oe:meth:`SetFamily<OEDepict::OEFont::SetFamily>`
        - :oe:constns:`OEDepict::OEFontFamily`
      * - font size
        - :oe:meth:`GetSize<OEDepict::OEFont::GetSize>`
        - :oe:meth:`SetSize<OEDepict::OEFont::SetSize>`
        - None
      * - font style
        - :oe:meth:`GetStyle<OEDepict::OEFont::GetStyle>`
        - :oe:meth:`SetStyle<OEDepict::OEFont::SetStyle>`
        - :oe:constns:`OEDepict::OEFontStyle`
      * - hyperlink
        - :oe:meth:`GetHyperlink<OEDepict::OEFont::GetHyperlink>` / :oe:meth:`HasHyperlink<OEDepict::OEFont::HasHyperlink>`
        - :oe:meth:`SetHyperlink<OEDepict::OEFont::SetHyperlink>`
        - string
      * - rotation angle
        - :oe:meth:`GetRotationAngle<OEDepict::OEFont::GetRotationAngle>`
        - :oe:meth:`SetRotationAngle<OEDepict::OEFont::SetRotationAngle>`
        - floating point number in range of :math:`[0.0^{\circ}, 360.0^{\circ}]`


   ..  seealso::

       * :oe:meth:`OEDepict::OEImageBase::DrawText` method


   .. ################################################################
      # Constructors
      ################################################################

   .. oe:method:: Constructors

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEFont()

      .. oe:language:: python

         .. oe:api:: python

            OEFont() -> OEFont

      Default constructor that initializes an :ref:`OEFont <OEDepict_OEFont>`
      object with the following properties:
      See example in :ref:`Figure: Example of drawing text with default OEFont object<figure_OEFont_Default>`.

      .. list-table:: Default parameters of OEFont
         :widths: 100 100
         :header-rows: 1

         * - Property
           - Default value
         * - alignment
           - :oe:const:`OEDepict::OEAlignment::Default`
         * - color
           - :oe:const:`OEBlack<OESystem::OESystem::OEBlack>` = OEColor(0,0,0)
         * - font family
           - :oe:const:`OEDepict::OEFontFamily::Default`
         * - font size
           - 12
         * - hyperlink
           - empty string (i.e. no hyperlink)
         * - font style
           - :oe:const:`OEDepict::OEFontStyle::Default`
         * - rotation angles
           - 0.0 (i.e. no rotation)

      .. _figure_OEFont_Default:

      .. figure:: ../images/OEFont_Default.*
         :align:  center

         **Example of drawing text with default OEFont object**

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEFont(const OESystem::OEColor& color)

      .. oe:language:: python

         .. oe:api:: python

            OEFont(color: OEColor) -> OEFont

      Constructor that initializes an :ref:`OEFont <OEDepict_OEFont>` object
      with the default parameters and the given :ref:`OEColor <OESystem_OEColor>`.

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEFont(unsigned int family, unsigned int style, unsigned int size,
                   unsigned int align, const OESystem::OEColor& color,
                   double rotangle = 0.0)

      .. oe:language:: python

         .. oe:api:: python

            OEFont(family: int, style: int, size: int, align: int,
                   color: OEColor, rotangle: float = 0.0) -> OEFont

      Constructor that initializes an :ref:`OEFont <OEDepict_OEFont>` object
      with the given parameters.

      *family*
         The family of the font.
         This value has to be from the :oe:constns:`OEDepict::OEFontFamily`
         namespace.
         See also :oe:meth:`OEDepict::OEFont::SetFamily` method.

      *style*
         The style of the font.
         This value has to be from the :oe:constns:`OEDepict::OEFontStyle`
         namespace.
         See also :oe:meth:`OEDepict::OEFont::SetSize` method.
      *size*
         The size of the font.
         See also :oe:meth:`OEDepict::OEFont::SetSize` method.

      *align*
         The alignment of the text.
         This value has to be from the :oe:constns:`OEDepict::OEAlignment`
         namespace.
         See also :oe:meth:`OEDepict::OEFont::SetAlignment` method.

      *color*
         The color of the font.
         See also :oe:meth:`OEDepict::OEFont::SetColor` method.

      *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 :ref:`OEFont <OEDepict_OEFont>` object is rendered
         horizontally.
         See also :oe:meth:`OEDepict::OEFont::SetRotationAngle` method.

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEFont(const OEFont& rhs)

      .. oe:language:: python

         .. oe:api:: python

            OEFont(arg2: OEFont) -> OEFont

      Copy constructors.


   .. oe:method:: operator=
      :language: c++

      .. oe:api::

         OEFont &operator=(const OEFont &rhs)

      Assignment operator.


   .. oe:method:: operator!=
      :language: c++

      .. oe:api::

         bool operator!=(const OEFont &rhs) const

      Determines whether two :ref:`OEFont <OEDepict_OEFont>` objects are
      different.
      Two :ref:`OEFont <OEDepict_OEFont>` objects are considered different
      if any of their properties (such as color, size, etc.) are
      different.


   .. oe:method:: operator==
      :language: c++

      .. oe:api::

         bool operator==(const OEFont &rhs) const

      Determines whether two :ref:`OEFont <OEDepict_OEFont>` objects are
      equal.
      Two :ref:`OEFont <OEDepict_OEFont>` objects are considered equivalent
      only if all of their properties (such as color, size, etc.) are
      identical.


   .. oe:method:: GetAlignment

      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned int GetAlignment() const

      .. oe:language:: python

         .. oe:api:: python

            GetAlignment() -> int

      Returns the *alignment* property of the :ref:`OEFont <OEDepict_OEFont>`
      object.
      The returned value is taken from the :oe:constns:`OEDepict::OEAlignment`
      namespace.

      .. seealso::

         * :oe:meth:`OEDepict::OEFont::SetAlignment` method
         * :oe:constns:`OEDepict::OEAlignment` namespace


   .. oe:method:: GetColor

      .. oe:language:: c++ java csharp

         .. oe:api::

            const OESystem::OEColor& GetColor() const

      .. oe:language:: python

         .. oe:api:: python

            GetColor() -> OEColor

      Returns the color of the :ref:`OEFont <OEDepict_OEFont>` object.

      .. seealso::

         * :oe:meth:`OEDepict::OEFont::SetColor` method
         * :ref:`OEColor <OESystem_OEColor>` class


   .. oe:method:: GetFamily

      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned int GetFamily() const

      .. oe:language:: python

         .. oe:api:: python

            GetFamily() -> int

      Returns the *font family* property of the :ref:`OEFont <OEDepict_OEFont>`
      object.
      The returned value is taken from the :oe:constns:`OEDepict::OEFontFamily`
      namespace.

      .. seealso::

         * :oe:meth:`OEDepict::OEFont::SetFamily` method
         * :oe:constns:`OEDepict::OEFontFamily` namespace


   .. oe:method:: GetHyperlink

      .. oe:language:: c++ java csharp

         .. oe:api::

            const std::string& GetHyperlink() const

      .. oe:language:: python

         .. oe:api:: python

            GetHyperlink() -> str

      Returns the URI string associated with the :ref:`OEFont <OEDepict_OEFont>`
      object.

      .. seealso::

         * :oe:meth:`OEDepict::OEFont::HasHyperlink` method
         * :oe:meth:`OEDepict::OEFont::SetHyperlink` method


   .. oe:method:: GetRotationAngle

      .. oe:language:: c++ java csharp

         .. oe:api::

            double GetRotationAngle() const

      .. oe:language:: python

         .. oe:api:: python

            GetRotationAngle() -> float

      Returns the angle of the rotation that is used to render a
      text when using the :ref:`OEFont <OEDepict_OEFont>` object.

      .. seealso::

         * :oe:meth:`OEDepict::OEFont::SetRotationAngle` method


   .. oe:method:: GetSize

      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned int GetSize() const

      .. oe:language:: python

         .. oe:api:: python

            GetSize() -> int

      Returns the size of the :ref:`OEFont <OEDepict_OEFont>` object.

      .. seealso::

         * :oe:meth:`OEDepict::OEFont::SetSize` method


   .. oe:method:: GetStyle

      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned int GetStyle() const

      .. oe:language:: python

         .. oe:api:: python

            GetStyle() -> int

      Returns the *font style* property of the :ref:`OEFont <OEDepict_OEFont>`
      object.
      The returned value is taken from the :oe:constns:`OEDepict::OEFontStyle`
      namespace.

      .. seealso::

         * :oe:meth:`OEDepict::OEFont::SetStyle` method
         * :oe:constns:`OEDepict::OEFontStyle` namespace


   .. oe:method:: HasHyperlink

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool HasHyperlink() const

      .. oe:language:: python

         .. oe:api:: python

            HasHyperlink() -> bool

      Returns whether an URI string is associated with the :ref:`OEFont <OEDepict_OEFont>`
      object.

      .. seealso::

         * :oe:meth:`OEDepict::OEFont::GetHyperlink` method
         * :oe:meth:`OEDepict::OEFont::SetHyperlink` method


   .. oe:method:: SetAlignment

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetAlignment(unsigned int align)

      .. oe:language:: python

         .. oe:api:: python

            SetAlignment(arg2: int) -> None

      Sets the *alignment* property of the :ref:`OEFont <OEDepict_OEFont>`
      object.

      *align*
         This value has to be from the :oe:constns:`OEDepict::OEAlignment`
         namespace.

      Example (:ref:`Figure: Example of using the SetAlignment method<figure_OEFont_SetAlignment>`)

      .. oe:source:: OEFont_SetProperties.py
         :language: python
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-ALIGNMENT

      .. oe:source:: OEFont_SetProperties.cpp
         :language: c++
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-ALIGNMENT

      .. oe:source:: OEFont_SetProperties.java
         :language: java
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-ALIGNMENT

      .. oe:source:: OEFont_SetProperties.cs
         :language: csharp
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-ALIGNMENT

      .. _figure_OEFont_SetAlignment:

      .. figure:: ../images/OEFont_SetAlignment.*
         :align:  center

         **Example of using the SetAlignment method**

      .. seealso::

         * :oe:meth:`OEDepict::OEFont::GetAlignment` method
         * :oe:constns:`OEDepict::OEAlignment` namespace


   .. oe:method:: SetColor

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetColor(const OESystem::OEColor& color)

      .. oe:language:: python

         .. oe:api:: python

            SetColor(color: OEColor) -> None

      Sets the color of the :ref:`OEFont <OEDepict_OEFont>` object.

      Example (:ref:`Figure: Example of using the SetColor method<figure_OEFont_SetColor>`)

      .. oe:source:: OEFont_SetProperties.py
         :language: python
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-COLOR

      .. oe:source:: OEFont_SetProperties.cpp
         :language: c++
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-COLOR

      .. oe:source:: OEFont_SetProperties.java
         :language: java
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-COLOR

      .. oe:source:: OEFont_SetProperties.cs
         :language: csharp
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-COLOR

      .. _figure_OEFont_SetColor:

      .. figure:: ../images/OEFont_SetColor.*
         :align:  center

         **Example of using the SetColor method**

      .. seealso::

         * :oe:meth:`OEDepict::OEFont::GetColor` method
         * :ref:`OEColor <OESystem_OEColor>` class


   .. oe:method:: SetFamily

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetFamily(unsigned int family)

      .. oe:language:: python

         .. oe:api:: python

            SetFamily(arg2: int) -> None

      Sets the *font family* property of the :ref:`OEFont <OEDepict_OEFont>`
      object.

      *family*
         This value has to be from the :oe:constns:`OEDepict::OEFontFamily`
         namespace.

      Example (:ref:`Figure: Example of using the SetFamily method<figure_OEFont_SetFamily>`)

      .. oe:source:: OEFont_SetProperties.py
         :language: python
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-FAMILY

      .. oe:source:: OEFont_SetProperties.cpp
         :language: c++
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-FAMILY

      .. oe:source:: OEFont_SetProperties.java
         :language: java
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-FAMILY

      .. oe:source:: OEFont_SetProperties.cs
         :language: csharp
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-FAMILY

      .. _figure_OEFont_SetFamily:

      .. figure:: ../images/OEFont_SetFamily.*
         :align:  center

         **Example of using the SetFamily method**

      .. seealso::

         * :oe:meth:`OEDepict::OEFont::GetFamily` method
         * :oe:constns:`OEDepict::OEFontFamily` namespace


   .. oe:method:: SetHyperlink

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetHyperlink(const string& uri)

      .. oe:language:: python

         .. oe:api:: python

            SetHyperlink(link: str) -> None

      Associates URI string with the :ref:`OEFont <OEDepict_OEFont>`
      object.

      *uri*
         After associating a **valid** URI with a :ref:`OEFont <OEDepict_OEFont>`
         object, texts drawn with the given font become "click-able"
         and by clicking on them will send you to the given address.

      .. meta:
         :keywords: URI, hyperlink

      Example (:ref:`Figure: Example of using the SetHyperlink method<figure_OEFont_SetHyperlink>`)

      .. oe:source:: DepictMolWithHyperlink.py
         :language: python
         :noindent:
         :frag:     SNIPPET-DEPICT-MOL-WITH-HYPERLINK

      .. oe:source:: DepictMolWithHyperlink.cpp
         :language: c++
         :noindent:
         :frag:     SNIPPET-DEPICT-MOL-WITH-HYPERLINK

      .. oe:source:: DepictMolWithHyperlink.java
         :language: java
         :noindent:
         :frag:     SNIPPET-DEPICT-MOL-WITH-HYPERLINK

      .. oe:source:: DepictMolWithHyperlink.cs
         :language: csharp
         :noindent:
         :frag:     SNIPPET-DEPICT-MOL-WITH-HYPERLINK

      .. _figure_OEFont_SetHyperlink:

      .. figure:: ../images/DepictMolWithHyperlink.*
         :align:  center
         :width: 250 pt

         **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 :file:`.pdf`
         and :file:`.svg` image formats.

      .. warning::

         **OEDepict TK** does **not** check whether the given
         string is a valid `URI <http://en.wikipedia.org/wiki/Uniform_resource_identifier>`_.

         It is recommended to always keep the `URI scheme <http://en.wikipedia.org/wiki/URI_scheme>`_
         prefix of the `URI <http://en.wikipedia.org/wiki/Uniform_resource_identifier>`_ string for the sake
         of compatibility.
         For example, some application can interpret the ``www.eyesopen.com`` string as a valid
         `URI <http://en.wikipedia.org/wiki/Uniform_resource_identifier>`_,
         others only work when using ``http://www.eyesopen.com``.

      .. seealso::

         * :oe:meth:`OEDepict::OEFont::GetHyperlink` method
         * :oe:meth:`OEDepict::OEFont::GetHyperlink` method


   .. oe:method:: SetRotationAngle

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetRotationAngle(double angle)

      .. oe:language:: python

         .. oe:api:: python

            SetRotationAngle(arg2: float) -> None

      Sets the rotation angle of the :ref:`OEFont <OEDepict_OEFont>` object.

      *angle*
         The rotation angle of the text (in degrees).
         The value of the angle has to be in a range of
         :math:`[0.0^{\circ}, 360.0^{\circ}]`.

      Example (:ref:`Figure: Example of using the SetRotationAngle method<figure_OEFont_SetRotationAngle>`)

      .. oe:source:: OEFont_SetProperties.py
         :language: python
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-ROTATION-ANGLE

      .. oe:source:: OEFont_SetProperties.cpp
         :language: c++
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-ROTATION-ANGLE

      .. oe:source:: OEFont_SetProperties.java
         :language: java
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-ROTATION-ANGLE

      .. oe:source:: OEFont_SetProperties.cs
         :language: csharp
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-ROTATION-ANGLE

      .. _figure_OEFont_SetRotationAngle:

      .. figure:: ../images/OEFont_SetRotationAngle.*
         :align:  center

         **Example of using the SetRotationAngle method**

      .. note::

         The angles are interpreted in an anti-clockwise direction.
         The :math:`0.0^{\circ}` and :math:`360.0^{\circ}`
         degrees are at the 3 o'clock position *i.e.* the text is
         rendered horizontally.
         While the :math:`180.0^{\circ}` degrees corresponds to
         rendering the text upside down.
         See examples in :ref:`Figure: Example of drawing texts with various
         rotation angle<figure_OEImageBase_DrawText_Rotations>`.

      .. _figure_OEImageBase_DrawText_Rotations:

      .. figure:: ../images/OEImageBase-DrawText-Rotations.*
         :align:  center
         :scale:  100

         **Example of drawing texts with various rotation angles**

      .. seealso::

         * :oe:meth:`OEDepict::OEFont::GetRotationAngle` method


   .. oe:method:: SetSize

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetSize(unsigned int size)

      .. oe:language:: python

         .. oe:api:: python

            SetSize(arg2: int) -> None

      Sets the size of the :ref:`OEFont <OEDepict_OEFont>` object.

      Example (:ref:`Figure: Example of using the SetSize method<figure_OEFont_SetSize>`)

      .. oe:source:: OEFont_SetProperties.py
         :language: python
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-SIZE

      .. oe:source:: OEFont_SetProperties.cpp
         :language: c++
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-SIZE

      .. oe:source:: OEFont_SetProperties.java
         :language: java
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-SIZE

      .. oe:source:: OEFont_SetProperties.cs
         :language: csharp
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-SIZE

      .. _figure_OEFont_SetSize:

      .. figure:: ../images/OEFont_SetSize.*
         :align:  center

         **Example of using the SetSize method**

      .. seealso::

         * :oe:meth:`OEDepict::OEFont::GetSize` method


   .. oe:method:: SetStyle

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetStyle(unsigned int style)

      .. oe:language:: python

         .. oe:api:: python

            SetStyle(arg2: int) -> None

      Sets the *font style* property (such as **bold**, *italic* etc.)
      of the :ref:`OEFont <OEDepict_OEFont>` object.

      *style*
         This value has to be from the :oe:constns:`OEDepict::OEFontStyle`
         namespace.

      Example (:ref:`Figure: Example of using the SetStyle method<figure_OEFont_SetStyle>`)

      .. oe:source:: OEFont_SetProperties.py
         :language: python
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-STYLE

      .. oe:source:: OEFont_SetProperties.cpp
         :language: c++
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-STYLE

      .. oe:source:: OEFont_SetProperties.java
         :language: java
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-STYLE

      .. oe:source:: OEFont_SetProperties.cs
         :language: csharp
         :noindent:
         :frag:     SNIPPET-OEFONT-SET-STYLE

      .. _figure_OEFont_SetStyle:

      .. figure:: ../images/OEFont_SetStyle.*
         :align:  center

         **Example of using the SetStyle method**

      .. seealso::

         * :oe:meth:`OEDepict::OEFont::GetStyle` method
         * :oe:constns:`OEDepict::OEFontStyle` namespace
