diff --git a/css/main.less b/css/main.less index 90fe836..d6bdcc7 100644 --- a/css/main.less +++ b/css/main.less @@ -1,9 +1,125 @@ - - -@import './ttf.less'; - +@import './common/common.less'; +@import './common/util.less'; +@import './common/ico.less'; @import './common/editor.less'; +.project { + .project-title { + font-weight: bold; + } + .project-list { + line-height: 24px; + + div { + padding: 0 10px; + } + + div:hover { + background: #EFEFEF; + + .i-del { + display: block; + } + } + + .i-del { + float: right; + display: none; + } + } +} + + + + +.glyf-list { + height: 100%; + overflow: auto; + + >.glyf-item { + + float: left; + position: relative; + margin: 10px; + width: 86px; + border: 1px solid #CCC; + box-shadow: 1px 1px 1px #EEE; + border-radius: 6px; + cursor: pointer; + + .unicode, + .name { + font-size: 12px; + line-height: 20px; + height: 20px; + padding-left: 4px; + .ellipsis(); + } + + .unicode { + color: green; + border-top: 1px solid #CCC; + } + + .glyf { + width: 60px; + height: 60px; + margin: 10px; + .path { + fill: green; + } + } + + .i-del, + .i-edit { + position: absolute; + right: 2px; + display: none; + } + + .i-edit { + right: 20px; + } + } + + >.glyf-item:hover { + background: #EFEFEF; + .path { + fill: darkgreen; + } + + .i-del { + display: block; + } + } + + >.compound { + .path { + fill: lightgreen!important; + } + } + + >.new, + >.edit { + .path { + fill: blue!important; + } + } + + >.selected { + background: #EBFFC2!important; + } +} + + +.glyf-list.no-hover { + .glyf-item { + pointer-events: none; + } +} + + + .glyf-list { >.glyf-item:hover { diff --git a/css/ttf.less b/css/ttf.less deleted file mode 100644 index 96607f0..0000000 --- a/css/ttf.less +++ /dev/null @@ -1,121 +0,0 @@ - - -@import './common/common.less'; -@import './common/util.less'; -@import './common/ico.less'; - - -.project { - .project-title { - font-weight: bold; - } - .project-list { - line-height: 24px; - - div { - padding: 0 10px; - } - - div:hover { - background: #EFEFEF; - - .i-del { - display: block; - } - } - - .i-del { - float: right; - display: none; - } - } -} - - - - -.glyf-list { - height: 100%; - overflow: auto; - - >.glyf-item { - - float: left; - position: relative; - margin: 10px; - width: 86px; - border: 1px solid #CCC; - box-shadow: 1px 1px 1px #EEE; - border-radius: 6px; - cursor: pointer; - - .unicode, - .name { - font-size: 12px; - line-height: 20px; - height: 20px; - padding-left: 4px; - .ellipsis(); - } - - .unicode { - color: green; - border-top: 1px solid #CCC; - } - - .glyf { - width: 60px; - height: 60px; - margin: 10px; - .path { - fill: green; - } - } - - .i-del, - .i-edit { - position: absolute; - right: 2px; - display: none; - } - - .i-edit { - right: 20px; - } - } - - >.glyf-item:hover { - background: #EFEFEF; - .path { - fill: darkgreen; - } - - .i-del { - display: block; - } - } - - >.compound { - .path { - fill: lightgreen!important; - } - } - - >.new, - >.edit { - .path { - fill: blue!important; - } - } - - >.selected { - background: #EBFFC2!important; - } -} - - -.glyf-list.no-hover { - .glyf-item { - pointer-events: none; - } -} \ No newline at end of file diff --git a/edp-build-config.js b/edp-build-config.js index 3b8a305..7459666 100644 --- a/edp-build-config.js +++ b/edp-build-config.js @@ -11,7 +11,6 @@ exports.getProcessors = function () { new LessCompiler( { files: [ 'css/main.less', - 'css/ttf.less', 'css/preview.less' ], compileOptions: { @@ -24,8 +23,7 @@ exports.getProcessors = function () { new JsCompressor({ files: [ - 'src/fonteditor/main.js', - 'src/fonteditor/ttf.js' + 'src/fonteditor/main.js' ] }), diff --git a/index.html b/index.html index d909919..c855d93 100644 --- a/index.html +++ b/index.html @@ -118,6 +118,6 @@ define('jquery', $); require(['fonteditor/main']) -
+
\ No newline at end of file diff --git a/src/fonteditor/controller/ttf.js b/src/fonteditor/controller/ttf.js deleted file mode 100644 index fe75374..0000000 --- a/src/fonteditor/controller/ttf.js +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @file default.js - * @author mengke01 - * @date - * @description - * ttf页面的页面控制器 - */ - - -define( - function(require) { - var lang = require('common/lang'); - var clipboard = require('editor/util/clipboard'); - var string = require('common/string'); - - return { - - /** - * 初始化控制器 - * - * @param {Object} program 项目组件 - */ - init: function(program) { - - program.viewer.on('del', function(e) { - if (e.list) { - program.ttfManager.removeGlyf(e.list); - } - }).on('copy', function(e) { - var list = program.ttfManager.getGlyf(e.list); - clipboard.set(list, 'glyf'); - }).on('cut', function(e) { - var list = program.ttfManager.getGlyf(e.list); - clipboard.set(list, 'glyf'); - program.ttfManager.removeGlyf(e.list); - }).on('undo', function(e) { - program.ttfManager.undo(); - }).on('redo', function(e) { - program.ttfManager.redo(); - }); - - program.projectViewer.on('open', function(e) { - var imported = program.project.get(e.projectName); - if (imported) { - if (program.ttfManager.isChanged() && !window.confirm('是否放弃保存当前项目?')) { - return; - } - program.ttfManager.set(imported); - program.data.projectName = e.projectName; - program.viewer.focus(); - } - }).on('del', function(e) { - if (e.projectName && window.confirm('是否删除项目?')) { - program.projectViewer.show(program.project.remove(e.projectName)); - } - program.viewer.focus(); - }); - - program.ttfManager.on('change', function(e) { - program.viewer.show(e.ttf, program.viewer.getSelected()); - program.viewer.focus(); - }); - - - program.on('save', function(e) { - // 保存项目 - if (program.ttfManager.get()) { - if (program.data.projectName) { - program.project.add(program.data.projectName, program.ttfManager.get()); - program.ttfManager.setState('new'); - program.loading.show('保存成功..', 400); - } - else { - var name = ''; - if ((name = window.prompt('请输入项目名称:'))) { - name = string.encodeHTML(name); - var list = program.project.add(name, program.ttfManager.get()); - program.projectViewer.show(list); - program.data.projectName = name; - program.ttfManager.setState('new'); - program.loading.show('保存成功..', 400); - } - } - } - }).on('paste', function(e) { - var glyfList = clipboard.get('glyf'); - if (glyfList && glyfList.length) { - program.ttfManager.appendGlyf(glyfList, program.viewer.getSelected()); - } - }); - - program.init({ - viewer: program.viewer.main.get(0), - editor: null - }); - - window.onbeforeunload = function() { - if (program.ttfManager.isChanged()) { - return '是否放弃保存当前项目?'; - } - }; - } - }; - } -); diff --git a/src/fonteditor/main.js b/src/fonteditor/main.js index 8591051..36d4599 100644 --- a/src/fonteditor/main.js +++ b/src/fonteditor/main.js @@ -20,7 +20,7 @@ define( // 打开文件 function onUpFile(e) { var file = e.target.files[0]; - + console.log(file); if (program.data.action == 'open' && program.loader.supportLoad(file.name)) { program.loader.load(file, { type: file.name.slice(file.name.lastIndexOf('.') + 1).toLowerCase(), @@ -33,13 +33,22 @@ define( } else if (program.data.action == 'import' && program.loader.supportImport(file.name)) { if (program.ttfManager.get()) { - program.loader.load(file, { - type: file.name.slice(file.name.lastIndexOf('.') + 1).toLowerCase(), - success: function(imported) { - if (imported.glyf.length) { - program.ttfManager.merge(imported, {scale: true}); + + var ext = file.name.slice(file.name.lastIndexOf('.') + 1).toLowerCase(); + var reg = new RegExp('\.'+ ext +'$', 'i'); + var files = Array.prototype.slice.call(e.target.files).filter(function(f) { + return reg.test(file.name); + }); + + files.forEach(function(f) { + program.loader.load(f, { + type: ext, + success: function(imported) { + if (imported.glyf.length) { + program.ttfManager.merge(imported, {scale: true}); + } } - } + }); }); } } diff --git a/src/fonteditor/ttf.js b/src/fonteditor/ttf.js deleted file mode 100644 index bd28540..0000000 --- a/src/fonteditor/ttf.js +++ /dev/null @@ -1,106 +0,0 @@ -/** - * @file main.js - * @author mengke01 - * @date - * @description - * ttf管理器 - */ - -define( - function(require) { - - var GLYFViewer = require('./widget/glyfviewer'); - var ProjectViewer = require('./widget/projectviewer'); - var TTFManager = require('./widget/ttfmanager'); - var program = require('./widget/program'); - var controller = require('./controller/ttf'); - var actions = require('./widget/actions'); - - // 打开文件 - function onUpFile(e) { - var file = e.target.files[0]; - - if (program.data.action == 'open' && program.loader.supportLoad(file.name)) { - program.loader.load(file, { - type: file.name.slice(file.name.lastIndexOf('.') + 1).toLowerCase(), - success: function(imported) { - program.viewer.clearSelected(); - program.ttfManager.set(imported); - program.data.projectName = null; - } - }); - } - else if (program.data.action == 'import' && program.loader.supportImport(file.name)) { - if (program.ttfManager.get()) { - program.loader.load(file, { - type: file.name.slice(file.name.lastIndexOf('.') + 1).toLowerCase(), - success: function(imported) { - if (imported.glyf.length) { - program.ttfManager.merge(imported, {scale: true}); - } - } - }); - } - } - else { - alert('无法识别文件类型!'); - } - - e.target.value = ''; - } - - // 绑定组件 - function bindEvent() { - $('.navbar').delegate('[data-action]', 'click', function(e) { - var action = $(this).attr('data-action'); - if (actions[action]) { - program.data.action = action; - actions[action].call(this, e); - } - }); - - $('#export-btn').on('mouseup', actions['export-file']); - $('#export-btn-woff').on('mouseup', actions['export-file']); - $('#export-btn-svg').on('mouseup', actions['export-file']); - $('#export-btn-eot').on('mouseup', actions['export-file']); - - document.getElementById('font-import').addEventListener('change', onUpFile); - } - - var entry = { - - /** - * 初始化 - */ - init: function () { - bindEvent(); - - // 查看器 - program.viewer = new GLYFViewer($('#glyf-list')); - - // 项目管理 - program.project = require('./widget/project'); - program.projectViewer = new ProjectViewer($('#project-list')); - - // ttf管理 - program.ttfManager = new TTFManager(); - - // 导入导出器 - program.loader = require('./widget/loader'); - program.exporter = require('./widget/exporter'); - - // 预览器 - program.previewer = require('./widget/previewer'); - - controller.init(program); - - // 加载项目 - program.projectViewer.show(program.project.items()); - } - }; - - entry.init(); - - return entry; - } -); \ No newline at end of file diff --git a/src/ttf/svg2ttfobject.js b/src/ttf/svg2ttfobject.js index 97a985d..5785d0f 100644 --- a/src/ttf/svg2ttfobject.js +++ b/src/ttf/svg2ttfobject.js @@ -116,7 +116,7 @@ define( var svgNode = xmlDoc.getElementsByTagName('svg')[0]; if (!svgNode) { - error.raise(10104); + error.raise(10106); } var metaNode = xmlDoc.getElementsByTagName('metadata')[0]; diff --git a/ttf.html b/ttf.html deleted file mode 100644 index 5ce3ff5..0000000 --- a/ttf.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - - FontEditor字体编辑器 - - - - - - - - - -
-
-
-
- -
-
正在加载...
- - - - - - - - - -
- - \ No newline at end of file