All new
alle new
This commit is contained in:
1 parent
da64472251
commit
5b20adee48
1605 files changed
+396517
-1674
No files matched your search
+6
@@ -0,0 +1,6 @@
|
||||
declare const dingbats: {
|
||||
[typefaceName: string]: {
|
||||
[dingbatCodePoint: string]: number;
|
||||
};
|
||||
};
|
||||
export default dingbats;
|
||||
+1076
File diff suppressed because it is too large.
Load diff
+7
@@ -0,0 +1,7 @@
|
||||
export interface UnicodeScalarValue {
|
||||
codePoint: number;
|
||||
string: string;
|
||||
}
|
||||
export declare function codePoint(typeface: string, codePoint: number): UnicodeScalarValue | undefined;
|
||||
export declare function dec(typeface: string, dec: string): UnicodeScalarValue | undefined;
|
||||
export declare function hex(typeface: string, hex: string): UnicodeScalarValue | undefined;
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.hex = exports.dec = exports.codePoint = void 0;
|
||||
var dingbats_1 = __importDefault(require("./dingbats"));
|
||||
var dingbatsByCodePoint = {};
|
||||
var fromCodePoint = String.fromCodePoint ? String.fromCodePoint : fromCodePointPolyfill;
|
||||
function codePoint(typeface, codePoint) {
|
||||
var codePointMap = dingbats_1.default[typeface.toUpperCase()];
|
||||
if (codePointMap === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
var unicodeCodePoint = codePointMap[codePoint];
|
||||
if (unicodeCodePoint === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
codePoint: unicodeCodePoint,
|
||||
string: fromCodePoint(unicodeCodePoint),
|
||||
};
|
||||
}
|
||||
exports.codePoint = codePoint;
|
||||
function dec(typeface, dec) {
|
||||
return codePoint(typeface, parseInt(dec, 10));
|
||||
}
|
||||
exports.dec = dec;
|
||||
function hex(typeface, hex) {
|
||||
return codePoint(typeface, parseInt(hex, 16));
|
||||
}
|
||||
exports.hex = hex;
|
||||
function fromCodePointPolyfill(codePoint) {
|
||||
if (codePoint <= 0xFFFF) {
|
||||
// BMP
|
||||
return String.fromCharCode(codePoint);
|
||||
}
|
||||
else {
|
||||
// Astral
|
||||
// https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
||||
var highSurrogate = Math.floor((codePoint - 0x10000) / 0x400) + 0xD800;
|
||||
var lowSurrogate = (codePoint - 0x10000) % 0x400 + 0xDC00;
|
||||
return String.fromCharCode(highSurrogate, lowSurrogate);
|
||||
}
|
||||
}
|
||||
;
|
||||
Reference in new issue
Block a user