mirror of
				https://gitee.com/vant-contrib/vant.git
				synced 2025-11-01 03:42:08 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			22 lines
		
	
	
		
			541 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			541 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const fs = require('fs-extra');
 | |
| const path = require('path');
 | |
| const config = require('../src/config');
 | |
| 
 | |
| function template(fontName, ttf) {
 | |
|   return `@font-face {
 | |
|   font-weight: normal;
 | |
|   font-family: '${fontName}';
 | |
|   font-style: normal;
 | |
|   src: url('${ttf}') format('truetype');
 | |
| }
 | |
| `;
 | |
| }
 | |
| 
 | |
| module.exports = function encode(fontName, srcDir) {
 | |
|   const ttfBase64 = fs.readFileSync(`../src/${fontName}.ttf`, 'base64');
 | |
|   fs.writeFileSync(
 | |
|     path.join(srcDir, 'encode.less'),
 | |
|     template(config.name, `data:font/ttf;base64,${ttfBase64}`)
 | |
|   );
 | |
| };
 |