TTFLoader.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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">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">LoadingManager</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"><code>manager</code></td>
  40. <td class="description last"><p>The loading manager.</p></td>
  41. </tr>
  42. </tbody>
  43. </table>
  44. </div>
  45. </div>
  46. <h2 class="subsection-title">Properties</h2>
  47. <div class="member">
  48. <h3 class="name" id="reversed" translate="no">.<a href="#reversed">reversed</a><span class="type-signature"> : boolean</span> </h3>
  49. <div class="description">
  50. <p>Whether the TTF commands should be reversed or not.<br/>Default is <code>false</code>.</p>
  51. </div>
  52. </div>
  53. <h2 class="subsection-title">Methods</h2>
  54. <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">onProgressCallback</span>, onError : <span class="param-type">onErrorCallback</span> )</span> </h3>
  55. <div class="method">
  56. <div class="description">
  57. <p>Starts loading from the given URL and passes the loaded TTF asset
  58. to the <code>onLoad()</code> callback.</p>
  59. </div>
  60. <table class="params">
  61. <tbody>
  62. <tr>
  63. <td class="name"><code>url</code></td>
  64. <td class="description last"><p>The path/URL of the file to be loaded. This can also be a data URI.</p></td>
  65. </tr>
  66. <tr>
  67. <td class="name"><code>onLoad</code></td>
  68. <td class="description last"><p>Executed when the loading process has been finished.</p></td>
  69. </tr>
  70. <tr>
  71. <td class="name"><code>onProgress</code></td>
  72. <td class="description last"><p>Executed while the loading is in progress.</p></td>
  73. </tr>
  74. <tr>
  75. <td class="name"><code>onError</code></td>
  76. <td class="description last"><p>Executed when errors occur.</p></td>
  77. </tr>
  78. </tbody>
  79. </table>
  80. <dl class="details">
  81. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#load">Loader#load</a></dt>
  82. </dl>
  83. </div>
  84. <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>
  85. <div class="method">
  86. <div class="description">
  87. <p>Parses the given TTF data and returns a JSON for creating a font.</p>
  88. </div>
  89. <table class="params">
  90. <tbody>
  91. <tr>
  92. <td class="name"><code>arraybuffer</code></td>
  93. <td class="description last"><p>The raw TTF data as an array buffer.</p></td>
  94. </tr>
  95. </tbody>
  96. </table>
  97. <dl class="details">
  98. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#parse">Loader#parse</a></dt>
  99. </dl>
  100. <dl class="details">
  101. <dt class="tag-returns"><strong>Returns:</strong> The result JSON.</dt>
  102. </dl>
  103. </div>
  104. <h2 class="subsection-title">Source</h2>
  105. <p>
  106. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/TTFLoader.js" target="_blank" rel="noopener" translate="no">examples/jsm/loaders/TTFLoader.js</a>
  107. </p>
  108. </article>
  109. </section>
  110. <script src="../scripts/linenumber.js"></script>
  111. <script src="../scripts/page.js"></script>
  112. </body>
  113. </html>
粤ICP备19079148号