diff --git a/.gitignore b/.gitignore
index 0fee068..6d5dccf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,4 +14,8 @@ release
npm-debug.log
node_modules
css/common/*.css
+demo/sync/*.ttf
+demo/sync/*.woff
+demo/sync/*.eot
+demo/sync/*.svg
diff --git a/README.md b/README.md
index f4d51c6..c9f6fc1 100644
--- a/README.md
+++ b/README.md
@@ -38,3 +38,5 @@ fonteditor 在线ttf字体编辑器
15. 2015-3-12 增加字形图像导入功能.
16. 2015-4-9 增加图像导入参数设置,优化导入图形.
+
+16. 2015-4-12 增加同步字体功能.
diff --git a/css/common/bootstrap.less b/css/common/bootstrap.less
index f413af8..7e897dd 100644
--- a/css/common/bootstrap.less
+++ b/css/common/bootstrap.less
@@ -32,6 +32,7 @@
.modal-body {
min-height: 100px;
+ padding-bottom: 5px;
}
.modal-content {
@@ -60,6 +61,9 @@
.input-group {
margin-bottom: 10px;
+ .input-group-addon {
+ text-align: left;
+ }
}
.list-group-item {
@@ -74,14 +78,33 @@ hr {
}
// 自定义宽度
-.form-inline {
-
+.column-2,
+.column-3,
+.column-4 {
.form-group {
margin-right: 10px;
+ }
+}
+
+
+.column-2 {
+ .form-group {
+ width: 45%;
+ }
+}
+
+.column-3 {
+ .form-group {
width: 30%;
}
}
+.column-4 {
+ .form-group {
+ width: 22%;
+ }
+}
+
.navbar {
height: 50px;
@@ -263,4 +286,5 @@ hr {
.btn-right {
float: right;
+ margin-left: 10px;
}
diff --git a/css/common/dialog.less b/css/common/dialog.less
index 7ac7f81..661bd1f 100644
--- a/css/common/dialog.less
+++ b/css/common/dialog.less
@@ -6,21 +6,11 @@
width: 800px;
}
- .form-inline .form-group {
- width: 22%;
- }
-
.panose-inline {
- margin-bottom: -24px;
+ margin-bottom: -15px;
.input-group {
width: 100%;
}
- .input-group-addon {
- text-align: left;
- }
- .form-group {
- width: 29%;
- }
}
}
diff --git a/css/common/import-pic.less b/css/common/import-pic.less
index 80a2074..dd069f9 100644
--- a/css/common/import-pic.less
+++ b/css/common/import-pic.less
@@ -4,10 +4,6 @@
width: 960px;
}
- .form-group {
- width: auto;
- }
-
.modal-body {
padding-bottom: 0;
}
diff --git a/css/main.css b/css/main.css
index 751738d..761eee4 100644
--- a/css/main.css
+++ b/css/main.css
@@ -114,6 +114,7 @@ table {
}
.modal-body {
min-height: 100px;
+ padding-bottom: 5px;
}
.modal-content {
border-color: rgba(0, 0, 0, 0.5);
@@ -139,6 +140,9 @@ table {
.input-group {
margin-bottom: 10px;
}
+.input-group .input-group-addon {
+ text-align: left;
+}
.list-group-item .from {
float: right;
}
@@ -146,10 +150,20 @@ hr {
margin-top: 10px;
margin-bottom: 10px;
}
-.form-inline .form-group {
+.column-2 .form-group,
+.column-3 .form-group,
+.column-4 .form-group {
margin-right: 10px;
+}
+.column-2 .form-group {
+ width: 45%;
+}
+.column-3 .form-group {
width: 30%;
}
+.column-4 .form-group {
+ width: 22%;
+}
.navbar {
height: 50px;
background: #F9F9F9;
@@ -295,6 +309,7 @@ hr {
}
.btn-right {
float: right;
+ margin-left: 10px;
}
body,
html {
@@ -898,27 +913,15 @@ html {
.setting-metrics .modal-dialog {
width: 800px;
}
-.setting-metrics .form-inline .form-group {
- width: 22%;
-}
.setting-metrics .panose-inline {
- margin-bottom: -24px;
+ margin-bottom: -15px;
}
.setting-metrics .panose-inline .input-group {
width: 100%;
}
-.setting-metrics .panose-inline .input-group-addon {
- text-align: left;
-}
-.setting-metrics .panose-inline .form-group {
- width: 29%;
-}
.import-pic-dialog .modal-dialog {
width: 960px;
}
-.import-pic-dialog .form-group {
- width: auto;
-}
.import-pic-dialog .modal-body {
padding-bottom: 0;
}
diff --git a/demo/sync/example.html b/demo/sync/example.html
new file mode 100644
index 0000000..b8dc102
--- /dev/null
+++ b/demo/sync/example.html
@@ -0,0 +1,264 @@
+
+
+
+
+ icon example
+
+
+
+
+
+
fonteditor example
+
+
+
+
+ \e001
+ uniE001
+
+
+
+
+ \e002
+ uniE002
+
+
+
+
+ \e003
+ uniE003
+
+
+
+
+ \e004
+ uniE004
+
+
+
+
+ \e005
+ uniE005
+
+
+
+
+ \e006
+ uniE006
+
+
+
+
+ \e007
+ uniE007
+
+
+
+
+ \e008
+ uniE008
+
+
+
+
+ \e009
+ uniE009
+
+
+
+
+ \e00a
+ uniE00A
+
+
+
+
+ \e00b
+ uniE00B
+
+
+
+
+ \e00c
+ uniE00C
+
+
+
+
+ \e00d
+ uniE00D
+
+
+
+
+ \e00e
+ uniE00E
+
+
+
+
+ \e00f
+ uniE00F
+
+
+
+
+ \e010
+ uniE010
+
+
+
+
+ \e011
+ uniE011
+
+
+
+
+ \e012
+ uniE012
+
+
+
+
+ \e013
+ uniE013
+
+
+
+
+ \e014
+ uniE014
+
+
+
+
+ \e015
+ uniE015
+
+
+
+
+ \e016
+ uniE016
+
+
+
+
+ \e017
+ uniE017
+
+
+
+
+ \e018
+ uniE018
+
+
+
+
+ \e019
+ uniE019
+
+
+
+
+ \e01a
+ uniE01A
+
+
+
+
+ \e01b
+ uniE01B
+
+
+
+
+ \e01c
+ uniE01C
+
+
+
+
+ \e01d
+ uniE01D
+
+
+
+
+ \e01e
+ uniE01E
+
+
+
+
+ \e01f
+ uniE01F
+
+
+
+
+ \e020
+ uniE020
+
+
+
+
+ \e021
+ uniE021
+
+
+
+
+ \e022
+ uniE022
+
+
+
+
+ \e023
+ uniE023
+
+
+
+
+ \e024
+ uniE024
+
+
+
+
+ \e025
+ uniE025
+
+
+
+
+ \e026
+ uniE026
+
+
+
+
+ \e027
+ uniE027
+
+
+
+
+ \e028
+ uniE028
+
+
+
+
+ \e029
+ uniE029
+
+
+
+
+
+
+
diff --git a/demo/sync/font.php b/demo/sync/font.php
new file mode 100644
index 0000000..7cbd210
--- /dev/null
+++ b/demo/sync/font.php
@@ -0,0 +1,45 @@
+ 1,
+ statusInfo => '没有同步的字体名!'
+ ));
+ return;
+ }
+
+ $count = 0;
+ if (empty($encode) || $encode === 'base64') {
+ foreach (explode(',', $fontType) as $type) {
+ if (!empty($_POST[$type])) {
+ writeFile($_POST[$type], $fontName.'.'.$type);
+ $count++;
+ }
+ }
+ }
+
+ callback(array(
+ status => 0,
+ statusInfo => 'sync '.$count.'font files.'
+ ));
+ }
+
+ main();
diff --git a/demo/sync/icon.css b/demo/sync/icon.css
new file mode 100644
index 0000000..cc4fbe1
--- /dev/null
+++ b/demo/sync/icon.css
@@ -0,0 +1,193 @@
+/**
+ * @file icon.css
+ */
+
+@font-face {
+ font-family: "fonteditor";
+ src: url("fonteditor.eot"); /* IE9 */
+ src: url("fonteditor.eot?#iefix") format("embedded-opentype"), /* IE6-IE8 */
+ url("fonteditor.woff") format("woff"), /* chrome、firefox */
+ url("fonteditor.ttf") format("truetype"), /* chrome、firefox、opera、Safari, Android, iOS 4.2+ */
+ url("fonteditor.svg#uxfonteditor") format("svg"); /* iOS 4.1- */
+}
+
+[class^="icon-"],
+[class*=" icon-"]:after {
+ font-family: "fonteditor";
+ speak: none;
+ font-style: normal;
+ font-weight: normal;
+ font-variant: normal;
+ text-transform: none;
+ line-height: 1;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
+
+
+.icon-uniE001:before {
+ content: "\e001";
+}
+
+.icon-uniE002:before {
+ content: "\e002";
+}
+
+.icon-uniE003:before {
+ content: "\e003";
+}
+
+.icon-uniE004:before {
+ content: "\e004";
+}
+
+.icon-uniE005:before {
+ content: "\e005";
+}
+
+.icon-uniE006:before {
+ content: "\e006";
+}
+
+.icon-uniE007:before {
+ content: "\e007";
+}
+
+.icon-uniE008:before {
+ content: "\e008";
+}
+
+.icon-uniE009:before {
+ content: "\e009";
+}
+
+.icon-uniE00A:before {
+ content: "\e00a";
+}
+
+.icon-uniE00B:before {
+ content: "\e00b";
+}
+
+.icon-uniE00C:before {
+ content: "\e00c";
+}
+
+.icon-uniE00D:before {
+ content: "\e00d";
+}
+
+.icon-uniE00E:before {
+ content: "\e00e";
+}
+
+.icon-uniE00F:before {
+ content: "\e00f";
+}
+
+.icon-uniE010:before {
+ content: "\e010";
+}
+
+.icon-uniE011:before {
+ content: "\e011";
+}
+
+.icon-uniE012:before {
+ content: "\e012";
+}
+
+.icon-uniE013:before {
+ content: "\e013";
+}
+
+.icon-uniE014:before {
+ content: "\e014";
+}
+
+.icon-uniE015:before {
+ content: "\e015";
+}
+
+.icon-uniE016:before {
+ content: "\e016";
+}
+
+.icon-uniE017:before {
+ content: "\e017";
+}
+
+.icon-uniE018:before {
+ content: "\e018";
+}
+
+.icon-uniE019:before {
+ content: "\e019";
+}
+
+.icon-uniE01A:before {
+ content: "\e01a";
+}
+
+.icon-uniE01B:before {
+ content: "\e01b";
+}
+
+.icon-uniE01C:before {
+ content: "\e01c";
+}
+
+.icon-uniE01D:before {
+ content: "\e01d";
+}
+
+.icon-uniE01E:before {
+ content: "\e01e";
+}
+
+.icon-uniE01F:before {
+ content: "\e01f";
+}
+
+.icon-uniE020:before {
+ content: "\e020";
+}
+
+.icon-uniE021:before {
+ content: "\e021";
+}
+
+.icon-uniE022:before {
+ content: "\e022";
+}
+
+.icon-uniE023:before {
+ content: "\e023";
+}
+
+.icon-uniE024:before {
+ content: "\e024";
+}
+
+.icon-uniE025:before {
+ content: "\e025";
+}
+
+.icon-uniE026:before {
+ content: "\e026";
+}
+
+.icon-uniE027:before {
+ content: "\e027";
+}
+
+.icon-uniE028:before {
+ content: "\e028";
+}
+
+.icon-uniE029:before {
+ content: "\e029";
+}
+
+
+
diff --git a/demo/sync/page.css b/demo/sync/page.css
new file mode 100644
index 0000000..14cf29e
--- /dev/null
+++ b/demo/sync/page.css
@@ -0,0 +1,137 @@
+* {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+blockquote,
+body,
+button,
+dd,
+dl,
+dt,
+fieldset,
+form,
+h1,
+h2,
+h3,
+h4,
+h5,
+h6,
+hr,
+input,
+legend,
+li,
+ol,
+p,
+pre,
+td,
+textarea,
+th,
+ul {
+ margin: 0;
+ padding: 0;
+}
+body,
+button,
+input,
+select,
+textarea {
+ font: 12px/1.5 tahoma, arial, sans-serif;
+}
+h1,
+h2,
+h3,
+h4,
+h5,
+h6 {
+ font-size: 100%;
+}
+address,
+cite,
+dfn,
+em,
+var {
+ font-style: normal;
+}
+code,
+kbd,
+pre,
+samp {
+ font-family: courier new, courier, monospace;
+}
+small {
+ font-size: 12px;
+}
+ol,
+ul {
+ list-style: none;
+}
+a {
+ text-decoration: none;
+}
+a:hover {
+ text-decoration: underline;
+}
+legend {
+ color: #000000;
+}
+fieldset,
+img {
+ border: 0;
+}
+button,
+input,
+select,
+textarea {
+ font-size: 100%;
+}
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+.main {
+ padding: 30px 100px;
+}
+.main h1 {
+ font-size: 36px;
+ color: #333;
+ text-align: left;
+ margin-bottom: 30px;
+ border-bottom: 1px solid #eeeeee;
+}
+.helps {
+ margin-top: 40px;
+}
+.helps pre {
+ padding: 20px;
+ margin: 10px 0;
+ border: solid 1px #e7e1cd;
+ background-color: #fffdef;
+ overflow: auto;
+}
+.icon-list {
+ overflow: hidden;
+}
+.icon-list li {
+ float: left;
+ width: 100px;
+ height: 150px;
+ text-align: center;
+}
+.icon-list .icon {
+ font-size: 42px;
+ line-height: 100px;
+ margin: 10px 0;
+ color: #333;
+ font-style: normal;
+ -webkit-transition: font-size 0.25s ease-out 0s;
+ -moz-transition: font-size 0.25s ease-out 0s;
+ transition: font-size 0.25s ease-out 0s;
+}
+.icon-list .icon:hover {
+ font-size: 100px;
+}
+.icon-list .code {
+ color: green;
+ font-weight: bold;
+}
diff --git a/index.html b/index.html
index 661913b..7333b3f 100644
--- a/index.html
+++ b/index.html
@@ -126,7 +126,7 @@
-
+
diff --git a/src/fonteditor/controller/actions.js b/src/fonteditor/controller/actions.js
index 6cb43f9..6547896 100644
--- a/src/fonteditor/controller/actions.js
+++ b/src/fonteditor/controller/actions.js
@@ -57,6 +57,16 @@ define(
program.editor.focus();
}, 20);
+ // 延迟同步选项
+ var fontDelaySync = lang.debounce(function (projectId, ttf, syncConfig) {
+ program.loading.show('正在同步...', 4000);
+ program.sync.addTask(projectId, ttf, syncConfig).then(function (reason) {
+ program.loading.show('同步成功...', 400);
+ }, function (reason) {
+ program.loading.show('同步失败:' + reason.statusInfo + '...', 400);
+ });
+ }, 500);
+
var actions = {
'undo': function () {
@@ -125,6 +135,11 @@ define(
.then(function () {
program.ttfManager.setState('saved');
program.loading.show('保存成功...', 400);
+
+ var syncConfig = program.project.getConfig(program.data.projectId).sync;
+ if (syncConfig && !syncConfig.pause) {
+ fontDelaySync(program.data.projectId, program.ttfManager.get(), syncConfig);
+ }
}, function () {
program.loading.show('保存失败...', 1000);
});
@@ -142,6 +157,7 @@ define(
program.ttfManager.setState('new');
program.projectViewer.show(program.project.items(), id);
program.loading.show('保存成功...', 400);
+
}, function () {
program.loading.show('保存失败...', 400);
});
diff --git a/src/fonteditor/controller/default.js b/src/fonteditor/controller/default.js
index 26f7cd4..1d746b5 100644
--- a/src/fonteditor/controller/default.js
+++ b/src/fonteditor/controller/default.js
@@ -347,6 +347,26 @@ define(
}
}).show();
})
+ .on('setting-sync', function (e) {
+ if (program.data.projectId) {
+
+ var syncConfig = program.project.getConfig(program.data.projectId).sync;
+ if (!syncConfig) {
+ syncConfig = {
+ name: program.ttfManager.get().name.fontFamily
+ };
+ }
+
+ var SettingSync = settingSupport.sync;
+ !new SettingSync({
+ onChange: function (setting) {
+ program.project.updateConfig(program.data.projectId, {
+ sync: setting
+ });
+ }
+ }).show(syncConfig);
+ }
+ })
.on('refresh', function (e) {
showTTF(program.ttfManager.get(), 1);
})
diff --git a/src/fonteditor/dialog/setting-sync.js b/src/fonteditor/dialog/setting-sync.js
new file mode 100644
index 0000000..14e2c87
--- /dev/null
+++ b/src/fonteditor/dialog/setting-sync.js
@@ -0,0 +1,49 @@
+/**
+ * @file 同步字体设置
+ * @author mengke01(kekee000@gmail.com)
+ */
+
+
+define(
+ function (require) {
+
+ var tpl = require('../template/dialog/setting-sync.tpl');
+
+ return require('./setting').derive({
+
+ title: '同步字体',
+
+ getTpl: function () {
+ return tpl;
+ },
+
+ set: function (setting) {
+ this.setFields(setting || {});
+ var me = this;
+ $('#setting-sync-cancel').on('click', function () {
+ me.hide(0);
+ });
+ },
+
+ onDispose: function () {
+ $('#setting-sync-cancel').off('click');
+ },
+
+ validate: function () {
+ var setting = this.getFields();
+
+ if (!setting.url || !setting.name) {
+ alert('请设置同步URL和文件名称!');
+ return false;
+ }
+
+ if (!setting.woff && !setting.ttf && !setting.svg && !setting.eot) {
+ alert('请设置文件类型!');
+ return false;
+ }
+
+ return setting;
+ }
+ });
+ }
+);
diff --git a/src/fonteditor/dialog/setting.js b/src/fonteditor/dialog/setting.js
index c690f5f..2082455 100644
--- a/src/fonteditor/dialog/setting.js
+++ b/src/fonteditor/dialog/setting.js
@@ -262,6 +262,17 @@ define(
return this;
};
+ /**
+ * 关闭选项卡
+ */
+ Setting.prototype.hide = function (setting) {
+ if (undefined !== setting) {
+ this.options.onChange && this.options.onChange.call(this, setting);
+ }
+
+ $('#model-dialog').modal('hide');
+ };
+
/**
* 设置设置选项
@@ -282,7 +293,6 @@ define(
return this.setting;
};
-
/**
* 注销
*/
diff --git a/src/fonteditor/dialog/support.js b/src/fonteditor/dialog/support.js
index 28b8860..a1e17fa 100644
--- a/src/fonteditor/dialog/support.js
+++ b/src/fonteditor/dialog/support.js
@@ -20,7 +20,8 @@ define(
'editor': require('../dialog/setting-editor'),
'find-glyf': require('../dialog/setting-find-glyf'),
'ie': require('../dialog/setting-ie'),
- 'import-pic': require('../dialog/setting-import-pic')
+ 'import-pic': require('../dialog/setting-import-pic'),
+ 'sync': require('../dialog/setting-sync')
};
}
);
diff --git a/src/fonteditor/main.js b/src/fonteditor/main.js
index ea4098d..d7418a3 100644
--- a/src/fonteditor/main.js
+++ b/src/fonteditor/main.js
@@ -129,6 +129,9 @@ define(
// 预览器
program.previewer = require('./widget/previewer');
+ // 同步组件
+ program.sync = require('./widget/sync');
+
controller.init(program);
// 加载项目
diff --git a/src/fonteditor/menu/viewer.js b/src/fonteditor/menu/viewer.js
index 0c684ca..1475b5f 100644
--- a/src/fonteditor/menu/viewer.js
+++ b/src/fonteditor/menu/viewer.js
@@ -59,6 +59,10 @@ define(
{
name: 'setting-unicode',
title: '设置代码点'
+ },
+ {
+ name: 'setting-sync',
+ title: '同步字体'
}
];
}
diff --git a/src/fonteditor/template/dialog/setting-editor.tpl b/src/fonteditor/template/dialog/setting-editor.tpl
index 2680e30..a0b00d0 100644
--- a/src/fonteditor/template/dialog/setting-editor.tpl
+++ b/src/fonteditor/template/dialog/setting-editor.tpl
@@ -1,4 +1,4 @@
-