@@ -77,7 +77,6 @@ <h1>Free Software</h1>
7777
7878< script type ="module ">
7979import * as opentype from "/dist/opentype.mjs" ;
80- globalThis . opentype = opentype ;
8180
8281const form = document . forms . demo ;
8382form . oninput = renderText ;
@@ -204,30 +203,11 @@ <h1>Free Software</h1>
204203 el . innerHTML = message ;
205204}
206205
207- globalThis . downloadFont = async ( font ) => {
208- const fontArrayBuffer = font . toArrayBuffer ( ) ;
209- const blob = new Blob ( [ fontArrayBuffer ] , { type : 'font/otf' } ) ;
210- const link = document . createElement ( 'a' ) ;
211- link . href = URL . createObjectURL ( blob ) ;
212- link . download = 'font.otf' ;
213- document . body . appendChild ( link ) ;
214- link . click ( ) ;
215- document . body . removeChild ( link ) ;
216- } ;
217-
218- globalThis . calcKern = ( font , letter1 , letter2 ) => ( font . getKerningValue ( font . charToGlyph ( letter1 ) , font . charToGlyph ( letter2 ) ) ) ;
219-
220-
221-
222206function onFontLoaded ( font ) {
223207 if ( window . font ) {
224208 window . font . onGlyphUpdated = null
225209 }
226210 window . font = font ;
227-
228- window . fontArrayBuffer = font . toArrayBuffer ( ) ;
229- window . font2 = opentype . parse ( window . fontArrayBuffer ) ;
230-
231211 options = Object . assign ( { } , window . font . defaultRenderOptions ) ;
232212 window . fontOptions = options ;
233213
@@ -299,7 +279,7 @@ <h1>Free Software</h1>
299279 error = err ;
300280 }
301281
302- onFontLoaded ( opentype . parse ( isWoff2 ? Module . decompress ( data ) : data , { lowMemory : false } ) ) ;
282+ onFontLoaded ( opentype . parse ( isWoff2 ? Module . decompress ( data ) : data , { lowMemory : true } ) ) ;
303283 if ( ! error ) showErrorMessage ( '' ) ;
304284 } catch ( err ) {
305285 showErrorMessage ( err . toString ( ) ) ;
@@ -321,4 +301,4 @@ <h1>Free Software</h1>
321301 const fontFileName = 'fonts/FiraSansMedium.woff' ;
322302 display ( await fetch ( fontFileName ) , fontFileName ) ;
323303}
324- </ script >
304+ </ script >
0 commit comments