@sutton-signwriting/unicode8
Version:
a javascript package for processing SignWriting in Unicode 8 (uni8) characters
60 lines (53 loc) • 2.38 kB
JavaScript
/**
* Sutton SignWriting Unicode 8 Module v1.2.0 (https://github.com/sutton-signwriting/unicode8)
* Author: Steve Slevinski (https://SteveSlevinski.me)
* Sponsor: https://patreon.com/signwriting
* Donate: https://donate.sutton-signwriting.io
*
* font.js is released under the MIT License.
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ssw = global.ssw || {}, global.ssw.unicode8 = global.ssw.unicode8 || {}, global.ssw.unicode8.font = {})));
})(this, (function (exports) { 'use strict';
/**
* Function that appends font-face CSS for the Noto Sans SignWriting font for use with SignWriting in Unicode 8 (uni8) characters.
*
* This font-face declaration will use a locally installed font if available.
* If not found, the font will be loaded from a content delivery network.
*
* The list of local names is currently a work in progress.
* The font-face currently works for Windows and iOS.
* This CSS is duplicated in the src/font/index.css file.
*
* @function font.cssAppend
* @param {string} dir - an optional relative directory for font location
* @example
* font.cssAppend('./font/')
*/
const cssAppend = function (dir = '') {
const id = "SgnwUnicode8FontCss";
if (!document.getElementById(id)) {
const style = document.createElement('style');
style.setAttribute("id", "SgnwUnicode8FontCss");
style.appendChild(document.createTextNode(`
@font-face {
font-family: "NotoSansSignWriting";
src:
local('NotoSansSignWriting'),
local('Noto Sans SignWriting'),
local('Noto_Sans_SignWriting'),
local('Noto Sans SignWriting Regular'),
local('Noto_Sans_SignWriting_Regular'),
${dir ? `url('${dir}NotoSansSignWriting-Regular.ttf') format('truetype'),` : ""}
url('https://notofonts.github.io/sign-writing/fonts/NotoSansSignWriting/full/ttf/NotoSansSignWriting-Regular.ttf') format('opentype');
}
`));
document.head.appendChild(style);
}
};
exports.cssAppend = cssAppend;
Object.defineProperty(exports, '__esModule', { value: true });
}));
/* the end */