Skip to content

Commit

Permalink
Restored docs site
Browse files Browse the repository at this point in the history
  • Loading branch information
Balearica committed Jul 12, 2024
1 parent c91903e commit d3ca38a
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ <h1>Free Software</h1>

<script type="module">
import * as opentype from "/dist/opentype.mjs";
globalThis.opentype = opentype;

const form = document.forms.demo;
form.oninput = renderText;
Expand Down Expand Up @@ -204,30 +203,11 @@ <h1>Free Software</h1>
el.innerHTML = message;
}

globalThis.downloadFont = async (font) => {
const fontArrayBuffer = font.toArrayBuffer();
const blob = new Blob([fontArrayBuffer], { type: 'font/otf' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'font.otf';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};

globalThis.calcKern = (font, letter1, letter2) => (font.getKerningValue(font.charToGlyph(letter1), font.charToGlyph(letter2)));



function onFontLoaded(font) {
if (window.font) {
window.font.onGlyphUpdated = null
}
window.font = font;

window.fontArrayBuffer = font.toArrayBuffer();
window.font2 = opentype.parse(window.fontArrayBuffer);

options = Object.assign({}, window.font.defaultRenderOptions);
window.fontOptions = options;

Expand Down Expand Up @@ -299,7 +279,7 @@ <h1>Free Software</h1>
error = err;
}

onFontLoaded(opentype.parse(isWoff2 ? Module.decompress(data) : data, { lowMemory: false }));
onFontLoaded(opentype.parse(isWoff2 ? Module.decompress(data) : data, { lowMemory: true }));
if ( !error ) showErrorMessage('');
} catch (err) {
showErrorMessage(err.toString());
Expand All @@ -321,4 +301,4 @@ <h1>Free Software</h1>
const fontFileName = 'fonts/FiraSansMedium.woff';
display(await fetch(fontFileName), fontFileName);
}
</script>
</script>

0 comments on commit d3ca38a

Please # to comment.