-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from nyarla/add-rounded-mplus-font
feat(fonts): add Rounded M+ Fonts
- Loading branch information
Showing
2 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
all: unpack | ||
|
||
rounded-mplus.7z: | ||
curl -L -o rounded-mplus.7z https://ftp.iij.ad.jp/pub/osdn.jp/users/8/8569/rounded-mplus-20150529.7z | ||
|
||
rounded-x-mplus.7z: | ||
curl -L -o rounded-x-mplus.7z https://ftp.iij.ad.jp/pub/osdn.jp/users/8/8570/rounded-x-mplus-20150529.7z | ||
|
||
rounded-l-mplus.7z: | ||
curl -L -o rounded-l-mplus.7z https://ftp.iij.ad.jp/pub/osdn.jp/users/8/8568/rounded-l-mplus-20150529.7z | ||
|
||
unpack: rounded-mplus.7z rounded-x-mplus.7z rounded-l-mplus.7z | ||
echo A | 7z x rounded-mplus.7z | ||
echo A | 7z x rounded-x-mplus.7z | ||
echo A | 7z x rounded-l-mplus.7z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { readFile } from "node:fs/promises"; | ||
|
||
import { FontOptions } from "satori"; | ||
import type { FontStyle } from "satori"; | ||
|
||
type MPlusVariants = 1 | 2; | ||
type MPlusFontFaces = "c" | "p" | "m" | "mn"; | ||
|
||
type XMPlusWeights = "light" | "regular" | "medium" | "bold" | "heavy" | "bold"; | ||
type MPlusWeights = "thin" | XMPlusWeights; | ||
|
||
const MPlusWeights = { | ||
thin: 100, | ||
light: 200, | ||
regular: 400, | ||
medium: 500, | ||
bold: 600, | ||
heavy: 700, | ||
bold: 900, | ||
}; | ||
|
||
export async function RoundedXMPlus( | ||
fontVariant: MPlusVariants = 1, | ||
fontFace: MPlusFontFaces = "c", | ||
fontWeight: XMPlusWeights = "regular", | ||
fontStyle: FontStyle = "normal", | ||
) { | ||
const fn = new URL( | ||
`./rounded-x-mplus-${fontVariant}${fontFace}-${fontWeight}.ttf`, | ||
import.meta.url, | ||
); | ||
|
||
const name = `Rounded-X M+ ${fontVariant}${fontFace}`; | ||
const lang = "ja-JP"; | ||
const data = await readFile(fn); | ||
const weight = MPlusWeights[fontWeight]; | ||
const style = fontStyle; | ||
|
||
return { name, lang, data, weight, style }; | ||
} | ||
|
||
export async function RoundedLMPlus( | ||
fontVariant: MPlusVariants = 1, | ||
fontFace: MPlusFontFaces = "c", | ||
fontWeight: MPlusWeights = "regular", | ||
fontStyle: FontStyle = "normal", | ||
) { | ||
const fn = new URL( | ||
`./rounded-l-mplus-${fontVariant}${fontFace}-${fontWeight}.ttf`, | ||
import.meta.url, | ||
); | ||
|
||
const name = `Rounded-L M+ ${fontVariant}${fontFace}`; | ||
const lang = "ja-JP"; | ||
const data = await readFile(fn); | ||
const weight = MPlusWeights[fontWeight]; | ||
const style = fontStyle; | ||
|
||
return { name, lang, data, weight, style }; | ||
} | ||
|
||
export async function RoundedMPlus( | ||
fontVariant: MPlusVariants = 1, | ||
fontFace: MPlusFontFaces = "c", | ||
fontWeight: MPlusWeights = "regular", | ||
fontStyle: FontStyle = "normal", | ||
) { | ||
const fn = new URL( | ||
`./rounded-mplus-${fontVariant}${fontFace}-${fontWeight}.ttf`, | ||
import.meta.url, | ||
); | ||
|
||
const name = `Rounded M+ ${fontVariant}${fontFace}`; | ||
const lang = "ja-JP"; | ||
const data = await readFile(fn); | ||
const weight = MPlusWeights[fontWeight]; | ||
const style = fontStyle; | ||
|
||
return { name, lang, data, weight, style }; | ||
} |