.. include:: ../substitutions

.. oe:namespace:: OEDepict

.. meta::
   :keywords: OEReduceFontSizeToFit

.. _OEDepict_OEReduceFontSizeToFit:


.. oe:function:: OEReduceFontSizeToFit


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

      .. oe:api::

         unsigned int OEReduceFontSizeToFit(const std::string& text,
                                            const OEFont& font,
                                            unsigned int minfontsize,
                                            double maxwidth)

   .. oe:language:: python

      .. oe:api:: python

         OEReduceFontSizeToFit(text: str, font: OEFont, minfontsize: int,
                               maxwidth: float) -> int

   The :oe:func:`OEDepict::OEReduceFontSizeToFit` function
   gradually reduces the font size until the specified string can be drawn
   without exceeding the width limit.

   *text*
      The string for which the font size is calculated.

   *font*
      The :ref:`OEFont <OEDepict_OEFont>` object that defines the style of
      the depiction.

   *minfontsize*
      The minimum font size that can be returned.

   *maxwidth*
      The width that can not be exceeded when drawing the string.

   .. seealso::

      * :oe:func:`OEDepict::OEEstimateTextWidth` function
      * :ref:`OEFont <OEDepict_OEFont>` class
