font-carrier
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -59,4 +59,4 @@ var Base = require('./base.js') | ||
var scale, ascent | ||
//当前有字体就需要做出转换 | ||
if (this.__font) { | ||
//当前有新的字体就需要做出转换 | ||
if (this.__font && this.__font != dstFont) { | ||
//算出字体的比例,进行缩放还有参数变化 | ||
@@ -71,4 +71,2 @@ scale = this.__font.get('vertAdvY') / dstFont.get('vertAdvY') | ||
} | ||
@@ -75,0 +73,0 @@ |
@@ -129,11 +129,14 @@ var path = require('path') | ||
path = g.path.toPathData() | ||
if (path) { | ||
unicode = '&#x' + (g.unicode).toString(16) + ';' | ||
fontObjs.glyphs[unicode] = { | ||
d: path, | ||
unicode: unicode, | ||
name: g.name, | ||
horizAdvX: g.advanceWidth, | ||
vertAdvY: fontObjs.options.vertAdvY | ||
} | ||
if (path && _.isArray(g.unicodes)) { | ||
_.each(g.unicodes,function(_unicode){ | ||
unicode = '&#x' + (_unicode).toString(16) + ';' | ||
fontObjs.glyphs[unicode] = { | ||
d: path, | ||
unicode: unicode, | ||
name: g.name || 'uni' + _unicode, | ||
horizAdvX: g.advanceWidth, | ||
vertAdvY: fontObjs.options.vertAdvY | ||
} | ||
}) | ||
} | ||
@@ -140,0 +143,0 @@ } catch (e) { |
@@ -34,2 +34,3 @@ var Font = require('./class/font') | ||
FontCarrier.transfer = function(input, options) { | ||
var parsedFontObject = engine.parse(input) | ||
@@ -48,4 +49,4 @@ | ||
font.setGlyph(k, tmplGlyph) | ||
}) | ||
}) | ||
return font | ||
@@ -52,0 +53,0 @@ } |
{ | ||
"name": "font-carrier", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "字体搬运工,中文字体解决方案,iconfont", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -13,3 +13,5 @@ # font-carrier | ||
>基于font-carrier的图形客户端版本已经上线,懒人可以直接移步[panda](https://github.com/stormtea123/panda) | ||
# features | ||
@@ -112,2 +114,4 @@ | ||
```js | ||
var fontCarrier = require('font-carrier') | ||
//创建空白字体,使用svg生成字体 | ||
@@ -139,6 +143,10 @@ var font = fontCarrier.create() | ||
``` js | ||
var transFont = fontCarrier.transfer('./test/test.ttf') | ||
var fontCarrier = require('font-carrier') | ||
var transFont = fontCarrier.transfer('./test/test.ttf')//改成存在的字体文件地址 | ||
//生成空白字体 | ||
var font = fontCarrier.create() | ||
var gs = transFont.getGlyph('我是方正') | ||
//设置到上面案例一里的字体里面 | ||
//设置到空白字体里面 | ||
font.setGlyph(gs) | ||
@@ -159,2 +167,4 @@ | ||
``` js | ||
var fontCarrier = require('font-carrier') | ||
var transFont = fontCarrier.transfer('./test/test.ttf') | ||
@@ -161,0 +171,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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8252978
1122
190