add adjust
This commit is contained in:
parent
df723949c5
commit
8bb056c88c
64
src/fonteditor/dialog/setting-adjust.js
Normal file
64
src/fonteditor/dialog/setting-adjust.js
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @file setting-adjust.js
|
||||
* @author mengke01
|
||||
* @date
|
||||
* @description
|
||||
* 设置自动调整字形
|
||||
*/
|
||||
|
||||
define(
|
||||
function(require) {
|
||||
|
||||
var tpl = ''
|
||||
+ '<div class="input-group input-group-sm">'
|
||||
+ '<span class="input-group-addon">左边轴</span>'
|
||||
+ '<input data-field="leftSideBearing" type="number" min="-16384" max="16384" step="1" class="form-control">'
|
||||
+ '</div>'
|
||||
+ '<div class="input-group input-group-sm">'
|
||||
+ '<span class="input-group-addon">右边轴</span>'
|
||||
+ '<input data-field="rightSideBearing" type="number" min="-16384" max="16384" step="1" class="form-control">'
|
||||
+ '</div>'
|
||||
+
|
||||
+ '<div class="input-group input-group-sm">'
|
||||
+ '<span class="input-group-addon">缩放字形到em框</span>'
|
||||
+ '<span class="form-control">'
|
||||
+ '<input data-field="ajdustToEmBox" type="checkbox">'
|
||||
+ '</span>'
|
||||
+ '</div>'
|
||||
+ '<div class="input-group input-group-sm">'
|
||||
+ '<span class="input-group-addon">缩放留白</span>'
|
||||
+ '<input data-field="ajdustToEmPadding" type="number" min="-16384" max="16384" step="1" class="form-control">'
|
||||
+ '</div>';
|
||||
|
||||
|
||||
return require('./setting').derive({
|
||||
|
||||
title: '调整字形',
|
||||
|
||||
getTpl: function() {
|
||||
return tpl;
|
||||
},
|
||||
|
||||
set: function(setting) {
|
||||
setting = setting || {};
|
||||
this.getDialog().find('[data-field]').each(function(i, item) {
|
||||
item = $(item);
|
||||
item.val(setting[item.attr('data-field')] || '');
|
||||
});
|
||||
},
|
||||
|
||||
validate: function() {
|
||||
var name = {};
|
||||
this.getDialog().find('[data-field]').each(function(i, item) {
|
||||
item = $(item);
|
||||
var val = item.val().trim();
|
||||
if (val) {
|
||||
name[item.attr('data-field')] = val;
|
||||
}
|
||||
});
|
||||
return name;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
);
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file setting-unicode.js
|
||||
* @file setting-name.js
|
||||
* @author mengke01
|
||||
* @date
|
||||
* @description
|
||||
|
@ -25,6 +25,7 @@ define(
|
||||
var setting = {
|
||||
'unicode': require('../dialog/setting-unicode'),
|
||||
'name': require('../dialog/setting-name'),
|
||||
'adjust': require('../dialog/setting-adjust'),
|
||||
'online': require('../dialog/font-online')
|
||||
}
|
||||
|
||||
@ -93,6 +94,28 @@ define(
|
||||
});
|
||||
dlg.show(ttf.name);
|
||||
}
|
||||
},
|
||||
'setting-adjust': function() {
|
||||
var ttf = program.ttfmanager.get();
|
||||
if (ttf) {
|
||||
var dlg = new setting.adjust({
|
||||
onChange: function(setting) {
|
||||
program.ttfmanager.adjustGlyf(setting);
|
||||
}
|
||||
});
|
||||
// 如果仅选择一个字形,则填充现有值
|
||||
var selected = program.viewer.getSelected();
|
||||
if (selected.length === 1) {
|
||||
var glyf = program.ttfmanager.getGlyf(selected)[0];
|
||||
dlg.show({
|
||||
leftSideBearing: glyf.leftSideBearing || '',
|
||||
rightSideBearing: glyf.advanceWidth - glyf.xMax || ''
|
||||
});
|
||||
}
|
||||
else {
|
||||
dlg.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -158,18 +181,18 @@ define(
|
||||
function onUpFile(e) {
|
||||
var file = e.target.files[0];
|
||||
|
||||
if (program.action == 'open' && file.name.match(/(\.ttf|\.woff)$/)) {
|
||||
if (program.action == 'open' && file.name.match(/(\.ttf|\.woff)$/i)) {
|
||||
loader.load(file, {
|
||||
type: file.name.slice(file.name.lastIndexOf('.') + 1),
|
||||
type: file.name.slice(file.name.lastIndexOf('.') + 1).toLowerCase(),
|
||||
success: function(imported) {
|
||||
program.ttfmanager.set(imported);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (program.action == 'import' && file.name.match(/(\.ttf|\.woff|\.svg)$/)) {
|
||||
else if (program.action == 'import' && file.name.match(/(\.ttf|\.woff|\.svg)$/i)) {
|
||||
if (program.ttfmanager.get()) {
|
||||
loader.load(file, {
|
||||
type: file.name.slice(file.name.lastIndexOf('.') + 1),
|
||||
type: file.name.slice(file.name.lastIndexOf('.') + 1).toLowerCase(),
|
||||
success: function(imported) {
|
||||
if (imported.glyf.length) {
|
||||
program.ttfmanager.merge(imported, {scale: true});
|
||||
|
@ -163,8 +163,8 @@ define(
|
||||
*/
|
||||
Manager.prototype.removeGlyf = function(indexList) {
|
||||
var glyf = this.ttf.glyf, count = 0;
|
||||
for(var i = glyf.length - 1; i >= 0; i--) {
|
||||
if (indexList.indexOf(i) >= 0 && glyf[i].name != '.notdef') {
|
||||
for(var i = glyf.length - 1; i > 0; i--) {
|
||||
if (indexList.indexOf(i) >= 0) {
|
||||
glyf.splice(i, 1);
|
||||
count++;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user