diff --git a/README.md b/README.md
index 76c4955..70f597b 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,7 @@ fonteditor 在线ttf字体编辑器
[线上地址](http://font.baidu.com)
+[English Version](http://font.baidu.com/index-en.html)
## release log:
@@ -42,3 +43,5 @@ fonteditor 在线ttf字体编辑器
17. 2015-4-12 增加同步字体功能.
18. 2015-4-27 增加otf字体读取和转换ttf功能.
+
+19. 2015-5-29 增加英文版本.
diff --git a/build.sh b/build.sh
index b569d63..edbe13a 100644
--- a/build.sh
+++ b/build.sh
@@ -3,25 +3,24 @@
# 时间戳
version=`date "+%Y%m%d"`
+# build首页版本
+build_index() {
+ node "./build/build-index.js" $version
+}
+
# build静态资源
build_asset() {
edp build --stage=release --force
echo "asset path:./release"
}
-# build模板文件
-build_tpl() {
+# 移动文件到指定目录
+move_asset() {
mv ./release/src ./release/$version
-
- cat ./release/index.html |
- sed -e "s#'\.\/src'#'./$version'#g" |
- tr -s "\n" " " |
- sed 's#[[:space:]]\+# #g' > ./release/index.tmp
-
- mv ./release/index.tmp ./release/index.html
+ cp ./*.html ./release/
}
-
+build_index
build_asset
-build_tpl
+move_asset
diff --git a/build/build-index.js b/build/build-index.js
new file mode 100644
index 0000000..afdd19b
--- /dev/null
+++ b/build/build-index.js
@@ -0,0 +1,50 @@
+/**
+ * @file 编译首页文件,编译为中文版和英文版
+ * @author mengke01(kekee000@gmail.com)
+ */
+var fs = require('fs');
+var path = require('path');
+
+/**
+ * 字符串格式化,支持如 ${xxx.xxx} 的语法
+ * @param {string} source 模板字符串
+ * @param {Object} data 数据
+ * @return {string} 格式化后字符串
+ */
+function format(source, data) {
+ return source.replace(/\$\{([\w.]+)\}/g, function ($0, $1) {
+ var ref = $1.split('.');
+ var refObject = data;
+ var level;
+
+ while (refObject != null && (level = ref.shift())) {
+ refObject = refObject[level];
+ }
+
+ return refObject != null ? refObject : '';
+ });
+}
+
+
+/**
+ * 入口
+ */
+function main(version) {
+ var baseDir = path.dirname(__dirname);
+ var tpl = String(fs.readFileSync(baseDir + '/index.tpl'));
+ tpl = tpl.replace(/\s+/g, ' ').replace('./src', './' + version);
+
+
+
+ var i18n = {};
+ i18n.lang = require('./i18n.zh-cn');
+ var fileContent = format(tpl, i18n);
+ fs.writeFileSync(baseDir + '/index.html', fileContent);
+
+
+ i18n.lang = require('./i18n.en-us');
+ fileContent = format(tpl, i18n);
+ fs.writeFileSync(baseDir + '/index-en.html', fileContent);
+}
+
+main.apply(null, process.argv.slice(2));
diff --git a/build/i18n.en-us.js b/build/i18n.en-us.js
new file mode 100644
index 0000000..0b45d0c
--- /dev/null
+++ b/build/i18n.en-us.js
@@ -0,0 +1,43 @@
+module.exports = exports = {
+ lang: 'en-us',
+ newglyph: 'New Glyph',
+ undo: 'Undo',
+ redo: 'Redo',
+ import: 'Import',
+ import_svg: 'Import svg',
+ import_svg_title: 'Import svg font or svg file',
+ import_pic: 'Import Image',
+ import_pic_title: 'Import image with glyph',
+ import_font: 'Import Font',
+ import_font_title: 'Import ttf,woff,eot,otf font',
+ export_ttf: 'Export ttf',
+ export_woff: 'Export woff',
+ export_zip: 'Export zip file, including ttf,woff,eot,svg font and examples.',
+ save_proj: 'Save Project',
+ onlinefont: 'Online Font',
+ fonturl: 'Font URL',
+ tool: 'Tools',
+ gen_glyph_name: 'Generate Glyph Name',
+ clear_glyph_name: 'Clear Glyph Name',
+ optimize_glyph: 'Optimize Glyph',
+ compound2simple: 'Composite Glyph to Simple Glyph',
+ preview: 'Preview',
+ preview_ttf: 'ttf Font',
+ preview_woff: 'woff Font',
+ preview_svg: 'svg Font(Only safari)',
+ preview_eot: 'eot Font(Only IE)',
+ new_font: 'New',
+ new_font_title: 'new font',
+ open_font: 'Open',
+ open_font_title: 'Open ttf,woff,eot,otf format font file',
+ project_list: 'Project List',
+ close_editor: 'Click or press `F2` to close glyph editor',
+ metrics: 'Metrics',
+ editor_setting: 'Editor Setting',
+ import_and_export: 'Import and Export',
+ setting: 'Setting',
+ help: 'Help',
+ confirm: 'Confirm',
+ cancel: 'Cancel',
+ fontinfo: 'Font Info'
+};
diff --git a/build/i18n.zh-cn.js b/build/i18n.zh-cn.js
new file mode 100644
index 0000000..1310739
--- /dev/null
+++ b/build/i18n.zh-cn.js
@@ -0,0 +1,43 @@
+module.exports = exports = {
+ lang: 'zh-cn',
+ newglyph: '新字形',
+ undo: '撤销',
+ redo: '重做',
+ import: '导入',
+ import_svg: '导入svg',
+ import_svg_title: '导入svg格式字体文件',
+ import_pic: '导入图片',
+ import_pic_title: '导入包含字形的图片',
+ import_font: '导入字体文件',
+ import_font_title: '导入ttf,woff,eot,otf格式字体文件',
+ export_ttf: '导出ttf',
+ export_woff: '导出woff',
+ export_zip: '导出zip,包含ttf,woff,eot,svg等格式字体和icon示例',
+ save_proj: '保存项目',
+ onlinefont: '线上字体',
+ fonturl: '字体URL',
+ tool: '工具',
+ gen_glyph_name: '生成字形名称',
+ clear_glyph_name: '清除字形名称',
+ optimize_glyph: '优化字体',
+ compound2simple: '复合字形转简单字形',
+ preview: '预览',
+ preview_ttf: 'ttf字体',
+ preview_woff: 'woff字体',
+ preview_svg: 'svg字体(仅safari)',
+ preview_eot: 'eot字体(仅IE)',
+ new_font: '新建',
+ new_font_title: '新建ttf字体文件',
+ open_font: '打开',
+ open_font_title: '打开ttf,woff,eot,otf格式字体文件',
+ project_list: '项目列表',
+ close_editor: '点击或者按`F2`键关闭编辑器',
+ metrics: '字体度量',
+ editor_setting: '编辑器设置',
+ import_and_export: '导入和导出',
+ setting: '设置',
+ help: '帮助',
+ confirm: '确定',
+ cancel: '取消',
+ fontinfo: '字体信息'
+};
diff --git a/css/common/common.less b/css/common/common.less
index 31a8385..64bc95f 100644
--- a/css/common/common.less
+++ b/css/common/common.less
@@ -49,11 +49,10 @@ body, html {
top: 0;
>.logo {
- loat: left;
+ float: left;
width: 180px;
height: 50px;
background: url(./img/logo.png) no-repeat;
- float: left;
background-color: #fff;
background-position: center;
background-image: url(./img/logo@1x.png);
@@ -222,22 +221,31 @@ body, html {
pointer-events: none;
}
-.forkme {
+.forkme,
+.userguide,
+.switch-lang {
position: absolute;
color: #FFF;
- right: 2px;
- top: 2px;
- color: #333
-}
-
-.userguide {
- position: absolute;
- color: #FFF;
- right: 2px;
- top: 24px;
color: #333;
}
+.forkme {
+ right: 2px;
+ top: 2px;
+}
+
+.userguide {
+ right: 2px;
+ top: 24px;
+}
+
+.switch-lang {
+ right: 140px;
+ top: 2px;
+ a {
+ color: #666;
+ }
+}
// modal
diff --git a/css/main.css b/css/main.css
index 2c59ad9..ce0e393 100644
--- a/css/main.css
+++ b/css/main.css
@@ -350,11 +350,10 @@ html {
top: 0;
}
.navbar > .logo {
- loat: left;
+ float: left;
width: 180px;
height: 50px;
background: url(img/logo.png) no-repeat;
- float: left;
background-color: #fff;
background-position: center;
background-image: url(img/logo@1x.png);
@@ -486,19 +485,27 @@ html {
background: rgba(222, 222, 222, 0.5);
pointer-events: none;
}
-.forkme {
+.forkme,
+.userguide,
+.switch-lang {
position: absolute;
color: #FFF;
+ color: #333;
+}
+.forkme {
right: 2px;
top: 2px;
- color: #333333;
}
.userguide {
- position: absolute;
- color: #FFF;
right: 2px;
top: 24px;
- color: #333;
+}
+.switch-lang {
+ right: 140px;
+ top: 2px;
+}
+.switch-lang a {
+ color: #666;
}
.modal {
background: -webkit-radial-gradient(center, circle contain, rgba(255, 255, 255, 0.6) 0%, rgba(0, 0, 0, 0.6) 100%);
diff --git a/edp-build-config.js b/edp-build-config.js
index 0e7b06b..55c1928 100644
--- a/edp-build-config.js
+++ b/edp-build-config.js
@@ -58,6 +58,7 @@ exports.getProcessors = function () {
'src/render/**',
'src/ttf/**',
'src/fonteditor/*/**',
+ '*.tpl'
]
})
];
@@ -80,7 +81,8 @@ exports.exclude = [
".gitignore",
"package.json",
"node",
- "node_modules"
+ "node_modules",
+ "build"
];
exports.injectProcessor = function ( processors ) {
diff --git a/index-en.html b/index-en.html
index fca8d97..ee6d724 100644
--- a/index-en.html
+++ b/index-en.html
@@ -1,175 +1 @@
-
-
-
-
- FontEditor
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Fork me on Github
- Help
-
-
-
-
-
-
-
-
-
- Loading...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ FontEditor
\ No newline at end of file
diff --git a/index.html b/index.html
index 3501e45..ad2d42f 100644
--- a/index.html
+++ b/index.html
@@ -1,175 +1 @@
-
-
-
-
- FontEditor
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Fork me on Github
- 帮助
-
-
-
-
-
-
-
-
-
- 正在加载...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ FontEditor
\ No newline at end of file
diff --git a/index.tpl b/index.tpl
new file mode 100644
index 0000000..ca85b59
--- /dev/null
+++ b/index.tpl
@@ -0,0 +1,176 @@
+
+
+
+
+ FontEditor
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Fork me on Github
+ ${lang.help}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${lang.msg_loading}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/.fecsrc b/src/.fecsrc
index eb82220..04908f5 100644
--- a/src/.fecsrc
+++ b/src/.fecsrc
@@ -9,7 +9,8 @@
"no-console": 0,
"fecs-max-statements": 0,
"max-params": 0,
- "max-depth": 0
+ "max-depth": 0,
+ "fecs-camelcase": 0
}
}
}
diff --git a/src/common/I18n.js b/src/common/I18n.js
index 42aec8a..9662227 100644
--- a/src/common/I18n.js
+++ b/src/common/I18n.js
@@ -28,7 +28,11 @@ define(
*/
function I18n(languageList, defaultLanguage) {
this.store = appendLanguage({}, languageList);
- this.setLanguage('en-us' || defaultLanguage || navigator.language.toLowerCase());
+ this.setLanguage(
+ defaultLanguage
+ || navigator && navigator.language.toLowerCase()
+ || 'en-us'
+ );
}
@@ -49,7 +53,6 @@ define(
/**
* 添加一个语言字符串
*
- * @param {string} path 语言路径
* @param {string} language 语言
* @param {Object} langObject 语言对象
* @return {this}
@@ -62,7 +65,7 @@ define(
/**
* 获取当前语言字符串
* @param {string} path 语言路径
- * @return {string=} 语言字符串
+ * @return {string} 语言字符串
*/
I18n.prototype.get = function (path) {
var ref = path.split('.');
diff --git a/src/editor/i18n/en-us.js b/src/editor/i18n/en-us.js
index 7ae4fcc..437fb78 100644
--- a/src/editor/i18n/en-us.js
+++ b/src/editor/i18n/en-us.js
@@ -46,8 +46,8 @@ define(
addpath: 'Add Contour',
addshapes: 'Add Shape',
circle: 'Circle',
- rect: 'Rectangle',
- roundrect: 'Rounded Rectangle',
+ rect: 'Rectangle',
+ roundrect: 'Rounded Rectangle',
star: 'Star',
arrow: 'Arrow',
triangle: 'Triangle',
@@ -65,7 +65,7 @@ define(
addboundreferenceline: 'Bound Reference Line',
rescale: 'Rescale',
fontsetting: 'Font Setting',
- addpoint: 'Add Point',
+ addpoint: 'Add Point',
removepoint: 'Remove Point',
oncurve: 'On Curve',
offcurv: 'Off Curve',
diff --git a/src/editor/i18n/i18n.js b/src/editor/i18n/i18n.js
index 798c66b..b037bbf 100644
--- a/src/editor/i18n/i18n.js
+++ b/src/editor/i18n/i18n.js
@@ -12,7 +12,8 @@ define(
[
['zh-cn', require('./zh-cn')],
['en-us', require('./en-us')]
- ]
+ ],
+ window.language
);
}
);
diff --git a/src/editor/i18n/zh-cn.js b/src/editor/i18n/zh-cn.js
index 5b87f80..872ba23 100644
--- a/src/editor/i18n/zh-cn.js
+++ b/src/editor/i18n/zh-cn.js
@@ -46,8 +46,8 @@ define(
addpath: '添加路径',
addshapes: '添加形状',
circle: '圆',
- rect: '矩形',
- roundrect: '圆角矩形',
+ rect: '矩形',
+ roundrect: '圆角矩形',
star: '五角星',
arrow: '箭头',
triangle: '三角形',
@@ -65,7 +65,7 @@ define(
addboundreferenceline: '添加边界参考线',
rescale: '重置缩放',
fontsetting: '字形信息',
- addpoint: '添加点',
+ addpoint: '添加点',
removepoint: '删除点',
oncurve: '在曲线上',
offcurve: '远离曲线',
diff --git a/src/fonteditor/controller/actions.js b/src/fonteditor/controller/actions.js
index cb909be..f64dc26 100644
--- a/src/fonteditor/controller/actions.js
+++ b/src/fonteditor/controller/actions.js
@@ -6,6 +6,7 @@
define(
function (require) {
+ var i18n = require('../i18n/i18n');
var settingSupport = require('../dialog/support');
var program = require('../widget/program');
var ajaxFile = require('common/ajaxFile');
@@ -44,7 +45,7 @@ define(
});
},
onError: function () {
- alert('加载文件错误!');
+ alert(i18n.lang.msg_read_file_error);
}
});
}
@@ -56,11 +57,11 @@ define(
// 延迟同步选项
var fontDelaySync = lang.debounce(function (projectId, ttf, syncConfig) {
- program.loading.show('正在同步...', 4000);
+ program.loading.show(i18n.lang.msg_syncing, 4000);
program.sync.addTask(projectId, ttf, syncConfig).then(function (reason) {
- program.loading.show('同步成功...', 400);
+ program.loading.show(i18n.lang.msg_sync_success, 400);
}, function (reason) {
- program.loading.show('同步失败:' + reason.statusInfo + '...', 400);
+ program.loading.show(i18n.lang.msg_sync_failed + reason.statusInfo + '...', 400);
});
}, 500);
@@ -138,19 +139,19 @@ define(
program.project.update(projectId, program.ttfManager.get())
.then(function () {
program.ttfManager.setState('saved');
- program.loading.show('保存成功...', 400);
+ program.loading.show(i18n.lang.msg_save_success, 400);
var syncConfig = program.project.getConfig(projectId).sync;
if (syncConfig && syncConfig.autoSync) {
actions.sync(projectId, program.ttfManager.get(), syncConfig);
}
}, function () {
- program.loading.show('保存失败...', 1000);
+ program.loading.show(i18n.lang.msg_save_failed, 1000);
});
}
else {
var name = program.ttfManager.get().name.fontFamily || '';
- if ((name = window.prompt('请输入项目名称:', name))) {
+ if ((name = window.prompt(i18n.lang.msg_input_proj_name, name))) {
name = string.encodeHTML(name);
program.project.add(name, program.ttfManager.get())
@@ -158,10 +159,10 @@ define(
program.data.projectId = id;
program.ttfManager.setState('new');
program.projectViewer.show(program.project.items(), id);
- program.loading.show('保存成功...', 400);
+ program.loading.show(i18n.lang.msg_save_success, 400);
}, function () {
- program.loading.show('保存失败...', 400);
+ program.loading.show(i18n.lang.msg_save_failed, 400);
});
}
}
@@ -184,7 +185,7 @@ define(
!new SettingOnline({
onChange: function (url) {
- program.loading.show('正在加载..', 1000);
+ program.loading.show(i18n.lang.msg_loading, 1000);
// 此处延迟处理
setTimeout(function () {
var type = url.slice(url.lastIndexOf('.') + 1);
@@ -205,7 +206,7 @@ define(
var SettingUrl = settingSupport.url;
!new SettingUrl({
onChange: function (url) {
- program.loading.show('正在加载..', 1000);
+ program.loading.show(i18n.lang.msg_loading, 1000);
// 此处延迟处理
setTimeout(function () {
var fontUrl = string.format(program.readOnline, ['font', encodeURIComponent(url)]);
@@ -249,7 +250,7 @@ define(
'setting-glyf-name': function () {
if (program.ttfManager.get()) {
- if (window.confirm('生成的字形名称会覆盖原来的名称,确定生成?')) {
+ if (window.confirm(i18n.lang.msg_confirm_gen_names)) {
program.ttfManager.genGlyfName(program.viewer.getSelected());
}
}
diff --git a/src/fonteditor/controller/default.js b/src/fonteditor/controller/default.js
index b076490..76560e3 100644
--- a/src/fonteditor/controller/default.js
+++ b/src/fonteditor/controller/default.js
@@ -5,6 +5,7 @@
define(
function (require) {
+ var i18n = require('../i18n/i18n');
var lang = require('common/lang');
var settingSupport = require('../dialog/support');
var clipboard = require('editor/widget/clipboard');
@@ -55,7 +56,7 @@ define(
var font = ttf.glyf[glyfIndex];
if (font) {
if (font.compond) {
- alert('暂不支持复合字形!');
+ alert(i18n.lang.msg_not_support_compound_glyf);
}
else {
program.editor.setFont(lang.clone(font));
@@ -205,7 +206,7 @@ define(
})
.on('edit', function (e) {
- if (program.editor.isChanged() && !confirm('是否放弃保存当前编辑的字形?')) {
+ if (program.editor.isChanged() && !confirm(i18n.lang.msg_confirm_save_glyph)) {
return;
}
@@ -323,7 +324,7 @@ define(
showTTF(program.ttfManager.get(), page, glyfList);
}
else {
- program.loading.warn('未找到相关字形!', 1000);
+ program.loading.warn(i18n.lang.msg_no_related_glhph, 1000);
}
}
}).show();
@@ -376,7 +377,7 @@ define(
editingIndex = program.ttfManager.get().glyf.length;
}
- if (program.editor.isChanged() && !confirm('是否放弃保存当前编辑的字形?')) {
+ if (program.editor.isChanged() && !confirm(i18n.lang.msg_confirm_save_glyph)) {
return;
}
program.viewer.setEditing(--editingIndex);
@@ -398,7 +399,7 @@ define(
editingIndex = -1;
}
- if (program.editor.isChanged() && !confirm('是否放弃保存当前编辑的字形?')) {
+ if (program.editor.isChanged() && !confirm(i18n.lang.msg_confirm_save_glyph)) {
return;
}
program.viewer.setEditing(++editingIndex);
@@ -428,7 +429,7 @@ define(
var oldProjectId = program.data.projectId;
program.project.get(e.projectId).then(function (imported) {
if (imported) {
- if (program.ttfManager.isChanged() && !window.confirm('是否放弃保存当前编辑项目?')) {
+ if (program.ttfManager.isChanged() && !window.confirm(i18n.lang.msg_confirm_save_proj)) {
return;
}
program.ttfManager.set(imported);
@@ -437,7 +438,7 @@ define(
program.viewer.focus();
}
}, function () {
- if (window.confirm('打开项目失败,是否删除项目?')) {
+ if (window.confirm(i18n.lang.msg_error_open_proj)) {
var fnRemoveProject = function () {
program.projectViewer.show(program.project.items(), oldProjectId);
};
@@ -460,7 +461,7 @@ define(
program.data.projectId = null;
}
}, function () {
- program.loading.warn('删除项目失败!', 1000);
+ program.loading.warn(i18n.lang.msg_error_del_proj, 1000);
});
program.viewer.focus();
@@ -594,7 +595,7 @@ define(
window.onbeforeunload = function () {
if (program.ttfManager.isChanged()) {
- return '是否放弃保存当前编辑的项目?';
+ return i18n.lang.msg_confirm_save_proj;
}
};
}
diff --git a/src/fonteditor/i18n/en-us/dialog.js b/src/fonteditor/i18n/en-us/dialog.js
index 18f44c2..f78c7bd 100644
--- a/src/fonteditor/i18n/en-us/dialog.js
+++ b/src/fonteditor/i18n/en-us/dialog.js
@@ -80,9 +80,7 @@ define(
dialog_pic_open: 'Open',
dialog_pic_close: 'Close',
dialog_pic_dilate: 'Dilate',
- dialog_pic_enrode: 'Enrode',
-
-
+ dialog_pic_enrode: 'Enrode'
};
}
);
diff --git a/src/fonteditor/i18n/en-us/editor.js b/src/fonteditor/i18n/en-us/editor.js
index c4e8eed..4ae610c 100644
--- a/src/fonteditor/i18n/en-us/editor.js
+++ b/src/fonteditor/i18n/en-us/editor.js
@@ -45,8 +45,8 @@ define(
sCapHeight: '`H` Height',
yStrikeoutPosition: 'Strikeout Position',
yStrikeoutSize: 'Strikeout Size',
- underlinePosition: '下划线位置',
- underlineThickness: '下划线厚度',
+ underlinePosition: 'Underline Position',
+ underlineThickness: 'Underline Thickness',
ySubscriptXSize: 'Subscript x Size',
ySubscriptYSize: 'Subscript y Size',
ySubscriptXOffset: 'Subscript x Offset',
@@ -68,7 +68,11 @@ define(
postScriptName: 'PostScript Name',
unitsPerEm: 'EM Size',
lowestRecPPEM: 'Lowest Recognized PPEM',
- created: 'Created Time'
+ created: 'Created Time',
+ setting: 'Setting',
+ help: 'Help',
+ confirm: 'Confirm',
+ cancel: 'Cancel'
};
}
diff --git a/src/fonteditor/i18n/en-us/message.js b/src/fonteditor/i18n/en-us/message.js
index ff51ad7..7a975ba 100644
--- a/src/fonteditor/i18n/en-us/message.js
+++ b/src/fonteditor/i18n/en-us/message.js
@@ -6,18 +6,39 @@
define(
function (require) {
return {
-
- msg_not_support_file_type: 'File type not supported.',
+ msg_not_support_file_type: 'Not support this file type!',
msg_loading_pic: 'Loading pic...',
msg_read_pic_error: 'Error reading pic...',
msg_processing: 'Processing...',
msg_input_pic_url: 'Please input pic url!',
msg_no_glyph_to_import: 'No glyph to import',
+ msg_error_read_file: 'Read error file',
+ msg_loading: 'Loading...',
+ msg_confirm_del_proj: 'Do you want to delete project?',
+ msg_not_set_sync_info: 'Not set sync config!',
+ msg_no_sync_font: 'No sync font!',
+ msg_repeat_unicode: 'Repeat unicode, glyph index are:',
+ msg_confirm_del_glyph: 'Do you want to delete glyph?',
+ msg_read_file_error: 'Error read file!',
+ msg_syncing: 'Synchronizing...',
+ msg_sync_success: 'Sync success...',
+ msg_sync_failed: 'Sync failed:',
+ msg_confirm_save_proj: 'Do you want to save current project before leave?',
+ msg_save_success: 'Save success...',
+ msg_save_failed: 'Save failed...',
+ 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_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?',
+ msg_error_del_proj: 'Delete project error, please refresh this page and try delete again!',
+
preview_title: 'Preview {%=fontFormat%} Format Font',
- preview_first_step: 'Step 1: Use font-face to declare fonts.',
- preview_second_step: 'Step 2:Define css styles using {%=fontFamily%}.',
- preview_third_step: 'Step 3:Use font icon unicode to web page.'
+ preview_first_step: 'Step 1: Use `{%=fontFamily%}` as font-face.',
+ preview_second_step: 'Step 2:Define css styles with `{%=fontFamily%}`.',
+ preview_third_step: 'Step 3:Set font unicode to icons on web page.'
};
}
);
diff --git a/src/fonteditor/i18n/i18n.js b/src/fonteditor/i18n/i18n.js
index 1c2d125..73f3043 100644
--- a/src/fonteditor/i18n/i18n.js
+++ b/src/fonteditor/i18n/i18n.js
@@ -18,7 +18,8 @@ define(
['zh-cn', require('./zh-cn/dialog')],
['en-us', require('./en-us/dialog')]
- ]
+ ],
+ window.language
);
}
);
diff --git a/src/fonteditor/i18n/zh-cn/dialog.js b/src/fonteditor/i18n/zh-cn/dialog.js
index 3332440..ae273da 100644
--- a/src/fonteditor/i18n/zh-cn/dialog.js
+++ b/src/fonteditor/i18n/zh-cn/dialog.js
@@ -80,7 +80,7 @@ define(
dialog_pic_open: '消除杂点',
dialog_pic_close: '消除孔洞',
dialog_pic_dilate: '膨胀',
- dialog_pic_enrode: '腐蚀',
+ dialog_pic_enrode: '腐蚀'
};
}
);
diff --git a/src/fonteditor/i18n/zh-cn/editor.js b/src/fonteditor/i18n/zh-cn/editor.js
index 8f35756..86d0e52 100644
--- a/src/fonteditor/i18n/zh-cn/editor.js
+++ b/src/fonteditor/i18n/zh-cn/editor.js
@@ -68,8 +68,11 @@ define(
postScriptName: 'PostScript名称',
unitsPerEm: 'em框大小',
lowestRecPPEM: '最小可读尺寸',
- created: '创建日期'
-
+ created: '创建日期',
+ setting: '设置',
+ help: '帮助',
+ confirm: '确定',
+ cancel: '取消'
};
}
);
diff --git a/src/fonteditor/i18n/zh-cn/message.js b/src/fonteditor/i18n/zh-cn/message.js
index 35fed45..21cabeb 100644
--- a/src/fonteditor/i18n/zh-cn/message.js
+++ b/src/fonteditor/i18n/zh-cn/message.js
@@ -6,13 +6,33 @@
define(
function (require) {
return {
-
msg_not_support_file_type: '不支持的文件类型!',
msg_loading_pic: '正在加载图片...',
msg_read_pic_error: '读取图片失败...',
msg_processing: '正在处理...',
msg_input_pic_url: '请输入图片URL!',
msg_no_glyph_to_import: '没有找到可导入的字形!',
+ msg_error_read_file: '读取文件出错!',
+ msg_loading: '正在加载...',
+ msg_confirm_del_proj: '是否删除项目?',
+ msg_not_set_sync_info: '没有设置同步信息!',
+ msg_no_sync_font: '没有要同步的字体!',
+ msg_repeat_unicode: '重复的unicode代码点,字形序号:',
+ msg_confirm_del_glyph: '确定删除字形么?',
+ msg_read_file_error: '加载文件错误!',
+ msg_syncing: '正在同步...',
+ msg_sync_success: '同步成功...',
+ msg_sync_failed: '同步失败:',
+ msg_confirm_save_proj: '是否放弃保存当前编辑的项目?',
+ msg_save_success: '保存成功...',
+ msg_save_failed: '保存失败...',
+ msg_input_proj_name: '请输入项目名称:',
+ msg_confirm_gen_names: '生成的字形名称会覆盖原来的名称,确定生成?',
+ msg_not_support_compound_glyf: '暂不支持复合字形!',
+ msg_confirm_save_glyph: '是否放弃保存当前编辑的字形?',
+ msg_no_related_glhph: '未找到相关字形!',
+ msg_error_open_proj: '打开项目失败,是否删除项目?',
+ msg_error_del_proj: '删除项目失败,请刷新页面后删除!',
preview_title: '预览{%=fontFormat%}格式字体',
diff --git a/src/fonteditor/main.js b/src/fonteditor/main.js
index 2cba466..1bd89e2 100644
--- a/src/fonteditor/main.js
+++ b/src/fonteditor/main.js
@@ -5,7 +5,7 @@
define(
function (require) {
-
+ var i18n = require('./i18n/i18n');
var GLYFViewer = require('./widget/glyfviewer/GLYFViewer');
var GLYFEditor = require('./widget/GLYFEditor');
var ProjectViewer = require('./widget/ProjectViewer');
@@ -56,13 +56,12 @@ define(
}
}
else {
- alert('无法识别文件类型!');
+ alert(i18n.lang.msg_not_support_file_type);
}
e.target.value = '';
}
-
function bindEvent() {
$('.action-groups').delegate('[data-action]', 'click', function (e) {
var action = $(this).attr('data-action');
@@ -87,6 +86,7 @@ define(
* 初始化
*/
init: function () {
+
bindEvent();
program.setting = require('./widget/settingmanager');
diff --git a/src/fonteditor/menu/viewer.js b/src/fonteditor/menu/viewer.js
index dbd157f..2dc25fd 100644
--- a/src/fonteditor/menu/viewer.js
+++ b/src/fonteditor/menu/viewer.js
@@ -36,11 +36,11 @@ define(
},
{
name: 'adjust-pos',
- title: ei18n.lang.adjustpos,
+ title: ei18n.lang.adjustpos
},
{
name: 'adjust-glyf',
- title: ei18n.lang.adjustglyf,
+ title: ei18n.lang.adjustglyf
},
{
name: 'setting-font',
@@ -52,15 +52,15 @@ define(
},
{
name: 'find-glyf',
- title: i18n.lang.findglyf,
+ title: i18n.lang.findglyf
},
{
name: 'setting-unicode',
- title: i18n.lang.setunicode,
+ title: i18n.lang.setunicode
},
{
name: 'setting-sync',
- title: i18n.lang.syncfont,
+ title: i18n.lang.syncfont
}
];
}
diff --git a/src/fonteditor/template/dialog/setting-adjust-glyf.tpl.js b/src/fonteditor/template/dialog/setting-adjust-glyf.tpl.js
index a61a285..32c0258 100644
--- a/src/fonteditor/template/dialog/setting-adjust-glyf.tpl.js
+++ b/src/fonteditor/template/dialog/setting-adjust-glyf.tpl.js
@@ -1 +1 @@
-define(function () {return '\r\n\r\n\r\n\r\n';});
\ No newline at end of file
+define(function () {return '\r\n\r\n\r\n\r\n';});
\ No newline at end of file
diff --git a/src/fonteditor/template/dialog/setting-adjust-pos.tpl.js b/src/fonteditor/template/dialog/setting-adjust-pos.tpl.js
index 2af9c34..bc895c7 100644
--- a/src/fonteditor/template/dialog/setting-adjust-pos.tpl.js
+++ b/src/fonteditor/template/dialog/setting-adjust-pos.tpl.js
@@ -1 +1 @@
-define(function () {return '\r\n\r\n\r\n';});
\ No newline at end of file
+define(function () {return '\r\n\r\n\r\n';});
\ No newline at end of file
diff --git a/src/fonteditor/template/dialog/setting-editor.tpl.js b/src/fonteditor/template/dialog/setting-editor.tpl.js
index b00a16c..5293ac3 100644
--- a/src/fonteditor/template/dialog/setting-editor.tpl.js
+++ b/src/fonteditor/template/dialog/setting-editor.tpl.js
@@ -1 +1 @@
-define(function () {return '\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n';});
\ No newline at end of file
+define(function () {return '\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n';});
\ No newline at end of file
diff --git a/src/fonteditor/template/dialog/setting-glyf.tpl.js b/src/fonteditor/template/dialog/setting-glyf.tpl.js
index 0c02b3c..e2e3a67 100644
--- a/src/fonteditor/template/dialog/setting-glyf.tpl.js
+++ b/src/fonteditor/template/dialog/setting-glyf.tpl.js
@@ -1 +1 @@
-define(function () {return '\r\n\r\n\r\n\r\n';});
\ No newline at end of file
+define(function () {return '\r\n\r\n\r\n\r\n';});
\ No newline at end of file
diff --git a/src/fonteditor/template/dialog/setting-ie.tpl.js b/src/fonteditor/template/dialog/setting-ie.tpl.js
index e653af0..77112e4 100644
--- a/src/fonteditor/template/dialog/setting-ie.tpl.js
+++ b/src/fonteditor/template/dialog/setting-ie.tpl.js
@@ -1 +1 @@
-define(function () {return '\r\n\r\n';});
\ No newline at end of file
+define(function () {return '\r\n\r\n';});
\ No newline at end of file
diff --git a/src/fonteditor/template/dialog/setting-import-pic.tpl.js b/src/fonteditor/template/dialog/setting-import-pic.tpl.js
index 6d4ce9c..d5a7431 100644
--- a/src/fonteditor/template/dialog/setting-import-pic.tpl.js
+++ b/src/fonteditor/template/dialog/setting-import-pic.tpl.js
@@ -1 +1 @@
-define(function () {return '\r\n';});
\ No newline at end of file
+define(function () {return '\r\n';});
\ No newline at end of file
diff --git a/src/fonteditor/template/dialog/setting-metrics.tpl.js b/src/fonteditor/template/dialog/setting-metrics.tpl.js
index 8bb4f2c..c2618f7 100644
--- a/src/fonteditor/template/dialog/setting-metrics.tpl.js
+++ b/src/fonteditor/template/dialog/setting-metrics.tpl.js
@@ -1 +1 @@
-define(function () {return '\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\n\r\n\r\n\r\n\r\n${panoseOptions}
\r\n\r\n';});
\ No newline at end of file
+define(function () {return '\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\n\r\n\r\n\r\n\r\n${panoseOptions}
\r\n\r\n';});
\ No newline at end of file
diff --git a/src/fonteditor/template/dialog/setting-name.tpl.js b/src/fonteditor/template/dialog/setting-name.tpl.js
index 5754125..b257206 100644
--- a/src/fonteditor/template/dialog/setting-name.tpl.js
+++ b/src/fonteditor/template/dialog/setting-name.tpl.js
@@ -1 +1 @@
-define(function () {return '\r\n 字体家族\r\n \r\n
\r\n\r\n 子字体家族\r\n \r\n
\r\n\r\n 完整字体名\r\n \r\n
\r\n\r\n 唯一字体识别名\r\n \r\n
\r\n\r\n 版本\r\n \r\n
\r\n\r\n PostScript名称\r\n \r\n
\r\n\r\n em框大小\r\n \r\n
\r\n\r\n 最小可读尺寸\r\n \r\n
\r\n\r\n 创建日期\r\n \r\n
\r\n';});
\ No newline at end of file
+define(function () {return '\r\n ${lang.fontFamily}\r\n \r\n
\r\n\r\n ${lang.fontSubFamily}\r\n \r\n
\r\n\r\n ${lang.fullName}\r\n \r\n
\r\n\r\n ${lang.uniqueSubFamily}\r\n \r\n
\r\n\r\n ${lang.version}\r\n \r\n
\r\n\r\n ${lang.postScriptName}\r\n \r\n
\r\n\r\n ${lang.unitsPerEm}\r\n \r\n
\r\n\r\n ${lang.lowestRecPPEM}\r\n \r\n
\r\n\r\n ${lang.created}\r\n \r\n
\r\n';});
\ No newline at end of file
diff --git a/src/fonteditor/template/dialog/setting-sync.tpl.js b/src/fonteditor/template/dialog/setting-sync.tpl.js
index 99f13f7..f11f7d7 100644
--- a/src/fonteditor/template/dialog/setting-sync.tpl.js
+++ b/src/fonteditor/template/dialog/setting-sync.tpl.js
@@ -1 +1 @@
-define(function () {return '\r\n\r\n\r\n\r\n\r\n\r\n';});
\ No newline at end of file
+define(function () {return '\r\n\r\n\r\n\r\n\r\n\r\n';});
\ No newline at end of file
diff --git a/src/fonteditor/template/export/preview-ttf.tpl.js b/src/fonteditor/template/export/preview-ttf.tpl.js
index 88a2d38..8b8806a 100644
--- a/src/fonteditor/template/export/preview-ttf.tpl.js
+++ b/src/fonteditor/template/export/preview-ttf.tpl.js
@@ -1 +1 @@
-define(function () {return '\r\n\r\n\r\n
预览{%=fontFormat%}格式字体
\r\n
\r\n {%glyfList.forEach(function(glyf) {%}\r\n - \r\n {%=glyf.code%}\r\n
{%=glyf.codeName%}
\r\n {%=glyf.name%}
\r\n \r\n {%});%}\r\n
\r\n
第一步:使用font-face声明字体\r\n
\r\n@font-face {\r\n font-family: \'{%=fontFamily%}\';\r\n src: url(\'{%=fontFamily%}.eot\'); /* IE9*/\r\n src: url(\'{%=fontFamily%}.eot?#iefix\') format(\'embedded-opentype\'), /* IE6-IE8 */\r\n url(\'{%=fontFamily%}.woff\') format(\'woff\'), /* chrome、firefox */\r\n url(\'{%=fontFamily%}.ttf\') format(\'truetype\'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/\r\n url(\'{%=fontFamily%}.svg#ux{%=fontFamily%}\') format(\'svg\'); /* iOS 4.1- */\r\n}\r\n\r\n第二步:定义使用{%=fontFamily%}的样式\r\n
\r\n.{%=fontFamily%} {\r\n font-family:"{%=fontFamily%}" !important;\r\n font-size:16px;font-style:normal;\r\n -webkit-font-smoothing: antialiased;\r\n -webkit-text-stroke-width: 0.2px;\r\n -moz-osx-font-smoothing: grayscale;\r\n}\r\n\r\n第三步:挑选相应图标并获取字体编码,应用于页面\r\n
\r\n <i class="{%=fontFamily%}">3</i>\r\n\r\n
\r\n
\r\n';});
\ No newline at end of file
+define(function () {return '\r\n\r\n\r\n
${lang.preview_title}
\r\n
\r\n {%glyfList.forEach(function(glyf) {%}\r\n - \r\n {%=glyf.code%}\r\n
{%=glyf.codeName%}
\r\n {%=glyf.name%}
\r\n \r\n {%});%}\r\n
\r\n
${lang.preview_first_step}\r\n
\r\n@font-face {\r\n font-family: \'{%=fontFamily%}\';\r\n src: url(\'{%=fontFamily%}.eot\'); /* IE9*/\r\n src: url(\'{%=fontFamily%}.eot?#iefix\') format(\'embedded-opentype\'), /* IE6-IE8 */\r\n url(\'{%=fontFamily%}.woff\') format(\'woff\'), /* chrome、firefox */\r\n url(\'{%=fontFamily%}.ttf\') format(\'truetype\'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/\r\n url(\'{%=fontFamily%}.svg#ux{%=fontFamily%}\') format(\'svg\'); /* iOS 4.1- */\r\n}\r\n\r\n${lang.preview_second_step}\r\n
\r\n.{%=fontFamily%} {\r\n font-family:"{%=fontFamily%}" !important;\r\n font-size:16px;font-style:normal;\r\n -webkit-font-smoothing: antialiased;\r\n -webkit-text-stroke-width: 0.2px;\r\n -moz-osx-font-smoothing: grayscale;\r\n}\r\n\r\n${lang.preview_third_step}\r\n
\r\n <i class="{%=fontFamily%}">3</i>\r\n\r\n
\r\n
\r\n';});
\ No newline at end of file
diff --git a/src/fonteditor/widget/ProjectViewer.js b/src/fonteditor/widget/ProjectViewer.js
index 518b98c..da31295 100644
--- a/src/fonteditor/widget/ProjectViewer.js
+++ b/src/fonteditor/widget/ProjectViewer.js
@@ -26,7 +26,7 @@ define(
var action = target.attr('data-action');
var id = target.parents('[data-id]').attr('data-id');
if ('del' === action) {
- if (!window.confirm('是否删除项目?')) {
+ if (!window.confirm(i18n.lang.msg_confirm_del_proj)) {
return;
}
me.current && me.current.remove();
diff --git a/src/fonteditor/widget/TTFManager.js b/src/fonteditor/widget/TTFManager.js
index 6025f04..f532584 100644
--- a/src/fonteditor/widget/TTFManager.js
+++ b/src/fonteditor/widget/TTFManager.js
@@ -5,6 +5,7 @@
define(
function (require) {
+ var i18n = require('../i18n/i18n');
var lang = require('common/lang');
var History = require('editor/widget/History');
var TTF = require('ttf/ttf');
@@ -430,7 +431,7 @@ define(
var message = '';
if (result.repeat) {
- message = '重复的unicode代码点,字形序号:' + result.repeat.join(',');
+ message = i18n.lang.msg_repeat_unicode + result.repeat.join(',');
}
return {
diff --git a/src/fonteditor/widget/glyfviewer/binder.js b/src/fonteditor/widget/glyfviewer/binder.js
index 44a1586..73b5be9 100644
--- a/src/fonteditor/widget/glyfviewer/binder.js
+++ b/src/fonteditor/widget/glyfviewer/binder.js
@@ -7,6 +7,7 @@
define(
function (require) {
+ var i18n = require('../../i18n/i18n');
var lang = require('common/lang');
var DragSelector = require('../DragSelector');
@@ -19,7 +20,7 @@ define(
var selected = +selectedGlyf.attr('data-index');
if (action === 'del') {
- if (!window.confirm('确定删除字形么?')) {
+ if (!window.confirm(i18n.lang.msg_confirm_del_glyph)) {
return;
}
diff --git a/src/fonteditor/widget/loader.js b/src/fonteditor/widget/loader.js
index f724087..ce6ad72 100644
--- a/src/fonteditor/widget/loader.js
+++ b/src/fonteditor/widget/loader.js
@@ -6,7 +6,7 @@
define(
function (require) {
-
+ var i18n = require('../i18n/i18n');
var TTFReader = require('ttf/ttfreader');
var woff2ttf = require('ttf/woff2ttf');
var eot2ttf = require('ttf/eot2ttf');
@@ -76,7 +76,7 @@ define(
fileReader.onerror = function (e) {
loading.hide();
fileReader = null;
- alert('读取文件出错!');
+ alert(i18n.lang.msg_error_read_file);
options.error && options.error(e);
};
fileReader.readAsArrayBuffer(file);
@@ -137,7 +137,7 @@ define(
fileReader.onerror = function (e) {
loading.hide();
fileReader = null;
- alert('读取文件出错!');
+ alert(i18n.lang.msg_error_read_file);
options.error && options.error(e);
};
fileReader.readAsText(file);
@@ -200,7 +200,7 @@ define(
}
else {
options.error && options.error({
- message: '不支持的文件类型'
+ message: i18n.lang.msg_not_support_file_type
});
}
},
diff --git a/src/fonteditor/widget/loading.js b/src/fonteditor/widget/loading.js
index 9da4f07..d1b5c5e 100644
--- a/src/fonteditor/widget/loading.js
+++ b/src/fonteditor/widget/loading.js
@@ -5,6 +5,7 @@
define(
function (require) {
+ var i18n = require('../i18n/i18n');
/**
* 提示
@@ -27,7 +28,7 @@ define(
var loading = $('#loading');
loading.attr('data-status', status || '')
.find('span')
- .html(text || '正在加载...');
+ .html(text || i18n.lang.msg_loading);
loading.show();
if (duration) {
diff --git a/src/fonteditor/widget/projectviewer.js b/src/fonteditor/widget/projectviewer.js
index 518b98c..da31295 100644
--- a/src/fonteditor/widget/projectviewer.js
+++ b/src/fonteditor/widget/projectviewer.js
@@ -26,7 +26,7 @@ define(
var action = target.attr('data-action');
var id = target.parents('[data-id]').attr('data-id');
if ('del' === action) {
- if (!window.confirm('是否删除项目?')) {
+ if (!window.confirm(i18n.lang.msg_confirm_del_proj)) {
return;
}
me.current && me.current.remove();
diff --git a/src/fonteditor/widget/sync.js b/src/fonteditor/widget/sync.js
index 8d9e83c..b5380b2 100644
--- a/src/fonteditor/widget/sync.js
+++ b/src/fonteditor/widget/sync.js
@@ -6,7 +6,7 @@
define(
function (require) {
-
+ var i18n = require('../i18n/i18n');
var Resolver = require('common/promise');
var project = require('./project');
var TTFWriter = require('ttf/ttfwriter');
@@ -112,7 +112,7 @@ define(
if (!syncConfig || !syncConfig.url) {
return Resolver.rejected({
status: 2,
- statusInfo: '没有同步设置!'
+ statusInfo: i18n.lang.msg_not_set_sync_info
});
}
@@ -124,7 +124,7 @@ define(
}, function () {
resolver.reject({
status: 2,
- statusInfo: '没有要同步的字体!'
+ statusInfo: i18n.lang.msg_no_sync_font
});
});
}
diff --git a/src/fonteditor/widget/ttfmanager.js b/src/fonteditor/widget/ttfmanager.js
index 6025f04..f532584 100644
--- a/src/fonteditor/widget/ttfmanager.js
+++ b/src/fonteditor/widget/ttfmanager.js
@@ -5,6 +5,7 @@
define(
function (require) {
+ var i18n = require('../i18n/i18n');
var lang = require('common/lang');
var History = require('editor/widget/History');
var TTF = require('ttf/ttf');
@@ -430,7 +431,7 @@ define(
var message = '';
if (result.repeat) {
- message = '重复的unicode代码点,字形序号:' + result.repeat.join(',');
+ message = i18n.lang.msg_repeat_unicode + result.repeat.join(',');
}
return {
diff --git a/src/ttf/error.js b/src/ttf/error.js
index c51f011..b8bc757 100644
--- a/src/ttf/error.js
+++ b/src/ttf/error.js
@@ -7,36 +7,7 @@ define(function (require) {
var string = require('common/string');
- var error = {
- 10001: '超出读取范围:${0}, ${1}',
- 10002: '超出写入范围:${0}, ${1}',
- 10003: '未知数据类型:${0}, ${1}',
- 10004: '不支持svg解析',
-
- 10101: '错误的ttf文件',
- 10102: '错误的woff文件',
- 10103: '错误的svg文件',
- 10104: '读取ttf文件错误',
- 10105: '读取woff文件错误',
- 10106: '读取svg文件错误',
- 10107: '写入ttf文件错误',
- 10108: '写入woff文件错误',
- 10109: '写入svg文件错误',
-
- 10110: '读取eot文件错误',
- 10111: '读取eot字体错误',
-
- 10200: '重复的unicode代码点,字形序号:${0}',
- 10201: 'ttf字形轮廓数据为空',
- 10202: '不支持标志位:ARGS_ARE_XY_VALUES',
- 10203: '未找到表:${0}',
- 10204: '读取ttf表错误',
- 10205: '未找到解压函数',
-
- 10301: '错误的otf文件',
- 10302: '读取otf表错误',
- 10303: 'otf字形轮廓数据为空'
- };
+ var error = require('./i18n').lang;
/**
* 抛出一个异常
diff --git a/src/ttf/i18n.js b/src/ttf/i18n.js
new file mode 100644
index 0000000..ebe1906
--- /dev/null
+++ b/src/ttf/i18n.js
@@ -0,0 +1,85 @@
+/**
+ * @file 语言字符串管理
+ * @author mengke01(kekee000@gmail.com)
+ */
+
+
+define(
+ function (require) {
+ var I18n = require('common/I18n');
+
+ var zh = {
+ // error define
+ 10001: '超出读取范围:${0}, ${1}',
+ 10002: '超出写入范围:${0}, ${1}',
+ 10003: '未知数据类型:${0}, ${1}',
+ 10004: '不支持svg解析',
+
+ 10101: '错误的ttf文件',
+ 10102: '错误的woff文件',
+ 10103: '错误的svg文件',
+ 10104: '读取ttf文件错误',
+ 10105: '读取woff文件错误',
+ 10106: '读取svg文件错误',
+ 10107: '写入ttf文件错误',
+ 10108: '写入woff文件错误',
+ 10109: '写入svg文件错误',
+
+ 10110: '读取eot文件错误',
+ 10111: '读取eot字体错误',
+
+ 10200: '重复的unicode代码点,字形序号:${0}',
+ 10201: 'ttf字形轮廓数据为空',
+ 10202: '不支持标志位:ARGS_ARE_XY_VALUES',
+ 10203: '未找到表:${0}',
+ 10204: '读取ttf表错误',
+ 10205: '未找到解压函数',
+
+ 10301: '错误的otf文件',
+ 10302: '读取otf表错误',
+ 10303: 'otf字形轮廓数据为空'
+ };
+
+
+ var en = {
+ // error define
+ 10001: 'Reading index out of range: ${0}, ${1}',
+ 10002: 'Writing index out of range: ${0}, ${1}',
+ 10003: 'Unknown datatype: ${0}, ${1}',
+ 10004: 'No svg parser',
+
+ 10101: 'ttf file damaged',
+ 10102: 'woff file damaged',
+ 10103: 'svg file damaged',
+ 10104: 'Read ttf error',
+ 10105: 'Read woff error',
+ 10106: 'Read svg error',
+ 10107: 'Write ttf error',
+ 10108: 'Write woff error',
+ 10109: 'Write svg error',
+
+ 10110: 'Read eot error',
+ 10111: 'Write eot error',
+
+ 10200: 'Repeat unicode, glyph index: ${0}',
+ 10201: 'ttf `glyph` data is empty',
+ 10202: 'Not support compound glyph flag: ARGS_ARE_XY_VALUES',
+ 10203: 'No ttf table: ${0}',
+ 10204: 'Read ttf table data error',
+ 10205: 'No zip deflate function',
+
+ 10301: 'otf file damaged',
+ 10302: 'Read otf table error',
+ 10303: 'otf `glyph` data is empty'
+ };
+
+
+ return new I18n(
+ [
+ ['zh-cn', zh],
+ ['en-us', en]
+ ],
+ window && window.language
+ );
+ }
+);
diff --git a/src/ttf/table/OS2.js b/src/ttf/table/OS2.js
index 151185e..40219a4 100644
--- a/src/ttf/table/OS2.js
+++ b/src/ttf/table/OS2.js
@@ -170,13 +170,15 @@ define(
var compositePoints = 0;
glyf.glyfs.forEach(function (g) {
var cglyf = ttf.glyf[g.glyphIndex];
+ if (!cglyf) {
+ return;
+ }
compositeContours += cglyf.contours ? cglyf.contours.length : 0;
if (cglyf.contours && cglyf.contours.length) {
cglyf.contours.forEach(function (contour) {
compositePoints += contour.length;
});
}
-
});
maxComponentElements++;
diff --git a/src/ttf/util/glyf2svg.js b/src/ttf/util/glyf2svg.js
index b301ed1..dcd6b9b 100644
--- a/src/ttf/util/glyf2svg.js
+++ b/src/ttf/util/glyf2svg.js
@@ -42,7 +42,7 @@ define(
glyfs.forEach(function (g) {
var glyph = ttf.glyf[g.glyphIndex];
- if (!glyph) {
+ if (!glyph || !glyph.contours || !glyph.contours.length) {
return;
}