add unicode and name to glyf
This commit is contained in:
parent
6f6ae9dd4b
commit
8fd866f68c
@ -172,13 +172,9 @@ define(
|
||||
return;
|
||||
}
|
||||
|
||||
// 撤销
|
||||
if (e.keyCode == 90 && e.ctrlKey) {
|
||||
me.execCommand('undo');
|
||||
}
|
||||
// 恢复
|
||||
else if (e.keyCode == 89 && e.ctrlKey) {
|
||||
me.execCommand('redo');
|
||||
// esc键,重置model
|
||||
if (e.key == 'esc' && !me.mode.keyup) {
|
||||
me.setMode();
|
||||
}
|
||||
// 粘贴
|
||||
else if (e.keyCode == 86 && e.ctrlKey) {
|
||||
@ -189,15 +185,30 @@ define(
|
||||
me.fire('change');
|
||||
}
|
||||
}
|
||||
// esc键,重置model
|
||||
else if (e.key == 'esc' && !me.mode.keyup) {
|
||||
me.setMode();
|
||||
}
|
||||
else {
|
||||
me.mode.keyup && me.mode.keyup.call(me, e);
|
||||
}
|
||||
});
|
||||
|
||||
render.keyCapture.on('keydown', function(e) {
|
||||
if (me.contextMenu.visible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 撤销
|
||||
if (e.keyCode == 90 && e.ctrlKey) {
|
||||
me.execCommand('undo');
|
||||
}
|
||||
// 恢复
|
||||
else if (e.keyCode == 89 && e.ctrlKey) {
|
||||
me.execCommand('redo');
|
||||
}
|
||||
else {
|
||||
me.mode.keydown && me.mode.keydown.call(me, e);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
render.keyCapture.on('keydown', function(e) {
|
||||
if (me.contextMenu.visible()) {
|
||||
return;
|
||||
|
@ -10,6 +10,7 @@
|
||||
define(
|
||||
function(require) {
|
||||
|
||||
var guid = require('render/util/guid');
|
||||
var ShapesGroup = require('../group/ShapesGroup');
|
||||
var lang = require('common/lang');
|
||||
var selectShape = require('render/util/selectShape');
|
||||
@ -152,8 +153,26 @@ define(
|
||||
* 开始拖动
|
||||
*/
|
||||
dragstart: function(e) {
|
||||
if (this.currentGroup && this.currentPoint) {
|
||||
this.currentGroup.beginTransform(this.currentPoint);
|
||||
|
||||
|
||||
if (this.currentGroup) {
|
||||
|
||||
// 点拖动模式
|
||||
if (this.currentPoint) {
|
||||
this.currentGroup.beginTransform(this.currentPoint);
|
||||
}
|
||||
// 复制模式
|
||||
else if (e.ctrlKey && e.altKey) {
|
||||
var shapes = lang.clone(this.currentGroup.shapes);
|
||||
var fontLayer = this.fontLayer;
|
||||
shapes.forEach(function(shape) {
|
||||
shape.id = guid('shape');
|
||||
fontLayer.addShape(shape);
|
||||
});
|
||||
|
||||
this.currentGroup.setShapes(shapes);
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -70,6 +70,32 @@ define(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联glyf相关的信息
|
||||
*/
|
||||
function resolveGlyf(ttf) {
|
||||
var chars = ttf.chars;
|
||||
var glyf = ttf.glyf;
|
||||
|
||||
Object.keys(chars).forEach(function(c) {
|
||||
var i = chars[c];
|
||||
glyf[i].unicode = +c;
|
||||
});
|
||||
|
||||
if (ttf.post && 2 == ttf.post.format) {
|
||||
var nameIndex = ttf.post.glyphNameIndex;
|
||||
var names = ttf.post.names;
|
||||
nameIndex.forEach(function(name, i) {
|
||||
if (name <= 257) {
|
||||
glyf[i].name = name;
|
||||
}
|
||||
else {
|
||||
glyf[i].name = names[name - 258] || '';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ttf读取函数
|
||||
*
|
||||
@ -79,6 +105,7 @@ define(
|
||||
function TTF(ttf) {
|
||||
this.ttf = ttf;
|
||||
this.ttf.chars = readWindowsAllChars(ttf);
|
||||
resolveGlyf.call(this, this.ttf);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user