TTFLoader.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>TTFLoader - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <p class="inheritance" translate="no"><a href="Loader.html">Loader</a> → </p>
  13. <h1 translate="no">TTFLoader</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A loader for the TTF format.</p>
  17. <p>Loads TTF files and converts them into typeface JSON that can be used directly
  18. to create THREE.Font objects.</p></div>
  19. <h2>Code Example</h2>
  20. <div translate="no"><pre><code class="language-js">const loader = new TTFLoader();
  21. const json = await loader.loadAsync( 'fonts/ttf/kenpixel.ttf' );
  22. const font = new Font( json );
  23. </code></pre></div>
  24. </header>
  25. <article>
  26. <h2 class="subsection-title">Import</h2>
  27. <p><span translate="no">TTFLoader</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank" rel="noopener">Installation#Addons</a>.</p>
  28. <pre><code class="language-js">import { TTFLoader } from 'three/addons/loaders/TTFLoader.js';</code></pre>
  29. <div class="container-overview">
  30. <h2>Constructor</h2>
  31. <h3 class="name name-method" id="TTFLoader" translate="no">new <a href="#TTFLoader">TTFLoader</a><span class="signature">( manager : <span class="param-type"><a href="LoadingManager.html">LoadingManager</a></span> )</span> </h3>
  32. <div class="method">
  33. <div class="description">
  34. <p>Constructs a new TTF loader.</p>
  35. </div>
  36. <table class="params">
  37. <tbody>
  38. <tr>
  39. <td class="name">
  40. <strong>manager</strong>
  41. </td>
  42. <td class="description last">
  43. <p>The loading manager.</p>
  44. </td>
  45. </tr>
  46. </tbody>
  47. </table>
  48. </div>
  49. </div>
  50. <h2 class="subsection-title">Properties</h2>
  51. <div class="member">
  52. <h3 class="name" id="reversed" translate="no">.<a href="#reversed">reversed</a><span class="type-signature"> : boolean</span> </h3>
  53. <div class="description">
  54. <p>Whether the TTF commands should be reversed or not.</p>
  55. <p>Default is <code>false</code>.</p>
  56. </div>
  57. </div>
  58. <h2 class="subsection-title">Methods</h2>
  59. <h3 class="name name-method" id="load" translate="no">.<a href="#load">load</a><span class="signature">( url : <span class="param-type">string</span>, onLoad : <span class="param-type">function</span>, onProgress : <span class="param-type"><a href="global.html#onProgressCallback">onProgressCallback</a></span>, onError : <span class="param-type"><a href="global.html#onErrorCallback">onErrorCallback</a></span> )</span> </h3>
  60. <div class="method">
  61. <div class="description">
  62. <p>Starts loading from the given URL and passes the loaded TTF asset
  63. to the <code>onLoad()</code> callback.</p>
  64. </div>
  65. <table class="params">
  66. <tbody>
  67. <tr>
  68. <td class="name">
  69. <strong>url</strong>
  70. </td>
  71. <td class="description last">
  72. <p>The path/URL of the file to be loaded. This can also be a data URI.</p>
  73. </td>
  74. </tr>
  75. <tr>
  76. <td class="name">
  77. <strong>onLoad</strong>
  78. </td>
  79. <td class="description last">
  80. <p>Executed when the loading process has been finished.</p>
  81. </td>
  82. </tr>
  83. <tr>
  84. <td class="name">
  85. <strong>onProgress</strong>
  86. </td>
  87. <td class="description last">
  88. <p>Executed while the loading is in progress.</p>
  89. </td>
  90. </tr>
  91. <tr>
  92. <td class="name">
  93. <strong>onError</strong>
  94. </td>
  95. <td class="description last">
  96. <p>Executed when errors occur.</p>
  97. </td>
  98. </tr>
  99. </tbody>
  100. </table>
  101. <dl class="details">
  102. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#load">Loader#load</a></dt>
  103. </dl>
  104. </div>
  105. <h3 class="name name-method" id="parse" translate="no">.<a href="#parse">parse</a><span class="signature">( arraybuffer : <span class="param-type">ArrayBuffer</span> )</span><span class="type-signature"> : Object</span> </h3>
  106. <div class="method">
  107. <div class="description">
  108. <p>Parses the given TTF data and returns a JSON for creating a font.</p>
  109. </div>
  110. <table class="params">
  111. <tbody>
  112. <tr>
  113. <td class="name">
  114. <strong>arraybuffer</strong>
  115. </td>
  116. <td class="description last">
  117. <p>The raw TTF data as an array buffer.</p>
  118. </td>
  119. </tr>
  120. </tbody>
  121. </table>
  122. <dl class="details">
  123. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#parse">Loader#parse</a></dt>
  124. </dl>
  125. <dl class="details">
  126. <dt class="tag-returns"><strong>Returns:</strong> The result JSON.</dt>
  127. </dl>
  128. </div>
  129. <h2 class="subsection-title">Source</h2>
  130. <p>
  131. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/TTFLoader.js" translate="no" target="_blank" rel="noopener">examples/jsm/loaders/TTFLoader.js</a>
  132. </p>
  133. </article>
  134. </section>
  135. <script src="../scripts/linenumber.js"></script>
  136. <script src="../scripts/page.js"></script>
  137. </body>
  138. </html>
粤ICP备19079148号