UNPKG

1.78 kBJavaScriptView Raw
1/**
2* Sutton SignWriting Unicode 8 Module v1.1.2 (https://github.com/sutton-signwriting/unicode8)
3* Author: Steve Slevinski (https://SteveSlevinski.me)
4* font.mjs is released under the MIT License.
5*/
6
7/**
8 * Function that appends font-face CSS for the Noto Sans SignWriting font for use with SignWriting in Unicode 8 (uni8) characters.
9 *
10 * This font-face declaration will use a locally installed font if available.
11 * If not found, the font will be loaded from a content delivery network.
12 *
13 * The list of local names is currently a work in progress.
14 * The font-face currently works for Windows and iOS.
15 * This CSS is duplicated in the src/font/index.css file.
16 *
17 * @function font.cssAppend
18 * @param {string} dir - an optional relative directory for font location
19 * @example
20 * font.cssAppend('./font/')
21 */
22const cssAppend = function (dir = '') {
23 const id = "SgnwUnicode8FontCss";
24
25 if (!document.getElementById(id)) {
26 const style = document.createElement('style');
27 style.setAttribute("id", "SgnwUnicode8FontCss");
28 style.appendChild(document.createTextNode(`
29 @font-face {
30 font-family: "NotoSansSignWriting";
31 src:
32 local('NotoSansSignWriting'),
33 local('Noto Sans SignWriting'),
34 local('Noto_Sans_SignWriting'),
35 local('Noto Sans SignWriting Regular'),
36 local('Noto_Sans_SignWriting_Regular'),
37 ${dir ? `url('${dir}NotoSansSignWriting-Regular.otf') format('truetype'),` : ""}
38 url('https://cdn.jsdelivr.net/gh/googlefonts/noto-fonts/unhinted/otf/NotoSansSignWriting/NotoSansSignWriting-Regular.otf') format('opentype');
39 }
40 `));
41 document.head.appendChild(style);
42 }
43};
44
45export { cssAppend };
46
47/* support ongoing development on https://patreon.com/signwriting */