增加复合字形编辑支持
This commit is contained in:
parent
c25d8516d5
commit
9d3760c351
@ -10,7 +10,6 @@ define(
|
||||
var settingSupport = require('../dialog/support');
|
||||
var clipboard = require('editor/widget/clipboard');
|
||||
var actions = require('./actions');
|
||||
var glyfAdjust = require('fonteditor-core/ttf/util/glyfAdjust');
|
||||
var program;
|
||||
|
||||
/**
|
||||
@ -53,14 +52,25 @@ define(
|
||||
// 调整显示级别
|
||||
program.editor.setAxis(getEditingOpt(ttf));
|
||||
|
||||
if (null == glyfIndex) {
|
||||
return;
|
||||
}
|
||||
glyfIndex = +glyfIndex;
|
||||
var font = ttf.glyf[glyfIndex];
|
||||
if (font) {
|
||||
if (font.compond) {
|
||||
alert(i18n.lang.msg_not_support_compound_glyf);
|
||||
}
|
||||
else {
|
||||
program.editor.setFont(lang.clone(font));
|
||||
var clonedFont = lang.clone(font);
|
||||
if (clonedFont.compound) {
|
||||
if (!confirm(i18n.lang.msg_transform_compound_glyf)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 转换复合字形为简单字形,原始字形不变
|
||||
var transformGlyfContours = require('fonteditor-core/ttf/util/transformGlyfContours');
|
||||
var compound2simple = require('fonteditor-core/ttf/util/compound2simple');
|
||||
clonedFont = compound2simple(clonedFont, transformGlyfContours(font, ttf));
|
||||
}
|
||||
|
||||
program.editor.setFont(clonedFont);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -221,7 +231,7 @@ define(
|
||||
})
|
||||
.on('copy', function (e) {
|
||||
|
||||
var list = program.ttfManager.getGlyf(e.list);
|
||||
var list = program.ttfManager.getCopiedGlyf(e.list);
|
||||
var clip = {
|
||||
unitsPerEm: program.ttfManager.get().head.unitsPerEm,
|
||||
glyf: list
|
||||
@ -245,6 +255,7 @@ define(
|
||||
// 根据 unitsPerEm 调整形状
|
||||
if (program.ttfManager.get().head.unitsPerEm !== clip.unitsPerEm) {
|
||||
var scale = program.ttfManager.get().head.unitsPerEm / (clip.unitsPerEm || 1024);
|
||||
var glyfAdjust = require('fonteditor-core/ttf/util/glyfAdjust');
|
||||
clip.glyf.forEach(function (g) {
|
||||
glyfAdjust(g, scale, scale);
|
||||
});
|
||||
|
@ -29,6 +29,7 @@ define(
|
||||
msg_input_proj_name: 'Please input project name:',
|
||||
msg_confirm_gen_names: 'Glyph name will be rewrite by generated name, do you really want to regenerate?',
|
||||
msg_not_support_compound_glyf: 'Not support compound glyph currently!',
|
||||
msg_transform_compound_glyf: 'Do you want to transform compound glyf to simple glyf?',
|
||||
msg_confirm_save_glyph: 'Do you want to cancel save current editing glyph?',
|
||||
msg_no_related_glhph: 'Find no related glyph!',
|
||||
msg_error_open_proj: 'Open project error, do you want to delete this project?',
|
||||
|
@ -29,6 +29,7 @@ define(
|
||||
msg_input_proj_name: '请输入项目名称:',
|
||||
msg_confirm_gen_names: '生成的字形名称会覆盖原来的名称,确定生成?',
|
||||
msg_not_support_compound_glyf: '暂不支持复合字形!',
|
||||
msg_transform_compound_glyf: '是否转换复合字形为简单字形?',
|
||||
msg_confirm_save_glyph: '是否放弃保存当前编辑的字形?',
|
||||
msg_no_related_glhph: '未找到相关字形!',
|
||||
msg_error_open_proj: '打开项目失败,是否删除项目?',
|
||||
|
@ -10,6 +10,8 @@ define(
|
||||
var History = require('editor/widget/History');
|
||||
var TTF = require('fonteditor-core/ttf/ttf');
|
||||
var string = require('fonteditor-core/ttf/util/string');
|
||||
var transformGlyfContours = require('fonteditor-core/ttf/util/transformGlyfContours');
|
||||
var compound2simple = require('fonteditor-core/ttf/util/compound2simple');
|
||||
|
||||
/**
|
||||
* 清除glyf编辑状态
|
||||
@ -548,6 +550,30 @@ define(
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取复制的glyf对象,这里会将复合字形转换成简单字形,以便于粘贴到其他地方
|
||||
*
|
||||
* @param {Array=} indexList 索引列表
|
||||
* @return {Array} glyflist
|
||||
*/
|
||||
Manager.prototype.getCopiedGlyf = function (indexList) {
|
||||
var list = [];
|
||||
var ttf = this.ttf.get();
|
||||
for (var i = 0, l = indexList.length; i < l; ++i) {
|
||||
var index = indexList[i];
|
||||
var cloned = lang.clone(ttf.glyf[index]);
|
||||
if (ttf.glyf[index].compound) {
|
||||
compound2simple(cloned, transformGlyfContours(ttf.glyf[index], ttf));
|
||||
}
|
||||
list.push(cloned);
|
||||
}
|
||||
return list;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Manager.prototype.clearGlyfTag = clearGlyfTag;
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user