Skip to content

Commit

Permalink
Merge pull request #2 from alienzhou/feat/multi-font
Browse files Browse the repository at this point in the history
feat(font): support more font sets
  • Loading branch information
alienzhou authored Jun 6, 2021
2 parents d86745a + ac05e69 commit 49536b6
Show file tree
Hide file tree
Showing 206 changed files with 1,671 additions and 39 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
"ignoreRestSiblings": true
}
],
"@typescript-eslint/object-curly-spacing": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/prefer-readonly-parameter-types": "off",
"@typescript-eslint/promise-function-async": "off",
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
# v1.2.0

## Feature

Support more font families. Now you can use the `fontFamily` option to specify the type of font as below:

```typescript
import * as fontFamily from 'yoo-hoo/fonts/ansi-shadow';

yo('yoo-hoo', {
fontFamily,
});
```

[See more >>](./README.md#built-in-fonts)

---

# v1.1.0

## Feature

- support print rainbow fonts 🌈
- support padding start

---

# v1.0.1

## Fix
Expand All @@ -13,6 +33,8 @@
- use a string text instead of a variable for the default font set module, so that it can work in webpack
- codes should be numbers in the font set module

---

# v1.0.0

Init release πŸŽ‰
Expand Down
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ It will return the lines for printing. Then you can print it yourself line by li

**Options:**

- fontFamily: `object` Specify the font family. Optional. See more in the [Built-In Fonts Section](#built-in-fonts).
- spacing: `number` The number of spaces between two characters. Default `1`.
- paddingStart: `number` The number of spaces before the text. Default `0`.
- maxLineWidth: `number` The max length of lines. If exceed `maxLineWidth` following characters will get a line feed. Default `Infinity`.
Expand All @@ -53,11 +54,36 @@ It will return the lines for printing. Then you can print it yourself line by li
For example,

```typescript
yo('ho', { color: 'blue', spacing: 2 });
yo('ho', {
color: 'blue',
spacing: 2,
});
```

Then it will print a blue `HO` with two spaces between H and O.

## Built-In Fonts

Below is the fonts supported for the `fontFamily` option:

- default
- anis-shadow
- big
- crazy
- whimsy

You can import font sets from `fonts/xxx.js` and use it. Such as below:

```typescript
import * as fontFamily from 'yoo-hoo/fonts/ansi-shadow';

yo('yoo-hoo', {
fontFamily,
});
```

When not receiving a `fontFamily` object, it will use the default font set.

## Characters Supported

> 🀘 `yoo-hoo` can be used in **both NodeJS and browsers**.
Expand Down
17 changes: 16 additions & 1 deletion example/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
import { yo } from '../lib/index';
import * as fontFamily from '../lib/fonts/big';
import * as fontFamily2 from '../lib/fonts/ansi-shadow';

yo(process.argv[2] || 'yoo-hoo', { spacing: 1, color: 'rainbow', paddingStart: 5 });
yo(process.argv[2] || 'yoo-hoo', {
color: 'green',
spacing: 1,
paddingStart: 5,
});

yo(process.argv[2] || 'ascii * art', {
fontFamily,
color: 'rainbow',
});

yo(process.argv[2] || 'alienzhou', {
fontFamily: fontFamily2,
});
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "lib/index.js",
"scripts": {
"dev": "tsc --build -w tsconfig.json",
"example": "ts-node example/index.ts",
"example": "npm run build && DEBUG=yoo-hoo ts-node example/index.ts",
"lint": "eslint \"src/**/*.ts\" --fix",
"build": "rm -rf lib && tsc --build tsconfig.json && ts-node script/build.ts",
"prepublishOnly": "npm run lint && npm run build"
Expand All @@ -25,6 +25,7 @@
"author": "alienzhou <[email protected]>",
"license": "MIT",
"devDependencies": {
"@types/debug": "^4.1.5",
"@types/node": "^14.14.9",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
Expand All @@ -40,6 +41,7 @@
},
"dependencies": {
"chalk": "^4.1.0",
"debug": "^4.3.1",
"lolcatjs": "^2.4.0"
},
"husky": {
Expand Down
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
a
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β•šβ•β• β•šβ•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/b.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
b
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β•šβ•β•β•β•β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/c.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
c
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•β•β•
β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘
β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β•šβ•β•β•β•β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/d.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
d
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β•šβ•β•β•β•β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/e.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
e
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•β•β•
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β•šβ•β•β•β•β•β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/f.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
f
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•β•β•
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•
β–ˆβ–ˆβ•‘
β•šβ•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/g.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
g
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•β•β•
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β•šβ•β•β•β•β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/h.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
h
β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β•šβ•β• β•šβ•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/i.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
i
β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘
β•šβ•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/j.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
j
β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘
β–ˆβ–ˆ β–ˆβ–ˆβ•‘
β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β•šβ•β•β•β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/k.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
k
β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•—
β•šβ•β• β•šβ•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/l.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
l
β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β•šβ•β•β•β•β•β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/m.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
m
β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘
β•šβ•β• β•šβ•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/n.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
n
β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—
β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘
β•šβ•β• β•šβ•β•β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/o.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
o
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β•šβ•β•β•β•β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/p.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
p
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β–ˆβ–ˆβ•”β•β•β•β•
β–ˆβ–ˆβ•‘
β•šβ•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/q.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
q
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘β–„β–„ β–ˆβ–ˆβ•‘
β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β•šβ•β•β–€β–€β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/r.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
r
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β•šβ•β• β•šβ•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/s.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
s
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•β•β•
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β•šβ•β•β•β•β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘
β•šβ•β•β•β•β•β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/t.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
t
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β•šβ•β•β–ˆβ–ˆβ•”β•β•β•
β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘
β•šβ•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/u.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
u
β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β•šβ•β•β•β•β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/v.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
v
β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β•šβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•
β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β•šβ•β•β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/w.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
w
β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘ β–ˆβ•— β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘
β•šβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ•”β•
β•šβ•β•β•β•šβ•β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/x.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
x
β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—
β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•
β•šβ–ˆβ–ˆβ–ˆβ•”β•
β–ˆβ–ˆβ•”β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•—
β•šβ•β• β•šβ•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/y.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
y
β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—
β•šβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•
β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β•šβ–ˆβ–ˆβ•”β•
β–ˆβ–ˆβ•‘
β•šβ•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/letter/z.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
z
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β•šβ•β•β–ˆβ–ˆβ–ˆβ•”β•
β–ˆβ–ˆβ–ˆβ•”β•
β–ˆβ–ˆβ–ˆβ•”β•
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β•šβ•β•β•β•β•β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/number/0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
0
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘
β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β•šβ•β•β•β•β•β•
7 changes: 7 additions & 0 deletions raw/ansi-shadow/number/1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1
β–ˆβ–ˆβ•—
β–ˆβ–ˆβ–ˆβ•‘
β•šβ–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘
β•šβ•β•
Loading

0 comments on commit 49536b6

Please sign in to comment.