# GrapeCity.Documents.Drawing.GcGraphics.MeasureString

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_Documents_Drawing_GcGraphics_MeasureString_" data-uid="GrapeCity.Documents.Drawing.GcGraphics.MeasureString*">MeasureString Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_Documents_Drawing_GcGraphics_MeasureString_" data-uid="GrapeCity.Documents.Drawing.GcGraphics.MeasureString*"></a>
<h4 id="GrapeCity_Documents_Drawing_GcGraphics_MeasureString_System_String_GrapeCity_Documents_Text_TextFormat_System_Drawing_SizeF_GrapeCity_Documents_Text_TextSplitOptions_System_Int32__" data-uid="GrapeCity.Documents.Drawing.GcGraphics.MeasureString(System.String,GrapeCity.Documents.Text.TextFormat,System.Drawing.SizeF,GrapeCity.Documents.Text.TextSplitOptions,System.Int32@)">MeasureString(string, TextFormat, SizeF, TextSplitOptions, out int)</h4>
<div class="markdown level1 summary"><p>Measures a string using a specified <a class="xref" href="GrapeCity.Documents.Text.TextFormat.html">TextFormat</a>,
available layout size and <a class="xref" href="GrapeCity.Documents.Text.TextSplitOptions.html">TextSplitOptions</a>.
Also calculates and returns in an output parameter the number of chars
that fit into the specified size.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public SizeF MeasureString(string text, TextFormat textFormat, SizeF layoutSize, TextSplitOptions splitOptions, out int fitCharCount)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function MeasureString(text As String, textFormat As TextFormat, layoutSize As SizeF, splitOptions As TextSplitOptions, ByRef fitCharCount As Integer) As SizeF</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">text</span></td>
      <td><p>The string to measure.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="GrapeCity.Documents.Text.TextFormat.html">TextFormat</a></td>
      <td><span class="parametername">textFormat</span></td>
      <td><p>The text format to use.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.sizef">SizeF</a></td>
      <td><span class="parametername">layoutSize</span></td>
      <td><p>The maximum available size for the layout.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="GrapeCity.Documents.Text.TextSplitOptions.html">TextSplitOptions</a></td>
      <td><span class="parametername">splitOptions</span></td>
      <td><p>The options controlling how to split the text if it does not fit into the specified size.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">fitCharCount</span></td>
      <td><p>OUT: The number of chars that fit into the specified size.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.sizef">SizeF</a></td>
      <td><p>The actual size needed to draw the string.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="GrapeCity_Documents_Drawing_GcGraphics_MeasureString_" data-uid="GrapeCity.Documents.Drawing.GcGraphics.MeasureString*"></a>
<h4 id="GrapeCity_Documents_Drawing_GcGraphics_MeasureString_System_String_GrapeCity_Documents_Text_TextFormat_System_Drawing_SizeF_System_Int32__" data-uid="GrapeCity.Documents.Drawing.GcGraphics.MeasureString(System.String,GrapeCity.Documents.Text.TextFormat,System.Drawing.SizeF,System.Int32@)">MeasureString(string, TextFormat, SizeF, out int)</h4>
<div class="markdown level1 summary"><p>Measures a string using a specified <a class="xref" href="GrapeCity.Documents.Text.TextFormat.html">TextFormat</a>,
available layout size and default split options (see <a class="xref" href="GrapeCity.Documents.Text.TextSplitOptions.html">TextSplitOptions</a>).
Also calculates and returns in an output parameter the number of chars
that fit into the specified size.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public SizeF MeasureString(string text, TextFormat textFormat, SizeF layoutSize, out int fitCharCount)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function MeasureString(text As String, textFormat As TextFormat, layoutSize As SizeF, ByRef fitCharCount As Integer) As SizeF</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">text</span></td>
      <td><p>The string to measure.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="GrapeCity.Documents.Text.TextFormat.html">TextFormat</a></td>
      <td><span class="parametername">textFormat</span></td>
      <td><p>The text format to use.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.sizef">SizeF</a></td>
      <td><span class="parametername">layoutSize</span></td>
      <td><p>The maximum available size for the layout.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">fitCharCount</span></td>
      <td><p>OUT: The number of chars that fit into the specified size.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.sizef">SizeF</a></td>
      <td><p>The actual size needed to draw the string.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="GrapeCity_Documents_Drawing_GcGraphics_MeasureString_" data-uid="GrapeCity.Documents.Drawing.GcGraphics.MeasureString*"></a>
<h4 id="GrapeCity_Documents_Drawing_GcGraphics_MeasureString_System_String_GrapeCity_Documents_Text_Font_System_Single_System_Nullable_System_Single__" data-uid="GrapeCity.Documents.Drawing.GcGraphics.MeasureString(System.String,GrapeCity.Documents.Text.Font,System.Single,System.Nullable{System.Single})">MeasureString(string, Font, float, float?)</h4>
<div class="markdown level1 summary"><p>Measures a string using a specified font, font size and layout width.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public SizeF MeasureString(string text, Font font, float fontSize, float? width = null)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function MeasureString(text As String, font As Font, fontSize As Single, Optional width As Single? = Nothing) As SizeF</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">text</span></td>
      <td><p>The string to measure.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="GrapeCity.Documents.Text.Font.html">Font</a></td>
      <td><span class="parametername">font</span></td>
      <td><p>The font to use.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.single">float</a></td>
      <td><span class="parametername">fontSize</span></td>
      <td><p>The font size to use.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.single">float</a>?</td>
      <td><span class="parametername">width</span></td>
      <td><p>The width allocated to draw the string, or null to indicate unlimited width.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.sizef">SizeF</a></td>
      <td><p>The size needed to draw the string.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="GrapeCity_Documents_Drawing_GcGraphics_MeasureString_" data-uid="GrapeCity.Documents.Drawing.GcGraphics.MeasureString*"></a>
<h4 id="GrapeCity_Documents_Drawing_GcGraphics_MeasureString_System_String_GrapeCity_Documents_Text_TextFormat_System_Nullable_System_Single__" data-uid="GrapeCity.Documents.Drawing.GcGraphics.MeasureString(System.String,GrapeCity.Documents.Text.TextFormat,System.Nullable{System.Single})">MeasureString(string, TextFormat, float?)</h4>
<div class="markdown level1 summary"><p>Measures a string using a specified <a class="xref" href="GrapeCity.Documents.Text.TextFormat.html">TextFormat</a>.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public SizeF MeasureString(string text, TextFormat textFormat, float? width = null)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function MeasureString(text As String, textFormat As TextFormat, Optional width As Single? = Nothing) As SizeF</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">text</span></td>
      <td><p>The string to measure.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="GrapeCity.Documents.Text.TextFormat.html">TextFormat</a></td>
      <td><span class="parametername">textFormat</span></td>
      <td><p>The text format to use.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.single">float</a>?</td>
      <td><span class="parametername">width</span></td>
      <td><p>The width allocated to draw the string, or null to indicate unlimited width.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.sizef">SizeF</a></td>
      <td><p>The size needed to draw the string.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
