From dc87a4b287c5ab02a7ee79a7fb86e81b90c3691f Mon Sep 17 00:00:00 2001 From: yutent Date: Mon, 5 Feb 2024 18:42:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=A8=A1=E6=9D=BF=E8=AF=AD?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/config.js | 53 +++++++++++++++++++++----------------- src/lib/svg2ttf/lib/svg.js | 1 - test/index.js | 2 +- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/lib/config.js b/src/lib/config.js index f358b15..a1adb25 100644 --- a/src/lib/config.js +++ b/src/lib/config.js @@ -43,30 +43,33 @@ export const FONT_TMPL = ` - - Created by font-carrier - + Created by @bytedo/font-generator - - - <% print(v + '="' + fontface[v] + '"') %> - <%} %> - /> - + + `${k}="${fontface[k]}"`) + .join(' ')} /> + + - <% if(!hasX){ %> - - <% } %> - - <% for(var i in glyphs){ - var glyph = glyphs[i].options; - %> - <% if (glyph['vertAdvY']) print('vert-adv-y="'+ glyph['vertAdvY']+'"') %> /> - - <% } %> + ${ + hasX + ? '' + : '' + } + ${glyphs + .map( + glyph => + `` + ) + .join('\n')} @@ -75,7 +78,11 @@ export const FONT_TMPL = ` export const SVG_TMPL = ` - x="0" y="0" width="<%= options['width'] %>" height="<%= options['height'] %>" <% } %> viewBox="0 0 <%= glyph['horizAdvX'] %> <%= glyph['vertAdvY'] %>"> - + + ` diff --git a/src/lib/svg2ttf/lib/svg.js b/src/lib/svg2ttf/lib/svg.js index fce8862..695d768 100644 --- a/src/lib/svg2ttf/lib/svg.js +++ b/src/lib/svg2ttf/lib/svg.js @@ -91,7 +91,6 @@ export function load(str) { fontElem = doc.getElementsByTagName('font')[0] if (!fontElem) { - console.log(doc) throw new Error( "Can't find tag. Make sure you SVG file is font, not image." ) diff --git a/test/index.js b/test/index.js index a9e51eb..f1dadac 100644 --- a/test/index.js +++ b/test/index.js @@ -11,4 +11,4 @@ let svg = fs.cat('test/game.svg').toString() let ttf = svg2ttf(svg) -console.log(ttf) +// console.log(ttf)