更新模板语法
							parent
							
								
									59608c7409
								
							
						
					
					
						commit
						dc87a4b287
					
				|  | @ -43,30 +43,33 @@ export const FONT_TMPL = ` | ||||||
| <?xml version="1.0" standalone="no"?> | <?xml version="1.0" standalone="no"?> | ||||||
|   <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" > |   <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" > | ||||||
|   <svg> |   <svg> | ||||||
|   <metadata> |   <metadata>Created by @bytedo/font-generator</metadata> | ||||||
|   Created by font-carrier |  | ||||||
|   </metadata> |  | ||||||
|   <defs> |   <defs> | ||||||
|   <font id="<%= font.id %>" horiz-adv-x="<%= font.horizAdvX %>" vert-adv-y="<%= font.horizAdvX %>" > |   <font id="${font.id}" horiz-adv-x="${font.horizAdvX}" vert-adv-y="${ | ||||||
|     <font-face |   font.horizAdvX | ||||||
|       <% for(var v in fontface){ %> | }" > | ||||||
|       <% print(v + '="' + fontface[v] + '"') %> |     <font-face ${Object.keys(fontface) | ||||||
|       <%} %> |       .map(k => `${k}="${fontface[k]}"`) | ||||||
|     /> |       .join(' ')} /> | ||||||
|       <missing-glyph /> |      | ||||||
|  |     <missing-glyph /> | ||||||
| 
 | 
 | ||||||
|       <% if(!hasX){ %> |     ${ | ||||||
|       <glyph glyph-name="x" unicode="x" horiz-adv-x="100" |       hasX | ||||||
|         d="M20 20 L50 20 L50 -20 Z" /> |         ? '' | ||||||
|       <% } %> |         : '<glyph glyph-name="x" unicode="x" horiz-adv-x="100" d="M20 20 L50 20 L50 -20 Z" />' | ||||||
| 
 |     } | ||||||
|       <% for(var i in glyphs){ |  | ||||||
|         var glyph = glyphs[i].options; |  | ||||||
|       %> |  | ||||||
|       <glyph glyph-name="<%= glyph['glyphName'] %>" unicode="<%= glyph['unicode']%>" d="<%= glyph['d']%>"  <% if (glyph['horizAdvX']) print('horiz-adv-x="'+ glyph['horizAdvX']+'"') %> <% if (glyph['vertAdvY']) print('vert-adv-y="'+ glyph['vertAdvY']+'"') %>  /> |  | ||||||
| 
 |  | ||||||
|       <% } %> |  | ||||||
| 
 | 
 | ||||||
|  |     ${glyphs | ||||||
|  |       .map( | ||||||
|  |         glyph => | ||||||
|  |           `<glyph glyph-name="${glyph.glyphName}" unicode="${ | ||||||
|  |             glyph.unicode | ||||||
|  |           }" d="${glyph.d}" ${ | ||||||
|  |             glyph.horizAdvX ? `horiz-adv-x="${glyph.horizAdvX}"` : '' | ||||||
|  |           } ${glyph.vertAdvY ? `vert-adv-y="${glyph.vertAdvY}"` : ''} />` | ||||||
|  |       ) | ||||||
|  |       .join('\n')} | ||||||
|   </font> |   </font> | ||||||
|   </defs> |   </defs> | ||||||
| </svg> | </svg> | ||||||
|  | @ -75,7 +78,11 @@ export const FONT_TMPL = ` | ||||||
| export const SVG_TMPL = ` | export const SVG_TMPL = ` | ||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | ||||||
|   <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" <% if(!options['skipViewport']){ %>  x="0" y="0"   width="<%= options['width'] %>" height="<%= options['height'] %>" <% } %> viewBox="0 0 <%= glyph['horizAdvX'] %> <%= glyph['vertAdvY'] %>"> |   <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ${ | ||||||
|   <path d="<%= glyph['d'] %>"/> |     options.skipViewport | ||||||
|  |       ? '' | ||||||
|  |       : `x="0" y="0" width="${options.width}" height="${options.height}"` | ||||||
|  |   } viewBox="0 0 ${glyph.horizAdvX} ${glyph.vertAdvY}"> | ||||||
|  |   <path d="${glyph.d}"/> | ||||||
| </svg> | </svg> | ||||||
| ` | ` | ||||||
|  |  | ||||||
|  | @ -91,7 +91,6 @@ export function load(str) { | ||||||
|   fontElem = doc.getElementsByTagName('font')[0] |   fontElem = doc.getElementsByTagName('font')[0] | ||||||
| 
 | 
 | ||||||
|   if (!fontElem) { |   if (!fontElem) { | ||||||
|     console.log(doc) |  | ||||||
|     throw new Error( |     throw new Error( | ||||||
|       "Can't find <font> tag. Make sure you SVG file is font, not image." |       "Can't find <font> tag. Make sure you SVG file is font, not image." | ||||||
|     ) |     ) | ||||||
|  |  | ||||||
|  | @ -11,4 +11,4 @@ let svg = fs.cat('test/game.svg').toString() | ||||||
| 
 | 
 | ||||||
| let ttf = svg2ttf(svg) | let ttf = svg2ttf(svg) | ||||||
| 
 | 
 | ||||||
| console.log(ttf) | // console.log(ttf)
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue