cursive-text 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +73 -3
- package/bin/cli.js +19 -0
- package/package.json +35 -6
- package/src/index.d.ts +15 -0
- package/src/index.js +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dipak Sah
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,73 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# cursive-text
|
|
2
|
+
|
|
3
|
+
Turn any text into cursive letters that you can paste anywhere: Instagram bios, Discord names, TikTok, captions, game names.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
Hello World -> ℋℯ𝓁𝓁ℴ 𝒲ℴ𝓇𝓁𝒹
|
|
7
|
+
Hello World -> 𝓗𝓮𝓵𝓵𝓸 𝓦𝓸𝓻𝓵𝓭 (bold)
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
No dependencies, about 2 KB, works in Node and the browser. Want to try it without code? Use the free [cursive generator](https://cursive-generator.io) in your browser.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install cursive-text
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Use
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
import { toCursive, styles, allStyles, toPlain } from 'cursive-text';
|
|
22
|
+
|
|
23
|
+
toCursive('Emma Rose'); // 'ℰ𝓂𝓂𝒶 ℛℴ𝓈ℯ'
|
|
24
|
+
toCursive('Emma Rose', { bold: true }); // '𝓔𝓶𝓶𝓪 𝓡𝓸𝓼𝓮'
|
|
25
|
+
|
|
26
|
+
styles.cursiveHearts('Ana'); // '♡ 𝒜𝓃𝒶 ♡'
|
|
27
|
+
allStyles('Ana'); // every style at once
|
|
28
|
+
|
|
29
|
+
toPlain('𝓔𝓶𝓶𝓪 𝓡𝓸𝓼𝓮'); // 'Emma Rose'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Styles
|
|
33
|
+
|
|
34
|
+
| Name | Example |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| `cursive` | ℋℯ𝓁𝓁ℴ |
|
|
37
|
+
| `boldCursive` | 𝓗𝓮𝓵𝓵𝓸 |
|
|
38
|
+
| `cursiveHearts` | ♡ ℋℯ𝓁𝓁ℴ ♡ |
|
|
39
|
+
| `cursiveFlowers` | ❀ ℋℯ𝓁𝓁ℴ ❀ |
|
|
40
|
+
| `boldCursiveSparkles` | ✨ 𝓗𝓮𝓵𝓵𝓸 ✨ |
|
|
41
|
+
| `underlinedCursive` | 𝓗̲𝓮̲𝓵̲𝓵̲𝓸̲ |
|
|
42
|
+
| `strikeCursive` | 𝓗̶𝓮̶𝓵̶𝓵̶𝓸̶ |
|
|
43
|
+
| `spacedCursive` | 𝓗 𝓮 𝓵 𝓵 𝓸 |
|
|
44
|
+
|
|
45
|
+
### Command line
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx cursive-text "Hello World"
|
|
49
|
+
npx cursive-text "Hello World" --bold
|
|
50
|
+
npx cursive-text "Hello World" --all
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## How it works
|
|
54
|
+
|
|
55
|
+
These are not fonts. Unicode has a block called Mathematical Alphanumeric Symbols with a script (cursive) version of every Latin letter, so the text stays cursive wherever you paste it, even where you can't pick a font.
|
|
56
|
+
|
|
57
|
+
One catch: 11 regular script letters (B, E, F, H, I, L, M, R, e, g, o) were in Unicode before that block existed, so their slots in the block are empty. Naive converters show empty boxes for them. This package maps them to the older characters (ℬ ℰ ℱ ℋ ℐ ℒ ℳ ℛ ℯ ℊ ℴ), so every letter shows up. Bold script has no gaps and also covers digits.
|
|
58
|
+
|
|
59
|
+
`toPlain` goes the other way. It uses Unicode NFKC normalization to turn fancy text back into plain letters, which is handy for search, sorting or checking usernames.
|
|
60
|
+
|
|
61
|
+
## Things to know
|
|
62
|
+
|
|
63
|
+
- Screen readers read these characters one by one or as math symbols, so don't use them for important text like headings or buttons.
|
|
64
|
+
- A few old phones and some apps can't show every character.
|
|
65
|
+
- Only the letters A to Z (and digits in bold) change. Accented letters, emoji and punctuation stay as they are.
|
|
66
|
+
|
|
67
|
+
## Learn real cursive handwriting
|
|
68
|
+
|
|
69
|
+
This package makes text look cursive. If you want to learn to write it by hand, there is a free [cursive alphabet chart](https://cursive-generator.io/cursive-alphabet) with every letter, stroke order animations and printable worksheets.
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { toCursive, allStyles } from '../src/index.js';
|
|
3
|
+
|
|
4
|
+
const args = process.argv.slice(2);
|
|
5
|
+
const bold = args.includes('--bold') || args.includes('-b');
|
|
6
|
+
const all = args.includes('--all') || args.includes('-a');
|
|
7
|
+
const text = args.filter((a) => !a.startsWith('-')).join(' ');
|
|
8
|
+
|
|
9
|
+
if (!text) {
|
|
10
|
+
console.log('Usage: cursive-text "your text" [--bold] [--all]');
|
|
11
|
+
console.log('Try it in the browser: https://cursive-generator.io');
|
|
12
|
+
process.exit(text === '' && args.length ? 1 : 0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (all) {
|
|
16
|
+
for (const [name, out] of Object.entries(allStyles(text))) console.log(`${name.padEnd(20)} ${out}`);
|
|
17
|
+
} else {
|
|
18
|
+
console.log(toCursive(text, { bold }));
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cursive-text",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "cursive-text",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Turn any text into cursive Unicode letters you can paste anywhere: Instagram bios, Discord names, TikTok, captions. Zero dependencies.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"types": "./src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./src/index.d.ts",
|
|
11
|
+
"default": "./src/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"cursive-text": "bin/cli.js"
|
|
16
|
+
},
|
|
17
|
+
"files": ["src", "bin"],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "node --test test/index.test.js"
|
|
20
|
+
},
|
|
21
|
+
"keywords": ["cursive", "cursive-text", "cursive-generator", "cursive-font", "unicode", "fancy-text", "script-font", "text-converter", "instagram-fonts", "discord-fonts"],
|
|
22
|
+
"homepage": "https://cursive-generator.io",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/dipak8080/cursive-text.git"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/dipak8080/cursive-text/issues"
|
|
29
|
+
},
|
|
30
|
+
"author": "Dipak Sah",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type StyleName =
|
|
2
|
+
| 'cursive'
|
|
3
|
+
| 'boldCursive'
|
|
4
|
+
| 'cursiveHearts'
|
|
5
|
+
| 'cursiveFlowers'
|
|
6
|
+
| 'boldCursiveSparkles'
|
|
7
|
+
| 'underlinedCursive'
|
|
8
|
+
| 'strikeCursive'
|
|
9
|
+
| 'spacedCursive';
|
|
10
|
+
|
|
11
|
+
export declare const styles: Record<StyleName, (text: string) => string>;
|
|
12
|
+
export declare function toCursive(text: string, options?: { bold?: boolean }): string;
|
|
13
|
+
export declare function toPlain(text: string): string;
|
|
14
|
+
export declare function allStyles(text: string): Record<StyleName, string>;
|
|
15
|
+
export default toCursive;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const cp = (n) => String.fromCodePoint(n);
|
|
2
|
+
|
|
3
|
+
const SCRIPT_EXCEPTIONS = { B: 'ℬ', E: 'ℰ', F: 'ℱ', H: 'ℋ', I: 'ℐ', L: 'ℒ', M: 'ℳ', R: 'ℛ', e: 'ℯ', g: 'ℊ', o: 'ℴ' };
|
|
4
|
+
|
|
5
|
+
function mapper(upper, lower, digits, exceptions = {}) {
|
|
6
|
+
return (text) =>
|
|
7
|
+
Array.from(String(text), (ch) => {
|
|
8
|
+
if (exceptions[ch]) return exceptions[ch];
|
|
9
|
+
const c = ch.codePointAt(0);
|
|
10
|
+
if (c >= 65 && c <= 90) return cp(upper + c - 65);
|
|
11
|
+
if (c >= 97 && c <= 122) return cp(lower + c - 97);
|
|
12
|
+
if (digits && c >= 48 && c <= 57) return cp(digits + c - 48);
|
|
13
|
+
return ch;
|
|
14
|
+
}).join('');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const script = mapper(0x1d49c, 0x1d4b6, 0, SCRIPT_EXCEPTIONS);
|
|
18
|
+
const boldScript = mapper(0x1d4d0, 0x1d4ea, 0x1d7ce);
|
|
19
|
+
const wrap = (fn, left, right) => (text) => (String(text).trim() ? left + fn(text) + right : String(text));
|
|
20
|
+
const mark = (fn, combining) => (text) => Array.from(fn(text), (c) => (c.trim() ? c + combining : c)).join('');
|
|
21
|
+
|
|
22
|
+
export const styles = {
|
|
23
|
+
cursive: script,
|
|
24
|
+
boldCursive: boldScript,
|
|
25
|
+
cursiveHearts: wrap(script, '♡ ', ' ♡'),
|
|
26
|
+
cursiveFlowers: wrap(script, '❀ ', ' ❀'),
|
|
27
|
+
boldCursiveSparkles: wrap(boldScript, '✨ ', ' ✨'),
|
|
28
|
+
underlinedCursive: mark(boldScript, '̲'),
|
|
29
|
+
strikeCursive: mark(boldScript, '̶'),
|
|
30
|
+
spacedCursive: (text) => Array.from(boldScript(text)).join(' '),
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function toCursive(text, { bold = false } = {}) {
|
|
34
|
+
return bold ? boldScript(text) : script(text);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function toPlain(text) {
|
|
38
|
+
return String(text).normalize('NFKC').replace(/[̶̲]/g, '');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function allStyles(text) {
|
|
42
|
+
return Object.fromEntries(Object.entries(styles).map(([name, fn]) => [name, fn(text)]));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default toCursive;
|