koishi-plugin-to-image-service-font-harmonyos-sans-sc 0.0.3 → 0.0.6
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/lib/index.d.ts +1 -3
- package/lib/index.js +7 -32
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -2,9 +2,7 @@ import { Context, Schema, Service } from "koishi";
|
|
|
2
2
|
declare class ToImageServiceFontHarmonyOsSansSc extends Service {
|
|
3
3
|
private _ctx;
|
|
4
4
|
constructor(ctx: Context, config: ToImageServiceFontHarmonyOsSansSc.Config);
|
|
5
|
-
|
|
6
|
-
private initFonts;
|
|
7
|
-
private fontNames;
|
|
5
|
+
start(): Promise<void>;
|
|
8
6
|
}
|
|
9
7
|
declare namespace ToImageServiceFontHarmonyOsSansSc {
|
|
10
8
|
const inject: string[];
|
package/lib/index.js
CHANGED
|
@@ -33,9 +33,8 @@ __export(src_exports, {
|
|
|
33
33
|
default: () => src_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(src_exports);
|
|
36
|
-
var import_koishi = require("koishi");
|
|
37
|
-
var import_promises = __toESM(require("node:fs/promises"));
|
|
38
36
|
var import_node_path = __toESM(require("node:path"));
|
|
37
|
+
var import_koishi = require("koishi");
|
|
39
38
|
var serviceName = "toImageServiceFontHarmonyOsSansSc";
|
|
40
39
|
var ToImageServiceFontHarmonyOsSansSc = class extends import_koishi.Service {
|
|
41
40
|
static {
|
|
@@ -47,37 +46,13 @@ var ToImageServiceFontHarmonyOsSansSc = class extends import_koishi.Service {
|
|
|
47
46
|
this._ctx = ctx;
|
|
48
47
|
}
|
|
49
48
|
async start() {
|
|
50
|
-
await this.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
for (let j = 0; j < 2; j++) {
|
|
57
|
-
fonts.push({
|
|
58
|
-
name: "HarmonyOS Sans",
|
|
59
|
-
weight: (i + 2) * 100,
|
|
60
|
-
style: ["normal", "italic"][j],
|
|
61
|
-
data: await import_promises.default.readFile(
|
|
62
|
-
import_node_path.default.join(
|
|
63
|
-
__dirname,
|
|
64
|
-
`../fonts/HarmonyOS_Sans${["_SC", ""][j]}${"_" + fontName}${["", "_Italic"][j]}.ttf`
|
|
65
|
-
)
|
|
66
|
-
),
|
|
67
|
-
supports: ["satori"]
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
this._ctx.toImageService.addFont(fonts);
|
|
49
|
+
const fonts = await this._ctx.toImageService.fontManagement.loadFontDir([
|
|
50
|
+
import_node_path.default.resolve(__dirname, "../fonts")
|
|
51
|
+
]);
|
|
52
|
+
this._ctx.on("dispose", () => {
|
|
53
|
+
this._ctx.toImageService.fontManagement.removeFont(fonts);
|
|
54
|
+
});
|
|
72
55
|
}
|
|
73
|
-
fontNames = [
|
|
74
|
-
"Thin",
|
|
75
|
-
"Light",
|
|
76
|
-
"Regular",
|
|
77
|
-
"Medium",
|
|
78
|
-
"Bold",
|
|
79
|
-
"Black"
|
|
80
|
-
];
|
|
81
56
|
};
|
|
82
57
|
((ToImageServiceFontHarmonyOsSansSc2) => {
|
|
83
58
|
ToImageServiceFontHarmonyOsSansSc2.inject = ["toImageService"];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-to-image-service-font-harmonyos-sans-sc",
|
|
3
3
|
"description": "Provide HarmonyOS Sans SC fonts for the to-image-service",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"koishi": "^4.18.5"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"koishi-plugin-to-image-service": "^
|
|
42
|
+
"koishi-plugin-to-image-service": "^1.0.1"
|
|
43
43
|
},
|
|
44
44
|
"koishi": {
|
|
45
45
|
"service": {
|