Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

font-carrier

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

font-carrier - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

12

lib/helper/engine.js

@@ -222,3 +222,3 @@ var path = require('path')

if (!inputBuffer) {
helper.showError('font convert input error,support path,buffer,string!')
helper.showError('font convert input error,support path,buffer,string!')
return

@@ -229,3 +229,3 @@ }

//不是svg字体就默认是ttf字体,就使用ttf.js进行解析
//不是svg字体就默认是ttf字体,就使用ttf.js进行解析
return _parseTtfFont(inputBuffer)

@@ -243,4 +243,4 @@ }

*
* @param {string|buffer|path} input 字体输入可以是路径,buffer对象,string对象
* @param {string} outputTypes 字体输出的类型,默认是所有四种
* @param {string|buffer|path} input 字体输入可以是路径,buffer对象,string对象
* @param {string} outputTypes 字体输出的类型,默认是所有四种
* @param {string} outputPath 字体的输出路径,不需要带后缀

@@ -294,3 +294,3 @@ * @return {array} outFonts 返回转换后的字体buffer数组

if (!inputBuffer) {
helper.showError('font convert input error,support path,buffer,string!')
helper.showError('font convert input error,support path,buffer,string.please check if the file exist,while the input is a path.')
return

@@ -310,5 +310,5 @@ }

/**
* 字体转换引擎,提供svg 到ttf,ttf到woff,eot,svg的转换
* 字体转换引擎,提供svg 到ttf,ttf到woff,eot,svg的转换
* 提供字体的解析与转换
*/
module.exports = fontEngine
{
"name": "font-carrier",
"version": "0.0.2",
"version": "0.0.3",
"description": "字体搬运工,中文字体解决方案,iconfont",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -104,4 +104,62 @@ # font-carrier

更多实例,请参考[这里](./doc/example.md)
### 案例一
使用svg设置一些icon
```js
//创建空白字体,使用svg生成字体
var font = fontCarrier.create()
var love = fs.readFileSync('./test/svgs/love.svg').toString()
var mail = fs.readFileSync('./test/svgs/mail.svg').toString()
//使用汉字
font.setGlyph('爱',{
svg:love,
glyphName:'爱'
})
//使用unicode
font.setSvg('',mail)
font.convert({
path:'./test'
})
```
### 案例二
从其他字体导出一些图标到自己的库里
``` js
var transFont = fontCarrier.transfer('./test/test.ttf')
var gs = transFont2.getGlyph('我是方正')
//设置到上面案例一里的字体里面
font.setGlyph(gs)
//这样font导出的字体里面就有了'我是方正'对应的svg形状了
font.convert({
path:'./test'
})
```
### 案例三
对中文字体精简
``` js
//使用上面的transFont
//会自动根据当前的输入的文字过滤精简字体
transFont.min('我是精简后的字体,我可以重复')
transFont.output({
path:'./min'
})
```
## api

@@ -108,0 +166,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc