# C1.Util.DX.DirectWrite.TextRenderer1.DrawUnderline

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Util_DX_DirectWrite_TextRenderer1_DrawUnderline_" data-uid="C1.Util.DX.DirectWrite.TextRenderer1.DrawUnderline*">DrawUnderline Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Util_DX_DirectWrite_TextRenderer1_DrawUnderline_" data-uid="C1.Util.DX.DirectWrite.TextRenderer1.DrawUnderline*"></a>
<h4 id="C1_Util_DX_DirectWrite_TextRenderer1_DrawUnderline_System_Object_System_Single_System_Single_C1_Util_DX_DirectWrite_GlyphOrientationAngle_C1_Util_DX_DirectWrite_Underline__System_IntPtr_" data-uid="C1.Util.DX.DirectWrite.TextRenderer1.DrawUnderline(System.Object,System.Single,System.Single,C1.Util.DX.DirectWrite.GlyphOrientationAngle,C1.Util.DX.DirectWrite.Underline@,System.IntPtr)">DrawUnderline(object, float, float, GlyphOrientationAngle, ref Underline, nint)</h4>
<div class="markdown level1 summary"><p>IDWriteTextLayout::Draw calls this function to instruct the client to draw an underline.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">HResult DrawUnderline(object clientDrawingContext, float baselineOriginX, float baselineOriginY, GlyphOrientationAngle orientationAngle, ref Underline underline, nint clientDrawingEffectPtr)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Function DrawUnderline(clientDrawingContext As Object, baselineOriginX As Single, baselineOriginY As Single, orientationAngle As GlyphOrientationAngle, ByRef underline As Underline, clientDrawingEffectPtr As IntPtr) As HResult</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.object">object</a></td>
      <td><span class="parametername">clientDrawingContext</span></td>
      <td><p>The application-defined drawing context passed to IDWriteTextLayout::Draw.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.single">float</a></td>
      <td><span class="parametername">baselineOriginX</span></td>
      <td><p>The pixel location (X-coordinate) at the baseline origin of the run where underline applies.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.single">float</a></td>
      <td><span class="parametername">baselineOriginY</span></td>
      <td><p>The pixel location (Y-coordinate) at the baseline origin of the run where underline applies.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Util.DX.DirectWrite.GlyphOrientationAngle.html">GlyphOrientationAngle</a></td>
      <td><span class="parametername">orientationAngle</span></td>
      <td><p>Orientation of the underline.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Util.DX.DirectWrite.Underline.html">Underline</a></td>
      <td><span class="parametername">underline</span></td>
      <td><p>Pointer to  a structure containing underline logical information.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.intptr">nint</a></td>
      <td><span class="parametername">clientDrawingEffectPtr</span></td>
      <td><p>Application-defined effect to apply to the underline. Usually this argument represents effects such as the foreground brush filling the interior of a line.</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="C1.Util.DX.HResult.html">HResult</a></td>
      <td><p>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_DX_DirectWrite_TextRenderer1_DrawUnderline_System_Object_System_Single_System_Single_C1_Util_DX_DirectWrite_GlyphOrientationAngle_C1_Util_DX_DirectWrite_Underline__System_IntPtr__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>A single underline can be broken into multiple calls, depending on how the formatting changes attributes. If font sizes/styles change within an underline, the thickness and offset will be averaged weighted according to characters. To get an appropriate starting pixel position, add underline::offset to the baseline. Otherwise there will be no spacing between the text. The x coordinate will always be passed as the left side, regardless of text directionality. This simplifies drawing and reduces the problem of round-off that could potentially cause gaps or a double stamped alpha blend. To avoid alpha overlap, round the end points to the nearest device pixel.</p>
</div>
</div>
