remove not used table

This commit is contained in:
kekee000
2015-01-18 11:45:47 +08:00
parent 32ebba4bdc
commit 2773fd7c4a
11 changed files with 19 additions and 306 deletions

View File

@@ -73,8 +73,8 @@
<ul class="dropdown-menu" role="menu">
<li><a data-format="ttf" data-action="preview">ttf字体</a></li>
<li><a data-format="woff" data-action="preview">woff字体</a></li>
<li><a data-format="svg" data-action="preview" title="仅支持Safari">svg字体</a></li>
<li><a data-format="eot" data-action="preview" title="仅支持IE">eot字体</a></li>
<li><a data-format="svg" data-action="preview" title="仅支持Safari">svg字体(仅safari)</a></li>
<li><a data-format="eot" data-action="preview" title="仅支持IE">eot字体(仅IE)</a></li>
</ul>
</div>
</div>

View File

@@ -23,14 +23,20 @@ define(
*/
function cubic2Points(cubicList, contour) {
var i;
var l;
var q2List = [];
cubicList.forEach(function (c) {
q2List = q2List.concat(bezierCubic2Q2(c[0], c[1], c[2], c[3]));
var list = bezierCubic2Q2(c[0], c[1], c[2], c[3]);
for (i = 0, l = list.length; i < l; i++) {
q2List.push(list[i]);
}
});
var q2;
var prevq2;
for (var i = 0, l = q2List.length; i < l; i++) {
for (i = 0, l = q2List.length; i < l; i++) {
q2 = q2List[i];
if (i === 0) {
contour.push({

View File

@@ -1,29 +0,0 @@
/**
* @file DSIG.js
* @author mengke01
* @date
* @description
* DSIG表
* Digital Signature Table
*
* 暂不支持数字签名解析
* http://www.microsoft.com/typography/otspec/dsig.htm
*/
define(
function (require) {
var table = require('./table');
var struct = require('./struct');
var DSIG = table.create(
'DSIG',
[
['ulVersion', struct.Uint32],
['usNumSigs', struct.Uint16],
['usFlag', struct.Uint16]
]
);
return DSIG;
}
);

View File

@@ -1,30 +0,0 @@
/**
* @file GDEF.js
* @author mengke01
* @date
* @description
* GDEF表
* The Glyph Definition Table
* 暂不支持解析子表,因此四个offset为0
* http://www.microsoft.com/typography/otspec/gdef.htm
*/
define(
function (require) {
var table = require('./table');
var struct = require('./struct');
var GDEF = table.create(
'GDEF',
[
['Version', struct.Uint32],
['GlyphClassDef', struct.Uint16],
['AttachList', struct.Uint16],
['LigCaretList', struct.Uint16],
['MarkAttachClassDef', struct.Uint16]
]
);
return GDEF;
}
);

View File

@@ -1,49 +0,0 @@
/**
* @file GPOS.js
* @author mengke01
* @date
* @description
* GPOS表
* The Glyph Positioning Table
* 暂不支持解析 ScriptList,FeatureList,LookupList 表
*
* http://www.microsoft.com/typography/otspec/gpos.htm
* http://www.microsoft.com/typography/otspec/chapter2.htm
*/
define(
function (require) {
var table = require('./table');
var GPOS = table.create(
'GPOS',
[],
{
read: function (reader) {
reader.seek(this.offset);
var gpos = {};
gpos.Version = reader.readFixed();
gpos.ScriptList = reader.readUint16();
gpos.FeatureList = reader.readUint16();
gpos.LookupList = reader.readUint16();
// 脚本表
gpos.ScriptTbl = {
ScriptCount: reader.readUint16(this.offset + gpos.ScriptList)
};
// 特征表
gpos.FeatureTbl = false;
// 查找表
gpos.LookupTbl = false;
return gpos;
}
}
);
return GPOS;
}
);

View File

@@ -1,51 +0,0 @@
/**
* @file GSUB.js
* @author mengke01
* @date
* @description
* GSUB表
* The Glyph Substitution Table
* 暂不支持解析 ScriptList,FeatureList,LookupList 表
*
* http://www.microsoft.com/typography/otspec/gsub.htm
* http://www.microsoft.com/typography/otspec/chapter2.htm
*/
define(
function (require) {
var table = require('./table');
var ScriptList = require('./ScriptList');
var GSUB = table.create(
'GSUB',
[],
{
read: function (reader) {
reader.seek(this.offset);
var gsub = {};
gsub.Version = reader.readFixed();
gsub.ScriptList = reader.readUint16();
gsub.FeatureList = reader.readUint16();
gsub.LookupList = reader.readUint16();
// 读取脚本表
var scriptList = new ScriptList(this.offset + gsub.ScriptList);
gsub.ScriptTbl = scriptList.read(reader, {
gsub: gsub
});
// 特征表
gsub.FeatureTbl = false;
// 查找表
gsub.LookupTbl = false;
return gsub;
}
}
);
return GSUB;
}
);

View File

@@ -1,66 +0,0 @@
/**
* @file ScriptList.js
* @author mengke01
* @date
* @description
* 脚本表
* 仅完成语言系统解析
* http://www.microsoft.com/typography/otspec/chapter2.htm
*/
define(
function (require) {
var table = require('./table');
var scriptList = table.create(
'ScriptList',
[],
{
read: function (reader) {
reader.seek(this.offset);
var ScriptCount = reader.readUint16();
// script records
var records = [];
var record;
var i;
var j;
var l;
for (i = 0, l = ScriptCount; i < l; i++) {
record = {
ScriptTag: reader.readUint32(),
Offset: reader.readUint16()
};
records.push(record);
}
// script table
var offset = this.offset;
for (i = 0, l = records.length; i < l; i++) {
record = records[i];
reader.seek(offset + record.Offset);
record.DefaultLangSys = reader.readUint16();
var LangSysCount = reader.readUint16();
record.LangSysRecord = [];
// 此处解析语言系统
for (j = 0, l = LangSysCount; j < l; j++) {
var langSysRecord = {
LangSysTag: reader.readUint32(),
LangSys: reader.readUint16()
};
record.LangSysRecord.push(langSysRecord);
}
}
return records;
}
}
);
return scriptList;
}
);

View File

@@ -4,6 +4,8 @@
* @date
* @description
* directory 表, 读取ttf表索引
*
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6.html
*/
@@ -13,8 +15,7 @@ define(
var directory = table.create(
'directory',
[
],
[],
{
read: function (reader, ttf) {
var tables = {};

View File

@@ -1,44 +0,0 @@
/**
* @file gasp.js
* @author mengke01
* @date
* @description
* gasp表
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6gasp.html
*/
define(
function (require) {
var table = require('./table');
var gasp = table.create(
'gasp',
[],
{
read: function (reader) {
var offset = this.offset;
var gasp = {};
reader.seek(offset);
gasp.version = reader.readUint16();
gasp.numRanges = reader.readUint16();
var GASPRangeTbl = [];
for (var i = 0; i < gasp.numRanges; ++i) {
var GASPRange = {};
GASPRange.rangeMaxPPEM = reader.readUint16();
GASPRange.rangeGaspBehavior = reader.readUint16();
GASPRangeTbl.push(GASPRange);
}
gasp.GASPRangeTbl = GASPRangeTbl;
return gasp;
}
}
);
return gasp;
}
);

View File

@@ -27,10 +27,8 @@ define(
return 0;
}
// fixed header + instructions + endPtsOfContours
var result = 10
+ 2
// + (glyf.instructions ? glyf.instructions.length : 0)
// fixed header + endPtsOfContours
var result = 12
+ glyf.contours.length * 2
+ glyfSupport.flags.length;
@@ -81,9 +79,6 @@ define(
});
// if (glyf.instructions) {
// size += 2 + glyf.instructions.length;
// }
return size;
}
@@ -267,8 +262,6 @@ define(
var g = glyf.glyfs[i];
// instructions
// flags += glyf.instructions ? componentFlag.WE_HAVE_INSTRUCTIONS : 0;
// use my metrics
flags += g.useMyMetrics ? componentFlag.USE_MY_METRICS : 0;
// overlap compound
@@ -328,14 +321,6 @@ define(
}
}
// if (glyf.instructions) {
// var instructions = glyf.instructions;
// writer.writeUint16(instructions.length);
// for (var i = 0, l = instructions.length; i < l; i++) {
// writer.writeUint8(instructions[i] & 0xFF);
// }
// }
}
else {
@@ -346,16 +331,7 @@ define(
});
// not support instruction
// if (glyf.instructions) {
// var instructions = glyf.instructions;
// writer.writeUint16(instructions.length);
// for (var i = 0, l = instructions.length; i < l; i++) {
// writer.writeUint8(instructions[i] & 0xFF);
// }
// }
// else {
writer.writeUint16(0);
// }
// 获取暂存中的flags
flags = ttf.support.glyf[index].flags;

View File

@@ -4,6 +4,8 @@
* @date
* @description
* 基本数据结构
*
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6.html
*/
@@ -19,22 +21,19 @@ define(
Uint32: 6,
Fixed: 7, // 32-bit signed fixed-point number (16.16)
FUnit: 8, // Smallest measurable distance in the em space
// 16-bit signed integer (SHORT) that describes a quantity in FUnits.
// FWord: 9,
// Unsigned 16-bit integer (USHORT) that describes a quantity in FUnits
// UFWord: 10,
// 16-bit signed fixed number with the low 14 bits of fraction
F2Dot14: 11,
// The long internal format of a date in seconds since 12:00 midnight,
// January 1, 1904. It is represented as a signed 64-bit integer.
LongDateTime: 12,
// extend data type
Char: 13,
String: 14,
Bytes: 15
};
// 翻转名字查找
// 反转名字查找
var names = {};
Object.keys(struct).forEach(function (key) {
names[struct[key]] = key;