add compond glyf

This commit is contained in:
mkwiser 2014-09-25 00:38:03 +08:00
parent 999a484d8a
commit 9228694de9
6 changed files with 46 additions and 7 deletions

View File

@ -16,8 +16,9 @@ function(require) {
"xMax": 521,
"yMin": -27,
"yMax": 475,
"advanceWidth": 520,
"advanceWidth": 530,
"unicode": 57395,
"name": "uniE033",
"contours": [
[
{

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -45,7 +45,7 @@ define(
// 重置形状
this.render.reset();
var rightSideBearing = offsetX + font.advanceWidth + font.xMin;
var rightSideBearing = offsetX + font.advanceWidth;
initAxis.call(this, {
x: offsetX,
y: offsetY,

View File

@ -14,6 +14,7 @@ define(
function(require) {
var glyFlag = require('../enum/glyFlag');
var table = require('./table');
var componentFlag = require('../enum/componentFlag');
function readSimpleGlyf(reader, ttf, offset, val) {
@ -179,11 +180,48 @@ define(
delete val.endPtsOfContours;
}
else {
val.Compound = true;
val.compound = true;
val.glyf = [];
// 读取复杂字形
//throw 'not support Compound glyf';
console.error('not support Compound glyf', val);
}
do {
var glyf = {};
var flags = glyf.flags = reader.readUint16();
val.glyphIndex = reader.readUint16();
var arg1, arg2, scaleX = 1, scaleY = 1;
if (componentFlag.ARG_1_AND_2_ARE_WORDS & flags) {
if (componentFlag.ARGS_ARE_XY_VALUES & flags) {
arg1 = reader.readUint16();
arg2 = reader.readUint16();
}
else {
arg1 = reader.readInt16();
arg2 = reader.readInt16();
}
}
else {
if (componentFlag.ARGS_ARE_XY_VALUES & flags) {
arg1 = reader.readUint8();
arg2 = reader.readUint8();
}
else {
arg1 = reader.readInt8();
arg2 = reader.readInt8();
}
}
if (componentFlag.ROUND_XY_TO_GRID & flags) {
arg1 = Math.round(arg1);
arg2 = Math.round(arg2);
}
glyf.x = arg1;
glyf.y = arg2;
val.glyf.push(glyf);
}
while(componentFlag.MORE_COMPONENTS & flags);
}
return val;
}