Tinkr2/4.2/AphelionCore/AphelionCore/Helpers/FontManager.cs
/// <summary>
/// Computes the total extent of a text for a specific font, similar to <see cref="Font.ComputeExtent(string, out int, out int)"/>
/// </summary>
/// <param name="font">Font to use</param>
/// <param name="value">Value to compute extent for</param>
/// <returns>Returns the total text extent in pixel of the given value</returns>
/// <remarks>
/// A string containing multiple lines separated by an \n will be spitted and the extents of every line are summed up.
/// </remarks>
Computes the total extent of a text for a specific font, similar to
Computes the total extent of a text for a specific font similar to
public static size ComputeExtentEx(Font font, String value)
      {
         var sz = new size();
         if (value == null || value == string.Empty)
         {
            return new size(0, font.Height);
         }
         string[] lines = value.Split('\n');
         for (int i = 0; i < lines.Length; i++)
         {
            int w;
            int h;
            font.ComputeExtent(lines[i], out w, out h);
            if (w > sz.Width)
            {
               sz.Width = w;
            }
         }
         sz.Height = font.Height * lines.Length;
         return sz;
      }
public static size ComputeExtentEx ( Font font , String value ) { var sz = new size ( ) ; if ( value == null || value == string . Empty ) { return new size ( 0 , font . Height ) ; } string [ ] lines = value . Split ( ' \n ' ) ; for ( int i = 0 ; i < lines . Length ; i ++ ) { int w ; int h ; font . ComputeExtent ( lines [ i ] , out w , out h ) ; if ( w > sz . Width ) { sz . Width = w ; } } sz . Height = font . Height * lines . Length ; return sz ; }
Computes the total extent of a text for a specific font, similar to
Computes the total extent of a text for a specific font similar to
Returns the total text extent in pixel of the given value
Returns the total text extent in pixel of the given value
font
Font
Font to use
Font to use
value
String
Value to compute extent for
Value to compute extent for
remarks
A string containing multiple lines separated by an \n will be spitted and the extents of every line are summed up.
A string containing multiple lines separated by an \ n will be spitted and the extents of every line are summed up .