alle new
This commit is contained in:
erik committed 2026-10-01 06:46:51 +02:00
1 parent da64472251
commit 5b20adee48
1605 files changed
+396517 -1674

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
Copyright (c) 2021, Michael Williamson
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+79
View File
@@ -0,0 +1,79 @@
# dingbat-to-unicode
Mapping from Dingbat fonts, such as Symbol, Webdings and Wingdings, to Unicode code points.
The following fonts are supported:
* Symbol
* Webdings
* Wingdings
* Wingdings 2
* Wingdings 3
Note that in some cases, such as docx files,
the dingbat code point may have 0xF000 added to it to shift the code point into the Unicode private use area.
You should subtract 0xF000 from the code point before passing it into this library.
## Installation
npm install dingbat-to-unicode
## Usage
Import using `require` or `import`:
```javascript
const dingbatToUnicode = require("dingbat-to-unicode");
// or
import * as dingbatToUnicode from "dingbat-to-unicode";
```
You can then call one of the following functions, depending on the representation you have the dingbat code point in:
* `dingbatToUnicode.codePoint(typeface: string, codePoint: number): UnicodeScalarValue | undefined`
* `dingbatToUnicode.dec(typeface: string, dec: string): UnicodeScalarValue | undefined`
* `dingbatToUnicode.hex(typeface: string, hex: string): UnicodeScalarValue | undefined`
`UnicodeScalarValue` is an object with two properties:
* `codePoint`: a `number` representing the Unicode code point
* `string`: a `string` representing the code point as a string
## Examples
```javascript
const result = dingbatToUnicode.codePoint("Wingdings", 41)!!;
assert.strictEqual(result.codePoint, 0x2706);
```
```javascript
const result = dingbatToUnicode.dec("Wingdings", "41")!!;
assert.strictEqual(result.codePoint, 0x2706);
```
```javascript
const result = dingbatToUnicode.hex("Wingdings", "29")!!;
assert.strictEqual(result.codePoint, 0x2706);
```
```javascript
const result = dingbatToUnicode.hex("Wingdings", "3E")!!;
assert.strictEqual(result.codePoint, 0x2707);
```
```javascript
const result = dingbatToUnicode.hex("Wingdings", "3e")!!;
assert.strictEqual(result.codePoint, 0x2707);
```
```javascript
const result = dingbatToUnicode.hex("Wingdings", "29")!!;
assert.strictEqual(result.string, "\u2706");
```
```javascript
const result = dingbatToUnicode.hex("Wingdings", "28")!!;
assert.strictEqual(result.string, "🕿");
```
+6
View File
@@ -0,0 +1,6 @@
declare const dingbats: {
[typefaceName: string]: {
[dingbatCodePoint: string]: number;
};
};
export default dingbats;
+1076
View File
File diff suppressed because it is too large. Load diff
+7
View File
@@ -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
View File
@@ -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);
}
}
;
+39
View File
@@ -0,0 +1,39 @@
{
"name": "dingbat-to-unicode",
"version": "1.0.2",
"description": "Mapping from Dingbat fonts, such as Symbol, Webdings and Wingdings, to Unicode code points",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"prepare": "tsc",
"test": "mocha --ui exports --require ts-node/register 'test/**/*.ts'"
},
"repository": {
"type": "git",
"url": "git+https://github.com/mwilliamson/dingbat-to-unicode.git"
},
"keywords": [
"dingbat",
"dingbats",
"symbol",
"webdings",
"wingdings",
"unicode"
],
"author": "Michael Williamson <mike@zwobble.org>",
"license": "BSD-2-Clause",
"bugs": {
"url": "https://github.com/mwilliamson/dingbat-to-unicode/issues"
},
"homepage": "https://github.com/mwilliamson/dingbat-to-unicode#readme",
"devDependencies": {
"@types/mocha": "^8.2.0",
"@types/node": "^14.14.21",
"mocha": "^6.2.3",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
}
}