# C1.Util.DX.DirectWrite.FontFileStream.ReadFileFragment

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Util_DX_DirectWrite_FontFileStream_ReadFileFragment_" data-uid="C1.Util.DX.DirectWrite.FontFileStream.ReadFileFragment*">ReadFileFragment Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Util_DX_DirectWrite_FontFileStream_ReadFileFragment_" data-uid="C1.Util.DX.DirectWrite.FontFileStream.ReadFileFragment*"></a>
<h4 id="C1_Util_DX_DirectWrite_FontFileStream_ReadFileFragment_System_IntPtr__System_Int64_System_Int64_System_IntPtr__" data-uid="C1.Util.DX.DirectWrite.FontFileStream.ReadFileFragment(System.IntPtr@,System.Int64,System.Int64,System.IntPtr@)">ReadFileFragment(out nint, long, long, out nint)</h4>
<div class="markdown level1 summary"><p>Reads a fragment from a font file.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">void ReadFileFragment(out nint fragmentStart, long fileOffset, long fragmentSize, out nint fragmentContext)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Sub ReadFileFragment(ByRef fragmentStart As IntPtr, fileOffset As Long, fragmentSize As Long, ByRef fragmentContext As IntPtr)</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.intptr">nint</a></td>
      <td><span class="parametername">fragmentStart</span></td>
      <td><p>When this method returns, contains an address of a  reference to the start of the font file fragment.  This parameter is passed uninitialized.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></td>
      <td><span class="parametername">fileOffset</span></td>
      <td><p>The offset of the fragment, in bytes, from the beginning of the font file.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></td>
      <td><span class="parametername">fragmentSize</span></td>
      <td><p>The size of the file fragment, in bytes.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.intptr">nint</a></td>
      <td><span class="parametername">fragmentContext</span></td>
      <td><p>When this method returns, contains the address of</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_DX_DirectWrite_FontFileStream_ReadFileFragment_System_IntPtr__System_Int64_System_Int64_System_IntPtr___remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Note that ReadFileFragment implementations must check whether the requested font file fragment is within the file bounds. Otherwise, an error should be returned from ReadFileFragment.   {{DirectWrite}} may invoke <a class="xref" href="C1.Util.DX.DirectWrite.FontFileStream.html">FontFileStream</a> methods on the same object from multiple threads simultaneously. Therefore, ReadFileFragment implementations that rely on internal mutable state must serialize access to such state across multiple threads. For example, an implementation that uses separate Seek and Read operations to read a file fragment must place the code block containing Seek and Read calls under a lock or a critical section.</p>
</div>
</div>
