diff --git a/README.md b/README.md index 6a47f88..a300b0f 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,12 @@ ui 需要展现一些特定的字体,但直接引入字体包又过大,于 例如 如下图生成的字体包仅包含 「天地无极乾坤借法」  - +```HTML + +``` 其体积自然十分之小 - + 2.另外可以生成 css 直接复制可用,部署在公网便可永久访问 @@ -69,8 +71,6 @@ ui 需要展现一些特定的字体,但直接引入字体包又过大,于 只支持生成 .ttf .eot .woff .svg 这几种格式 -如果 text 参数为空将会返回整个字体包 - ## 写项目时遇到的问题 使用 svelte https://github.com/DeMoorJasper/parcel-plugin-svelte 通过这个插件使用 parcel 然后报 new 的错 需要限制 编译的版本,在package.json browserslist 字段限制一下版本就好 diff --git a/doc_img/功能演示.mkv b/doc_img/功能演示.mkv new file mode 100644 index 0000000..c73e593 Binary files /dev/null and b/doc_img/功能演示.mkv differ diff --git a/doc_img/页面截图.jpg b/doc_img/页面截图.jpg index 99ca91d..766cbb5 100644 Binary files a/doc_img/页面截图.jpg and b/doc_img/页面截图.jpg differ diff --git a/src/app.controller.ts b/src/app.controller.ts index ce7b86e..66fdc6f 100644 --- a/src/app.controller.ts +++ b/src/app.controller.ts @@ -38,21 +38,21 @@ export class AppController { @Query('font') font: string, @Query('temp') temp: string, ) { - console.time() const type = req.url.match(/\.(.*)\?/)[1]; + res.set({ + 'Content-Type': `font/${type}`, + }); + if(!text) + return ' ' const file = await this.appService.generate_fonts_dynamically( text, font, temp, type, ); - res.set({ - 'Content-Type': `font/${type}`, - }); + const bufferStream = new Stream.PassThrough(); bufferStream.end(file); bufferStream.pipe(res); - console.timeEnd() - } } diff --git a/static/App.svelte b/static/App.svelte index bfffa14..22ffb8d 100644 --- a/static/App.svelte +++ b/static/App.svelte @@ -8,6 +8,18 @@ }); /** 选择的文字 */ let text = ''; + /** 用于测试动态生成接口 */ + let generate_fonts_dynamically=`` $: selected_font = font_list.filter(font => font.selected); function generate_font() { selected_font.forEach(font => { @@ -49,7 +61,7 @@ {#each font_list as font, i} {@html ""} {/each} -
使用如下的方式引入,则可以直接使用
+ +{@html generate_fonts_dynamically} + +