Commit 355b95ce authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander.Trofimov

FontEngine

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@68387 954022d7-b5bf-4e40-9824-e11837661b57
parent f5362aef
/******************************************************************************/
// stream
/******************************************************************************/
function FT_Frame_Field(v,s,o)
{
this.value = v;
this.size = s;
this.offset = o;
}
function FT_Stream(data, size)
{
this.obj = null;
this.data = data;
this.size = size;
this.pos = 0;
this.cur = 0;
this.Seek = function(_pos)
{
if (_pos > this.size)
return FT_Common.FT_Err_Invalid_Stream_Operation;
this.pos = _pos;
return FT_Common.FT_Err_Ok;
}
this.Skip = function(_skip)
{
if (_skip < 0)
return FT_Common.FT_Err_Invalid_Stream_Operation;
return this.Seek(this.pos + _skip);
}
this.Read = function(pointer, count)
{
return this.ReadAt(this.pos, pointer, count);
}
this.ReadArray = function(count)
{
var read_bytes = this.size - this.pos;
if (read_bytes > count)
read_bytes = count;
if (0 == read_bytes)
return null;
var a = new Array(read_bytes);
for (var i = 0;i<count;i++)
a[i] = this.data[this.pos+i];
return a;
}
this.ReadAt = function(_pos, pointer, count)
{
if (_pos > this.size)
return FT_Common.FT_Err_Invalid_Stream_Operation;
var read_bytes = this.size - _pos;
if (read_bytes > count)
read_bytes = count;
FT_Common.memcpy_p2(pointer,this.data,_pos,count);
this.pos = _pos + read_bytes;
if (read_bytes < count)
return FT_Common.FT_Err_Invalid_Stream_Operation;
return FT_Common.FT_Err_Ok;
}
this.TryRead = function(pointer, count)
{
var read_bytes = 0;
if (this.pos < this.size)
return read_bytes;
read_bytes = this.size - this.pos;
if (read_bytes > count)
read_bytes = count;
FT_Common.memcpy_p2(pointer,this.data,this.pos,count);
this.pos += read_bytes;
return read_bytes;
}
// 1 bytes
this.GetUChar = function()
{
if (this.cur >= this.size)
return 0;
return this.data[this.cur++];
}
this.GetChar = function()
{
if (this.cur >= this.size)
return 0;
var m = this.data[this.cur++];
if (m > FT_Common.m_c)
m -= FT_Common.a_c;
return m;
}
this.GetString1 = function(len)
{
if (this.cur + len > this.size)
return "";
var t = "";
for (var i = 0; i < len; i++)
t += String.fromCharCode(this.data[this.cur + i]);
this.cur += len;
return t;
}
this.ReadString1 = function(len)
{
if (this.pos + len > this.size)
return "";
var t = "";
for (var i = 0; i < len; i++)
t += String.fromCharCode(this.data[this.pos + i]);
this.pos += len;
return t;
}
this.ReadUChar = function()
{
if (this.pos >= this.size)
{
FT_Error = FT_Common.FT_Err_Invalid_Stream_Operation;
return 0;
}
FT_Error = FT_Common.FT_Err_Ok;
return this.data[this.pos++];
}
this.ReadChar = function()
{
if (this.pos >= this.size)
{
FT_Error = FT_Common.FT_Err_Invalid_Stream_Operation;
return 0;
}
FT_Error = FT_Common.FT_Err_Ok;
var m = this.data[this.pos++];
if (m > FT_Common.m_c)
m -= FT_Common.a_c;
return m;
}
// 2 byte
this.GetUShort = function()
{
if (this.cur + 1 >= this.size)
return 0;
return (this.data[this.cur++] << 8 | this.data[this.cur++]);
}
this.GetShort = function()
{
return FT_Common.UShort_To_Short(this.GetUShort());
}
this.ReadUShort = function()
{
if (this.pos + 1 >= this.size)
{
FT_Error = FT_Common.FT_Err_Invalid_Stream_Operation;
return 0;
}
FT_Error = FT_Common.FT_Err_Ok;
return (this.data[this.pos++] << 8 | this.data[this.pos++]);
}
this.ReadShort = function()
{
return FT_Common.UShort_To_Short(this.ReadUShort());
}
this.GetUShortLE = function()
{
if (this.cur + 1 >= this.size)
return 0;
return (this.data[this.cur++] | this.data[this.cur++] << 8);
}
this.GetShortLE = function()
{
return FT_Common.UShort_To_Short(this.GetUShortLE());
}
this.ReadUShortLE = function()
{
if (this.pos + 1 >= this.size)
{
FT_Error = FT_Common.FT_Err_Invalid_Stream_Operation;
return 0;
}
FT_Error = FT_Common.FT_Err_Ok;
return (this.data[this.pos++] | this.data[this.pos++] << 8);
}
this.ReadShortLE = function()
{
return FT_Common.UShort_To_Short(this.ReadUShortLE());
}
// 4 byte
this.GetULong = function()
{
if (this.cur + 3 >= this.size)
return 0;
//return (this.data[this.cur++] << 24 | this.data[this.cur++] << 16 | this.data[this.cur++] << 8 | this.data[this.cur++]);
var s = (this.data[this.cur++] << 24 | this.data[this.cur++] << 16 | this.data[this.cur++] << 8 | this.data[this.cur++]);
if (s < 0)
s += FT_Common.a_i;
return s;
}
this.GetLong = function()
{
// 32-битные числа - по умолчанию знаковые!!!
//return FT_Common.UintToInt(this.GetULong());
return (this.data[this.cur++] << 24 | this.data[this.cur++] << 16 | this.data[this.cur++] << 8 | this.data[this.cur++]);
}
this.ReadULong = function()
{
if (this.pos + 3 >= this.size)
{
FT_Error = FT_Common.FT_Err_Invalid_Stream_Operation;
return 0;
}
FT_Error = FT_Common.FT_Err_Ok;
var s = (this.data[this.pos++] << 24 | this.data[this.pos++] << 16 | this.data[this.pos++] << 8 | this.data[this.pos++]);
if (s < 0)
s += FT_Common.a_i;
return s;
}
this.ReadLong = function()
{
// 32-битные числа - по умолчанию знаковые!!!
//return FT_Common.Uint_To_int(this.ReadULong());
if (this.pos + 3 >= this.size)
{
FT_Error = FT_Common.FT_Err_Invalid_Stream_Operation;
return 0;
}
FT_Error = FT_Common.FT_Err_Ok;
return (this.data[this.pos++] << 24 | this.data[this.pos++] << 16 | this.data[this.pos++] << 8 | this.data[this.pos++]);
}
this.GetULongLE = function()
{
if (this.cur + 3 >= this.size)
return 0;
return (this.data[this.cur++] | this.data[this.cur++] << 8 | this.data[this.cur++] << 16 | this.data[this.cur++] << 24);
}
this.GetLongLE = function()
{
return FT_Common.Uint_To_int(this.GetULongLE());
}
this.ReadULongLE = function()
{
if (this.pos + 3 >= this.size)
{
FT_Error = FT_Common.FT_Err_Invalid_Stream_Operation;
return 0;
}
FT_Error = FT_Common.FT_Err_Ok;
return (this.data[this.pos++] | this.data[this.pos++] << 8 | this.data[this.pos++] << 16 | this.data[this.pos++] << 24);
}
this.ReadLongLE = function()
{
return FT_Common.Uint_To_int(this.ReadULongLE());
}
// 3 byte
this.GetUOffset = function()
{
if (this.cur + 2 >= this.size)
return 0;
return (this.data[this.cur++] << 16 | this.data[this.cur++] << 8 | this.data[this.cur++]);
}
this.GetUOffsetLE = function()
{
if (this.cur + 2 >= this.size)
return 0;
return (this.data[this.cur++] | this.data[this.cur++] << 8 | this.data[this.cur++] << 16);
}
this.ReadUOffset = function()
{
if (this.pos + 2 >= this.size)
{
FT_Error = FT_Common.FT_Err_Invalid_Stream_Operation;
return 0;
}
FT_Error = FT_Common.FT_Err_Ok;
return (this.data[this.pos++] << 16 | this.data[this.pos++] << 8 | this.data[this.pos++]);
}
this.ReadUOffsetLE = function()
{
if (this.pos + 2 >= this.size)
{
FT_Error = FT_Common.FT_Err_Invalid_Stream_Operation;
return 0;
}
FT_Error = FT_Common.FT_Err_Ok;
return (this.data[this.pos++] | this.data[this.pos++] << 8 | this.data[this.pos++] << 16);
}
this.EnterFrame = function(count)
{
if (this.pos >= this.size || this.size - this.pos < count)
return FT_Common.FT_Err_Invalid_Stream_Operation;
this.cur = this.pos;
this.pos += count;
return FT_Common.FT_Err_Ok;
}
this.ExtractFrame = function(count, pointer)
{
if (null == pointer)
pointer = new CPointer();
var err = this.EnterFrame(count);
if (err != FT_Common.FT_Err_Ok)
return err;
pointer.data = this.data;
pointer.pos = this.cur;
this.cur = 0;
return err;
}
this.ReleaseFrame = function()
{
}
this.ExitFrame = function()
{
this.cur = 0;
}
this.ReadFields = function(arrayFields, structure)
{
// arrayFields : array {value, size, offset}
// structures : data pointer
var error = FT_Common.FT_Err_Ok;
var cursor = this.cur;
var frame_accessed = false;
var data = null;
var pos = 0;
var ind = 0;
do
{
var value;
var sign_shift;
switch (arrayFields[ind].value)
{
case 4: /* access a new frame */
error = this.EnterFrame(arrayFields[ind].offset);
if (error != FT_Common.FT_Err_Ok)
{
if (frame_accessed === true)
this.ExitFrame();
return error;
}
frame_accessed = true;
cursor = this.cur;
ind++;
continue; /* loop! */
case 24: /* read a byte sequence */
case 25: /* skip some bytes */
{
var len = arrayFields[ind].size;
if ( cursor + len > this.size )
{
error = FT_Common.FT_Err_Invalid_Stream_Operation;
if (frame_accessed === true)
this.ExitFrame();
return error;
}
if ( arrayFields[ind] == 24 )
{
data = structure.data;
pos = structure.pos + arrayFields[ind].offset;
for (var i=0;i<len;i++)
data[i] = this.data[cursor+i];
}
cursor += len;
ind++;
continue;
}
case 8:
case 9: /* read a single byte */
value = this.data[cursor++];
sign_shift = 24;
break;
case 13:
case 12: /* read a 2-byte big-endian short */
value = this.data[cursor++] << 8 | this.data[cursor++];
sign_shift = 16;
break;
case 15:
case 14: /* read a 2-byte little-endian short */
value = this.data[cursor++] | this.data[cursor++] << 8;
sign_shift = 16;
break;
case 17:
case 16: /* read a 4-byte big-endian long */
value = this.data[cursor++] << 24 | this.data[cursor++] << 16 | this.data[cursor++] << 8 | this.data[cursor++];
sign_shift = 0;
break;
case 19:
case 18: /* read a 4-byte little-endian long */
value = this.data[cursor++] | this.data[cursor++] << 8 | this.data[cursor++] << 16 | this.data[cursor++] << 24;
sign_shift = 0;
break;
case 21:
case 20: /* read a 3-byte big-endian long */
value = this.data[cursor++] << 16 | this.data[cursor++] << 8 | this.data[cursor++];
sign_shift = 8;
break;
case 23:
case 22: /* read a 3-byte little-endian long */
value = this.data[cursor++] | this.data[cursor++] << 8 | this.data[cursor++] << 16;
sign_shift = 8;
break;
default:
/* otherwise, exit the loop */
this.cur = cursor;
if (frame_accessed === true)
this.ExitFrame();
return error;
}
/* now, compute the signed value is necessary */
if ( arrayFields[ind].value & 1 )
value = (( value << sign_shift ) >>> sign_shift) & 0xFFFFFFFF;
/* finally, store the value in the object */
data = structure.data;
pos = structure.pos + arrayFields[ind].offset;
switch (arrayFields[ind])
{
case 1:
data[pos] = value & 0xFF;
break;
case 2:
data[pos] = (value >>> 8)&0xFF;
data[pos+1] = value&0xFF;
break;
case 4:
data[pos] = (value >>> 24)&0xFF;
data[pos+1] = (value >>> 16)&0xFF;
data[pos+2] = (value >>> 8)&0xFF;
data[pos+3] = value&0xFF;
break;
default:
data[pos] = (value >>> 24)&0xFF;
data[pos+1] = (value >>> 16)&0xFF;
data[pos+2] = (value >>> 8)&0xFF;
data[pos+3] = value&0xFF;
}
/* go to next field */
ind++;
}
while ( 1 );
return error;
}
this.ReadFields2 = function(fields, structure)
{
// arrayFields : array {value, size, offset}
// structures : data pointer
var error = FT_Common.FT_Err_Ok;
var cursor = this.cur;
var frame_accessed = false;
var data = null;
var pos = 0;
var ind = 0;
do
{
var value;
var sign_shift;
var fval = fields[ind];
var fsize = fields[ind+1];
var foffset = fields[ind+2];
switch (fval)
{
case 4: /* access a new frame */
error = this.EnterFrame(foffset);
if (error != FT_Common.FT_Err_Ok)
{
if (frame_accessed === true)
this.ExitFrame();
return error;
}
frame_accessed = true;
cursor = this.cur;
ind+=3;
continue; /* loop! */
case 24: /* read a byte sequence */
case 25: /* skip some bytes */
{
if ( cursor + fsize > this.size )
{
error = FT_Common.FT_Err_Invalid_Stream_Operation;
if (frame_accessed === true)
this.ExitFrame();
return error;
}
if ( fval == 24 )
{
data = structure.data;
pos = structure.pos + arrayFields[ind].offset;
for (var i=0;i<len;i++)
data[i] = this.data[cursor+i];
}
cursor += fsize;
ind++;
continue;
}
case 8:
case 9: /* read a single byte */
value = this.data[cursor++];
sign_shift = 24;
break;
case 13:
case 12: /* read a 2-byte big-endian short */
value = this.data[cursor++] << 8 | this.data[cursor++];
sign_shift = 16;
break;
case 15:
case 14: /* read a 2-byte little-endian short */
value = this.data[cursor++] | this.data[cursor++] << 8;
sign_shift = 16;
break;
case 17:
case 16: /* read a 4-byte big-endian long */
value = this.data[cursor++] << 24 | this.data[cursor++] << 16 | this.data[cursor++] << 8 | this.data[cursor++];
sign_shift = 0;
break;
case 19:
case 18: /* read a 4-byte little-endian long */
value = this.data[cursor++] | this.data[cursor++] << 8 | this.data[cursor++] << 16 | this.data[cursor++] << 24;
sign_shift = 0;
break;
case 21:
case 20: /* read a 3-byte big-endian long */
value = this.data[cursor++] << 16 | this.data[cursor++] << 8 | this.data[cursor++];
sign_shift = 8;
break;
case 23:
case 22: /* read a 3-byte little-endian long */
value = this.data[cursor++] | this.data[cursor++] << 8 | this.data[cursor++] << 16;
sign_shift = 8;
break;
default:
/* otherwise, exit the loop */
this.cur = cursor;
if (frame_accessed === true)
this.ExitFrame();
return error;
}
/* now, compute the signed value is necessary */
if (0 != (fval & 1))
value = (( value << sign_shift ) >>> sign_shift) & 0xFFFFFFFF;
/* finally, store the value in the object */
data = structure.data;
pos = structure.pos + arrayFields[ind].offset;
switch (arrayFields[ind])
{
case 1:
data[pos] = value & 0xFF;
break;
case 2:
data[pos] = (value >>> 8)&0xFF;
data[pos+1] = value&0xFF;
break;
case 4:
data[pos] = (value >>> 24)&0xFF;
data[pos+1] = (value >>> 16)&0xFF;
data[pos+2] = (value >>> 8)&0xFF;
data[pos+3] = value&0xFF;
break;
default:
data[pos] = (value >>> 24)&0xFF;
data[pos+1] = (value >>> 16)&0xFF;
data[pos+2] = (value >>> 8)&0xFF;
data[pos+3] = value&0xFF;
}
/* go to next field */
ind+=3;
}
while ( 1 );
return error;
}
}
/******************************************************************************/
// memory
/******************************************************************************/
function CPointer()
{
this.obj = null;
this.data = null;
this.pos = 0;
}
function dublicate_pointer(p)
{
if (null == p)
return null;
var d = new CPointer();
d.data = p.data;
d.pos = p.pos;
return d;
}
function copy_pointer(p, size)
{
var _p = g_memory.Alloc(size);
for (var i = 0; i < size; i++)
_p.data[i] = p.data[p.pos + i];
return _p;
}
function FT_Memory()
{
this.canvas = document.createElement('canvas');
this.canvas.width = 1;
this.canvas.height = 1;
this.ctx = this.canvas.getContext('2d');
this.Alloc = function(size)
{
var p = new CPointer();
p.obj = this.ctx.createImageData(1,parseInt((size + 3) / 4));
p.data = p.obj.data;
p.pos = 0;
return p;
}
this.AllocHeap = function()
{
// TODO: нужно посмотреть, как эта память будет использоваться.
// нужно ли здесь делать стек, либо все время от нуля делать??
}
this.CreateStream = function(size)
{
var _size = parseInt((size + 3) / 4);
var obj = this.ctx.createImageData(1,_size);
return new FT_Stream(obj.data,_size);
}
}
var g_memory = new FT_Memory();
function FT_PEEK_CHAR(p)
{
var r = p.data[p.pos];
if (r > FT_Common.m_c)
return r-FT_Common.a_c;
return r;
}
function FT_NEXT_CHAR(p)
{
var r = p.data[p.pos++];
if (r > FT_Common.m_c)
return r - FT_Common.a_c;
return r;
}
function FT_PEEK_BYTE(p)
{
return p.data[p.pos];
}
function FT_NEXT_BYTE(p)
{
var r = p.data[p.pos++];
return r;
}
function FT_PEEK_SHORT(p)
{
var r = (p.data[p.pos] << 8 | p.data[p.pos+1]);
if (r > FT_Common.m_s)
return r - FT_Common.a_s;
return r;
}
function FT_PEEK_SHORT_LE(p)
{
var r = (p.data[p.pos+1] << 8 | p.data[p.pos]);
if (r > FT_Common.m_s)
return r - FT_Common.a_s;
return r;
}
function FT_NEXT_SHORT(p)
{
var r = (p.data[p.pos++] << 8 | p.data[p.pos++]);
if (r > FT_Common.m_s)
return r - FT_Common.a_s;
return r;
}
function FT_PEEK_USHORT(p)
{
var r = (p.data[p.pos] << 8 | p.data[p.pos+1]);
return r;
}
function FT_PEEK_USHORT_LE(p)
{
var r = (p.data[p.pos + 1] << 8 | p.data[p.pos]);
return r;
}
function FT_NEXT_USHORT(p)
{
var r = (p.data[p.pos++] << 8 | p.data[p.pos++]);
return r;
}
function FT_PEEK_UOFF3(p)
{
var r = (p.data[p.pos] << 16 | p.data[p.pos+1] << 8 | p.data[p.pos+2]);
return r;
}
function FT_NEXT_UOFF3(p)
{
var r = (p.data[p.pos++] << 16 | p.data[p.pos++] << 8 | p.data[p.pos++]);
return r;
}
function FT_PEEK_LONG(p)
{
return (p.data[p.pos] << 24 | p.data[p.pos+1] << 16 | p.data[p.pos+2] << 8 | p.data[p.pos+3]);
}
function FT_NEXT_LONG(p)
{
var r = (p.data[p.pos++] << 24 | p.data[p.pos++] << 16 | p.data[p.pos++] << 8 | p.data[p.pos++]);
return r;
}
function FT_PEEK_ULONG(p)
{
var r = (p.data[p.pos] << 24 | p.data[p.pos+1] << 16 | p.data[p.pos+2] << 8 | p.data[p.pos+3]);
if (r<0)
r+=FT_Common.a_i;
return r;
}
function FT_PEEK_ULONG_LE(p)
{
var r = (p.data[p.pos+3] << 24 | p.data[p.pos+2] << 16 | p.data[p.pos+1] << 8 | p.data[p.pos]);
if (r<0)
r+=FT_Common.a_i;
return r;
}
function FT_NEXT_ULONG(p)
{
var r = (p.data[p.pos++] << 24 | p.data[p.pos++] << 16 | p.data[p.pos++] << 8 | p.data[p.pos++]);
if (r<0)
r+=FT_Common.a_i;
return r;
}
function FT_PEEK_String1(p,len)
{
var t = "";
for (var i = 0; i < len; i++)
{
var r = p.data[p.pos + i];
if (r == 0)
return t;
t += String.fromCharCode(r);
}
return t;
}
function FT_NEXT_String1(p,len)
{
var t = "";
for (var i = 0; i < len; i++)
t += String.fromCharCode(p.data[p.pos + i]);
p.pos+=len;
return t;
}
function ft_memchr(p, v, size)
{
for (var i=0;i<size;i++)
if (p.data[p.pos+i] == v)
return i;
return -1;
}
function _strncmp(s1,s2,n)
{
var m1 = s1.length;
var m2 = s2.length;
var l = n;
if (m1 < l)
l = m1;
if (m2 < l)
l = m2;
for (var i=0;i<l;i++)
{
var c = s1.charCodeAt(i) - s2.charCodeAt(i);
if (c != 0)
return c;
}
return m1 - m2;
}
function _strcmp_data(s,p)
{
var m = s.length;
for (var i=0;i<m;i++)
{
var _c = p.data[p.pos + i];
if (_c == FT_Common.SYMBOL_CONST_S0)
return 1;
var c = s.charCodeAt(i) - _c;
if (c != 0)
return c;
}
if (p.data[p.pos + m] == FT_Common.SYMBOL_CONST_S0)
return 0;
return -1;
}
function _strcmp(s1,s2)
{
return (s1 == s2) ? 0 : 1;
}
function _strncmp_data(p,s,n)
{
var m2 = s.length;
var l = n;
if (m2 < l)
l = m2;
var m1 = 0;
for (var i=0;i<l;i++)
{
m1++;
if (FT_Common.SYMBOL_CONST_S0 == p.data[p.pos + i])
{
m1 = i;
break;
}
var c = p.data[p.pos + i] - s.charCodeAt(i);
if (c != 0)
return c;
}
return m1 - m2;
}
function _strncmp2(s1,s2,n,start1,start2)
{
var m1 = s1.length - start1;
var m2 = s2.length - start2;
var l = n;
if (m1 < l)
l = m1;
if (m2 < l)
l = m2;
for (var i=0;i<l;i++)
{
var c = s1.charCodeAt(i + start1) - s2.charCodeAt(i + start2);
if (c != 0)
return c;
}
return m1 - m2;
}
function _mem_strcpyn1(dst, src, size)
{
var i = 0;
var slen = src.length;
while (size > 1 && i < slen)
{
dst.data[dst.pos + i] = src.charCodeAt(i);
i++;
}
dst.data[dst.pos + i] = 0; /* always zero-terminate */
return i != slen;
}
/******************************************************************************/
// calc
/******************************************************************************/
function FT_LOAD_TARGET_MODE(x)
{
return ((x >>> 16) & 15);
}
function FT_LOAD_TARGET(x)
{
return ((x & 15) << 16);
}
function FT_PIX_FLOOR(x)
{
return x & ~63;
}
function FT_PIX_ROUND(x)
{
return (x + 32) & ~63;
}
function FT_PIX_CEIL(x)
{
return (x + 63) & ~63;
}
function FT_RoundFix(a)
{
return (a >= 0) ? (a + 0x8000) & ~0xFFFF : -((-a + 0x8000) & ~0xFFFF);
}
function FT_CeilFix(a)
{
return (a >= 0) ? (a + 0xFFFF) & ~0xFFFF : -((-a + 0xFFFF) & ~0xFFFF);
}
function FT_FloorFix(a)
{
return (a >= 0) ? a & ~0xFFFF : -((-a) & ~0xFFFF);
}
// int64 support
function _FT_MulDiv(a,b,c)
{
var s = 1;
var d = 0;
if ( a < 0 ) { a = -a; s = -1; }
if ( b < 0 ) { b = -b; s = -s; }
if ( c < 0 ) { c = -c; s = -s; }
d = (c > 0 ? parseInt((a * b + (c >>> 1)) / c) : 0x7FFFFFFF);
return (s > 0) ? d : -d;
}
function _FT_MulFix(a,b)
{
var s = 1;
if (a < 0)
{
a = -a;
s = -1;
}
if (b < 0)
{
b = -b;
s = -s;
}
var c = ((a * b + 0x8000) >>> 16) & 0xFFFFFFFF;
return ( s > 0 ) ? c : -c;
}
function _FT_DivFix(a,b)
{
var q;
var s = 1;
if ( a < 0 ) { a = -a; s = -1; }
if ( b < 0 ) { b = -b; s = -s; }
if (b == 0)
q = 0x7FFFFFFF;
else
{
q = parseInt(((a * 65536) + (b >>> 1)) / b);
if (q < 0)
q += FT_Common.a_i;
}
return (s < 0 ? -q : q);
}
function Int64()
{
this.lo = 0;
this.hi = 0;
}
function ft_multo64(x, y, z)
{
var lo1, hi1, lo2, hi2, lo, hi, i1, i2;
lo1 = x & 0x0000FFFF; hi1 = x >>> 16;
lo2 = y & 0x0000FFFF; hi2 = y >>> 16;
lo = lo1 * lo2;
i1 = lo1 * hi2;
i2 = lo2 * hi1;
hi = hi1 * hi2;
i1 += i2;
if (i1 < i2)
hi += (1 << 16);
hi += i1 >>> 16;
i1 = (i1 << 16) & 0xFFFFFFFF;
if (i1 < 0)
i1 += FT_Common.a_i;
lo += i1;
if (lo < i1)
hi++;
z.lo = lo;
z.hi = hi;
}
function ft_div64by32(hi, lo, y)
{
var q = 0;
var r = hi;
if (r >= y)
return 2147483647;
var i = 32;
do
{
r = (r << 1) & 0xFFFFFFFF;
q = (q << 1) & 0xFFFFFFFF;
if (q < 0)
q += FT_Common.a_i;
r |= lo >>> 31;
if (r < 0)
r += FT_Common.a_i;
if (r >= y)
{
r -= y;
q |= 1;
}
lo = (lo << 1) & 0xFFFFFFFF;
if (lo < 0)
lo += FT_Common.a_i;
} while ( --i );
return q;
}
function FT_Add64(x, y, z)
{
var lo = x.lo + y.lo;
var hi = x.hi + y.hi;
if (lo < x.lo)
hi++;
z.lo = lo;
z.hi = hi;
}
var temp1 = new Int64();
var temp2 = new Int64();
function FT_MulDiv(a, b, c)
{
if (a > FT_Common.m_i || b > FT_Common.m_i || c > FT_Common.m_i)
alert("error");
if (a == 0 || b == c)
return a;
var s = 1;
if ( a < 0 ) { a = -a; s = -1; }
if ( b < 0 ) { b = -b; s = -s; }
if ( c < 0 ) { c = -c; s = -s; }
if (a <= 46340 && b <= 46340 && c <= 176095 && c > 0)
a = ((a * b + (c >> 1)) / c) >> 0;
else if (c > 0)
{
ft_multo64(a >= 0 ? a : a + FT_Common.a_i, b >= 0 ? b : b + FT_Common.a_i, temp1);
temp2.hi = 0;
temp2.lo = (c >>> 1);
FT_Add64(temp1, temp2, temp1);
a = ft_div64by32(temp1.hi, temp1.lo, c);
}
else
a = 0x7FFFFFFF;
return (s < 0 ? -a : a);
}
function FT_MulFix(a, b)
{
if (a > FT_Common.m_i || b > FT_Common.m_i)
{
//alert("error");
a &= 0xFFFFFFFF;
b &= 0xFFFFFFFF;
}
if (a == 0 || b == 0x10000)
return a;
var s = a; a = Math.abs(a);
s ^= b; b = Math.abs(b);
var ua = a < 0 ? a + FT_Common.a_i : a;
var ub = b < 0 ? b + FT_Common.a_i : b;
if (ua <= 2048 && ub <= 1048576)
ua = (ua * ub + 0x8000) >>> 16;
else
{
var al = ua & 0xFFFF;
ua = ((ua >>> 16) * ub) + (al * (ub >>> 16)) + ((al * (ub & 0xFFFF) + 0x8000) >>> 16);
}
var _l = FT_Common.UintToInt(ua);
return (s < 0 ? -_l : _l);
}
function FT_DivFix(a, b)
{
if (a > FT_Common.m_i || b > FT_Common.m_i)
{
a = (a & 0xFFFFFFFF);
b = (b & 0xFFFFFFFF);
}
var q = 0;
var s = 1;
if ( a < 0 ) { a = -a; s = -1; }
if ( b < 0 ) { b = -b; s = -s; }
if (b == 0)
{
q = 0x7FFFFFFF;
}
else if ((a >> 16) == 0)
{
q = parseInt((a * 65536 + parseInt(b / 2)) / b);
//q = parseInt((((a << 16) & 0xFFFFFFFF) + (b >> 1)) / b);
if (q < 0)
q += FT_Common.a_i;
}
else
{
temp1.hi = (a >> 16);
temp1.lo = (a << 16) & 0xFFFFFFFF;
if (temp1.lo < 0)
temp1.lo += FT_Common.a_i;
temp2.hi = 0;
temp2.lo = (b >> 1);
if (temp2.lo < 0)
temp2.lo += FT_Common.a_i;
FT_Add64(temp1, temp2, temp1);
q = ft_div64by32(temp1.hi, temp1.lo, b < 0 ? b + FT_Common.a_i : b);
}
var _q = (q > FT_Common.m_i) ? q - FT_Common.a_i : q;
return (s < 0) ? -_q : _q;
}
function FT_Sqrt32(x)
{
var val, root, newroot, mask;
root = 0;
mask = 0x40000000;
val = x;
do
{
newroot = root + mask;
if ( newroot <= val )
{
val -= newroot;
root = newroot + mask;
}
root >>>= 1;
mask >>>= 2;
} while ( mask != 0 );
return root;
}
function FT_Matrix_Multiply(a, b)
{
var xx, xy, yx, yy;
if ( !a || !b )
return;
xx = FT_MulFix(a.xx, b.xx) + FT_MulFix(a.xy, b.yx);
xy = FT_MulFix(a.xx, b.xy) + FT_MulFix(a.xy, b.yy);
yx = FT_MulFix(a.yx, b.xx) + FT_MulFix(a.yy, b.yx);
yy = FT_MulFix(a.yx, b.xy) + FT_MulFix(a.yy, b.yy);
b.xx = xx; b.xy = xy;
b.yx = yx; b.yy = yy;
}
function FT_Matrix_Invert(matrix)
{
var delta, xx, yy;
if (!matrix)
return FT_Common.FT_Err_Invalid_Argument;
delta = FT_MulFix(matrix.xx, matrix.yy) - FT_MulFix(matrix.xy, matrix.yx);
if ( !delta )
return FT_Common.FT_Err_Invalid_Argument;
matrix.xy = -FT_DivFix(matrix.xy, delta);
matrix.yx = -FT_DivFix(matrix.yx, delta);
xx = matrix.xx;
yy = matrix.yy;
matrix.xx = FT_DivFix(yy, delta);
matrix.yy = FT_DivFix(xx, delta);
return 0;
}
function FT_Matrix_Multiply_Scaled(a, b, scaling)
{
var xx, xy, yx, yy;
var val = 0x10000 * scaling;
if ( !a || !b )
return;
xx = FT_MulDiv(a.xx, b.xx, val) + FT_MulDiv(a.xy, b.yx, val);
xy = FT_MulDiv(a.xx, b.xy, val) + FT_MulDiv(a.xy, b.yy, val);
yx = FT_MulDiv(a.yx, b.xx, val) + FT_MulDiv(a.yy, b.yx, val);
yy = FT_MulDiv(a.yx, b.xy, val) + FT_MulDiv(a.yy, b.yy, val);
b.xx = xx; b.xy = xy;
b.yx = yx; b.yy = yy;
}
function FT_Vector_Transform_Scaled(vector, matrix, scaling)
{
var xz, yz;
var val = 0x10000 * scaling;
if (!vector || !matrix)
return;
xz = FT_MulDiv(vector.x, matrix.xx, val) + FT_MulDiv(vector.y, matrix.xy, val);
yz = FT_MulDiv(vector.x, matrix.yx, val) + FT_MulDiv(vector.y, matrix.yy, val);
vector.x = xz;
vector.y = yz;
}
function FT_SqrtFixed(x)
{
var root, rem_hi, rem_lo, test_div;
var count;
root = 0;
if (x > 0)
{
rem_hi = 0;
rem_lo = x;
count = 24;
do
{
rem_hi = (rem_hi << 2) | (rem_lo >>> 30);
rem_lo <<= 2;
root <<= 1;
test_div = (root << 1) + 1;
if (rem_hi >= test_div)
{
rem_hi -= test_div;
root += 1;
}
} while (--count);
}
return root;
}
function ft_corner_orientation(in_x, in_y, out_x, out_y)
{
var result;
if ( in_y == 0 )
{
if ( in_x >= 0 )
result = out_y;
else
result = -out_y;
}
else if ( in_x == 0 )
{
if ( in_y >= 0 )
result = -out_x;
else
result = out_x;
}
else if ( out_y == 0 )
{
if ( out_x >= 0 )
result = in_y;
else
result = -in_y;
}
else if ( out_x == 0 )
{
if ( out_y >= 0 )
result = -in_x;
else
result = in_x;
}
else
{
var delta = in_x * out_y - in_y * out_x;
if ( delta == 0 )
result = 0;
else
result = 1 - 2 * ( delta < 0 );
}
return result;
}
function ft_corner_is_flat(in_x, in_y, out_x, out_y)
{
var ax = in_x;
var ay = in_y;
var d_in, d_out, d_corner;
if ( ax < 0 )
ax = -ax;
if ( ay < 0 )
ay = -ay;
d_in = ax + ay;
ax = out_x;
if ( ax < 0 )
ax = -ax;
ay = out_y;
if ( ay < 0 )
ay = -ay;
d_out = ax + ay;
ax = out_x + in_x;
if ( ax < 0 )
ax = -ax;
ay = out_y + in_y;
if ( ay < 0 )
ay = -ay;
d_corner = ax + ay;
return (( d_in + d_out - d_corner ) < ( d_corner >>> 4 )) ? 1 : 0;
}
/******************************************************************************/
// glyph
/******************************************************************************/
// bitmap
function ft_bitmap_glyph_init(glyph, slot)
{
var library = glyph.library;
if (slot.format != FT_Common.FT_GLYPH_FORMAT_BITMAP)
return FT_Common.FT_Err_Invalid_Glyph_Format;
glyph.left = slot.bitmap_left;
glyph.top = slot.bitmap_top;
if ((slot.internal.flags & FT_Common.FT_GLYPH_OWN_BITMAP) != 0)
{
var d = glyph.bitmap;
var s = slot.bitmap;
d.rows = s.rows;
d.width = s.width;
d.pitch = s.pitch;
d.buffer = dublicate_pointer(s.buffer);
d.num_grays = s.num_grays;
d.pixel_mode = s.pixel_mode;
d.palette_mode = s.palette_mode;
d.palette = s.palette;
slot.internal.flags &= ~FT_Common.FT_GLYPH_OWN_BITMAP;
}
else
{
FT_Bitmap_New(glyph.bitmap);
return FT_Bitmap_Copy(library, slot.bitmap, glyph.bitmap);
}
return 0;
}
function ft_bitmap_glyph_copy(source, target)
{
target.left = source.left;
target.top = source.top;
return FT_Bitmap_Copy(source.library, source.bitmap, target.bitmap);
}
function ft_bitmap_glyph_done(bitmap_glyph)
{
FT_Bitmap_Done(bitmap_glyph.library, bitmap_glyph.bitmap);
}
function ft_bitmap_glyph_bbox(glyph, cbox)
{
cbox.xMin = glyph.left << 6;
cbox.xMax = cbox.xMin + (glyph.bitmap.width << 6);
cbox.yMax = glyph.top << 6;
cbox.yMin = cbox.yMax - (glyph.bitmap.rows << 6);
}
// outline
function ft_outline_glyph_init(glyph, slot)
{
var source = slot.outline;
var target = glyph.outline;
/* check format in glyph slot */
if (slot.format != FT_Common.FT_GLYPH_FORMAT_OUTLINE)
return FT_Common.FT_Err_Invalid_Glyph_Format;
var error = FT_Outline_New(glyph.library, source.n_points, source.n_contours, glyph.outline);
if (error != 0)
return error;
FT_Outline_Copy(source, target);
return error;
}
function ft_outline_glyph_done(glyph)
{
FT_Outline_Done(glyph.library, glyph.outline);
}
function ft_outline_glyph_copy(source, target)
{
var library = source.library;
var error = FT_Outline_New(library, source.outline.n_points, source.outline.n_contours, target.outline);
if (error != 0)
FT_Outline_Copy(source.outline, target.outline);
return error;
}
function ft_outline_glyph_transform(glyph, matrix, delta)
{
if (matrix != null)
FT_Outline_Transform(glyph.outline, matrix);
if (delta != null)
FT_Outline_Translate(glyph.outline, delta.x, delta.y);
}
function ft_outline_glyph_bbox(glyph, bbox)
{
FT_Outline_Get_CBox(glyph.outline, bbox);
}
function ft_outline_glyph_prepare(glyph, slot)
{
slot.format = FT_Common.FT_GLYPH_FORMAT_OUTLINE;
var d = slot.outline;
var s = glyph.outline;
d.n_contours = s.n_contours;
d.n_points = s.n_points;
d.points = s.points;
d.tags = s.tags;
d.contours = s.contours;
d.flags = s.flags;
slot.outline.flags &= ~FT_Common.FT_OUTLINE_OWNER;
return 0;
}
function _ft_bitmap_glyph_class()
{
this.glyph_size = 0; // glyph_type
this.glyph_format = FT_Common.FT_GLYPH_FORMAT_BITMAP;
this.glyph_init = ft_bitmap_glyph_init;
this.glyph_done = ft_bitmap_glyph_done;
this.glyph_copy = ft_bitmap_glyph_copy;
this.glyph_transform = null;
this.glyph_bbox = ft_bitmap_glyph_bbox;
this.glyph_prepare = null;
}
var ft_bitmap_glyph_class = new _ft_bitmap_glyph_class();
function _ft_outline_glyph_class()
{
this.glyph_size = 1; // glyph_type
this.glyph_format = FT_Common.FT_GLYPH_FORMAT_OUTLINE;
this.glyph_init = ft_outline_glyph_init;
this.glyph_done = ft_outline_glyph_done;
this.glyph_copy = ft_outline_glyph_copy;
this.glyph_transform = ft_outline_glyph_transform;
this.glyph_bbox = ft_outline_glyph_bbox;
this.glyph_prepare = ft_outline_glyph_prepare;
}
var ft_outline_glyph_class = new _ft_outline_glyph_class();
function FT_GlyphRec()
{
this.library = null;
this.clazz = null;
this.format = 0;
this.advance = new FT_Vector();
}
function FT_BitmapGlyphRec()
{
this.library = null;
this.clazz = null;
this.format = 0;
this.advance = new FT_Vector();
this.left = 0;
this.top = 0;
this.bitmap = new FT_Bitmap();
}
function FT_OutlineGlyphRec()
{
this.library = null;
this.clazz = null;
this.format = 0;
this.advance = new FT_Vector();
this.outline = new FT_Outline();
}
function ft_new_glyph(library, clazz)
{
var glyph = null;
if (clazz.glyph_size == 0)
glyph = new FT_BitmapGlyphRec();
else
glyph = new FT_OutlineGlyphRec();
glyph.library = library;
glyph.clazz = clazz;
glyph.format = clazz.glyph_format;
return glyph;
}
/******************************************************************************/
// glyphloader
/******************************************************************************/
function FT_CreateVectorArray(array, start, count)
{
for (var i = start + count - 1; i >= start; i--)
array[i] = new FT_Vector();
}
function FT_CreateArray(array, start, count)
{
for (var i = start + count - 1; i >= start; i--)
array[i] = 0;
}
function FT_CreateArraySubGlyphs(array, start, count)
{
for (var i = start + count - 1; i >= start; i--)
array[i] = new FT_SubGlyph();
}
function FT_OutlineCur()
{
this.n_contours = 0;
this.n_points = 0;
this.points = 0;
this.tags = 0;
this.contours = 0;
this.flags = 0;
}
function FT_SubGlyph()
{
this.index = 0;
this.flags = 0;
this.arg1 = 0;
this.arg2 = 0;
this.transform = new FT_Matrix();
}
function FT_GlyphLoad()
{
this.outline = new FT_Outline();
this.extra_points = null;
this.extra_points2 = 0;
this.num_subglyphs = 0;
this.subglyphs = null;
}
function FT_GlyphLoadCur()
{
this.outline = new FT_OutlineCur();
this.extra_points = 0;
this.extra_points2 = 0;
this.num_subglyphs = 0;
this.subglyphs = 0;
}
function FT_GlyphLoader()
{
this.memory = null;
this.max_points = 0;
this.max_contours = 0;
this.max_subglyphs = 0;
this.use_extra = 0;
this.base = new FT_GlyphLoad();
this.current = new FT_GlyphLoadCur();
this.other = null;
}
function FT_GlyphLoader_New(memory)
{
var loader = new FT_GlyphLoader();
loader.memory = memory;
return loader;
}
function FT_GlyphLoader_Rewind(loader)
{
var base = loader.base;
var current = loader.current;
base.outline.n_points = 0;
base.outline.n_contours = 0;
base.num_subglyphs = 0;
var _cur = current.outline;
_cur.n_contours = 0;
_cur.n_points = 0;
_cur.points = 0;
_cur.tags = 0;
_cur.contours = 0;
_cur.flags = 0;
current.extra_points = 0;
current.extra_points2 = 0;
current.num_subglyphs = 0;
current.subglyphs = 0;
current.extra_points = 0;
current.extra_points2 = base.extra_points2;
}
function FT_GlyphLoader_Reset(loader)
{
var base = loader.base;
base.outline.points = null;
base.outline.tags = null;
base.outline.contours = null;
base.extra_points = null;
base.extra_points2 = 0;
base.subglyphs = null;
loader.max_points = 0;
loader.max_contours = 0;
loader.max_subglyphs = 0;
FT_GlyphLoader_Rewind(loader);
}
function FT_GlyphLoader_Done(loader)
{
if (loader)
FT_GlyphLoader_Reset(loader);
}
function FT_GlyphLoader_Adjust_Points(loader)
{
var base = loader.base.outline;
var current = loader.current.outline;
current.points = base.n_points;
current.tags = base.n_points;
current.contours = base.n_contours;
if (loader.use_extra == 1)
{
loader.current.extra_points = base.n_points;
loader.current.extra_points2 = loader.base.extra_points2 + base.n_points;
}
}
function FT_GlyphLoader_CreateExtra(loader)
{
var c = 2*loader.max_points;
loader.base.extra_points = new Array(c);
FT_CreateVectorArray(loader.base.extra_points, 0, c);
loader.use_extra = 1;
loader.base.extra_points2 = loader.max_points;
FT_GlyphLoader_Adjust_Points(loader);
return 0;
}
function FT_GlyphLoader_Adjust_Subglyphs(loader)
{
loader.current.subglyphs = loader.base.num_subglyphs;
}
function FT_GlyphLoader_CheckPoints(loader, n_points, n_contours)
{
var base = loader.base.outline;
var current = loader.current.outline;
var adjust = 0;
var new_max = base.n_points + current.n_points + n_points;
var old_max = loader.max_points;
if (new_max > old_max)
{
new_max = (new_max + 7) & ~7;
if (new_max > 32767)
return FT_Error.FT_Err_Array_Too_Large;
if (null == base.points)
base.points = new Array(new_max);
if (null == base.tags)
base.tags = new Array(new_max);
FT_CreateVectorArray(base.points, old_max, new_max - old_max);
FT_CreateArray(base.tags, old_max, new_max - old_max);
if (1 == loader.use_extra)
{
if (null == loader.base.extra_points)
loader.base.extra_points = new Array(2 * (new_max - old_max));
FT_CreateVectorArray(loader.base.extra_points, old_max * 2, 2 * (new_max - old_max));
loader.base.extra_points2 = new_max;
}
adjust = 1;
loader.max_points = new_max;
}
/* check contours */
old_max = loader.max_contours;
new_max = base.n_contours + current.n_contours + n_contours;
if (new_max > old_max)
{
new_max = (new_max + 4) & ~4;
if (new_max > 32767)
return FT_Common.FT_Err_Array_Too_Large;
if (base.contours == null)
base.contours = new Array(new_max);
FT_CreateArray(base.contours, old_max, new_max - old_max);
adjust = 1;
loader.max_contours = new_max;
}
if (adjust == 1)
FT_GlyphLoader_Adjust_Points(loader);
return 0;
}
function FT_GlyphLoader_CheckSubGlyphs(loader, n_subs)
{
var base = loader.base;
var current = loader.current;
var new_max = base.num_subglyphs + current.num_subglyphs + n_subs;
var old_max = loader.max_subglyphs;
if (new_max > old_max)
{
new_max = (new_max + 2) & ~2;
if (null == base.subglyphs)
base.subglyphs = new Array(new_max);
FT_CreateArraySubGlyphs(base.subglyphs, old_max, new_max - old_max);
loader.max_subglyphs = new_max;
FT_GlyphLoader_Adjust_Subglyphs(loader);
}
return 0;
}
function FT_GlyphLoader_Prepare(loader)
{
var current = loader.current;
current.outline.n_points = 0;
current.outline.n_contours = 0;
current.num_subglyphs = 0;
FT_GlyphLoader_Adjust_Points(loader);
FT_GlyphLoader_Adjust_Subglyphs(loader);
}
function FT_GlyphLoader_Add(loader)
{
if ( !loader )
return;
var base = loader.base;
var current = loader.current;
var n_curr_contours = current.outline.n_contours;
var n_base_points = base.outline.n_points;
base.outline.n_points = base.outline.n_points + current.outline.n_points;
base.outline.n_contours = base.outline.n_contours + current.outline.n_contours;
base.num_subglyphs += current.num_subglyphs;
var mass = base.outline.contours;
var start = current.outline.contours;
for (var n = 0; n < n_curr_contours; n++)
mass[start+n] = mass[start+n] + n_base_points;
FT_GlyphLoader_Prepare(loader);
}
function FT_GlyphLoader_CopyPoints(target, source)
{
var num_points = source.base.outline.n_points;
var num_contours = source.base.outline.n_contours;
var error = FT_GlyphLoader_CheckPoints(target, num_points, num_contours);
if (error != 0)
{
var _out = target.base.outline;
var _in = source.base.outline;
var i=0;
var out_p = _out.points;
var in_p = _in.points;
var out_t = _out.tags;
var in_t = _in.tags;
for (i=0;i<num_points;i++)
{
out_p[i].x = in_p[i].x;
out_p[i].y = in_p[i].y;
out_t[i] = in_t[i];
}
var out_c = _out.contours;
var in_c = _in.contours;
for (i=0;i<num_contours;i++)
out_c[i] = in_c[i];
if (1 == target.use_extra && 1 == source.use_extra)
{
var out_e = target.base.extra_points;
var in_e = source.base.extra_points;
var c = 2 * num_points;
for (i=0;i<c;i++)
{
out_e[i].x = in_e[i].x;
out_e[i].y = in_e[i].y;
}
}
_out.n_points = num_points;
_out.n_contours = num_contours;
FT_GlyphLoader_Adjust_Points(target);
}
return error;
}
function FT_GLYPHLOADER_CHECK_POINTS(_loader,_points,_contours)
{
if (_points == 0 || (_loader.base.outline.n_points + _loader.current.outline.n_points + _points) <= _loader.max_points)
{
if (_contours == 0 || (_loader.base.outline.n_contours + _loader.current.outline.n_contours + _contours) <= _loader.max_contours)
return 0;
}
return FT_GlyphLoader_CheckPoints(_loader,_points,_contours);
}
/******************************************************************************/
// ftmm
/******************************************************************************/
function FT_MM_Axis()
{
this.name = null;
this.minimum = 0;
this.maximum = 0;
}
function FT_Var_Axis()
{
this.name = null;
this.minimum = 0;
this.def = 0;
this.maximum = 0;
this.tag = 0;
this.strid = 0;
}
function FT_Var_Named_Style()
{
this.coords = null;
this.strid = 0;
}
function FT_MM_Var()
{
this.num_axis = 0;
this.num_designs = 0;
this.num_namedstyles = 0;
this.axis = null;
this.namedstyle = null;
this.dublicate = function()
{
var res = new FT_MM_Var();
res.num_axis = this.num_axis;
res.num_designs = this.num_designs;
res.num_namedstyles = this.num_namedstyles;
var c = res.num_axis;
if (c != 0)
{
res.axis = new Array(c);
for (var i=0;i<c;i++)
{
res.axis[i] = new FT_Var_Axis();
var _m = res.axis[i];
var _s = this.axis[i];
_m.name = _s.name;
_m.minimum = _s.minimum;
_m.def = _s.def;
_m.maximum = _s.maximum;
_m.tag = _s.tag;
_m.strid = _s.strid;
}
}
c = res.num_namedstyles;
if (c != 0)
{
res.namedstyle = new Array(c);
for (var i=0;i<c;i++)
{
res.namedstyle[i] = new FT_Var_Named_Style();
var _m = res.namedstyle[i];
var _s = this.namedstyle[i];
_m.strid = _s.strid;
if (null != _s.coords)
_m.coords = _s.coords.splice(0,0);
}
}
}
}
function FT_Multi_Master()
{
this.num_axis = 0;
this.num_designs = 0;
this.axis = new Array(FT_Common.T1_MAX_MM_AXIS);
for (var i = 0; i < FT_Common.T1_MAX_MM_AXIS; i++)
this.axis[i] = new FT_MM_Axis();
}
/******************************************************************************/
// ftdriver
/******************************************************************************/
function FT_Driver_Class()
{
this.flags = 0;
this.name = "";
this.version = 0;
this.requires = 0;
this.module_interface = null;
this.init = null;
this.done = null;
this.get_interface = null;
this.face_object_size = 0;
this.size_object_size = 0;
this.slot_object_size = 0;
this.init_face = null;
this.done_face = null;
this.init_size = null;
this.done_size = null;
this.init_slot = null;
this.done_slot = null;
//#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
this.set_char_sizes = null;
this.set_pixel_sizes = null;
//#endif
this.load_glyph = null;
this.get_kerning = null;
this.attach_file = null;
this.get_advances = null;
this.request_size = null;
this.select_size = null;
}
//#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
function ft_stub_set_char_sizes(size, width, height, horz_res, vert_res)
{
var driver = size.face.driver;
if (driver.clazz.request_size != null)
{
var req = new FT_Size_RequestRec();
req.type = 0;
req.width = width;
req.height = height;
if (horz_res == 0)
horz_res = vert_res;
if (vert_res == 0)
vert_res = horz_res;
if (horz_res == 0)
horz_res = vert_res = 72;
req.horiResolution = horz_res;
req.vertResolution = vert_res;
return driver.clazz.request_size(size, req);
}
return 0;
}
function ft_stub_set_pixel_sizes(size, width, height)
{
var driver = size.face.driver;
if (driver.clazz.request_size)
{
var req = new FT_Size_RequestRec();
req.type = 0;
req.width = width << 6;
req.height = height << 6;
req.horiResolution = 0;
req.vertResolution = 0;
return driver.clazz.request_size(size, req);
}
return 0;
}
//#endif
/******************************************************************************/
// ftvalid
/******************************************************************************/
function FT_ValidatorRec()
{
this.base = new CPointer();
this.limit = 0;
this.level = 0
this.error = 0
}
/******************************************************************************/
// pshints
/******************************************************************************/
/******************************************************************************/
// tttypes
/******************************************************************************/
function TTC_HeaderRec()
{
this.tag = 0;
this.version = 0;
this.count = 0;
this.offsets = null;
}
function SFNT_HeaderRec()
{
this.format_tag = 0;
this.num_tables = 0;
this.search_range = 0;
this.entry_selector = 0;
this.range_shift = 0;
this.offset = 0; /* not in file */
}
function TT_Table()
{
this.Tag = 0;
this.CheckSum = 0;
this.Offset = 0;
this.Length = 0;
}
function TT_LongMetricsRec()
{
this.advance = 0;
this.bearing = 0;
}
function TT_NameEntryRec()
{
this.platformID = 0;
this.encodingID = 0;
this.languageID = 0;
this.nameID = 0;
this.stringLength = 0;
this.stringOffset = 0;
this.string = null;
}
function TT_NameTableRec()
{
this.format = 0;
this.numNameRecords = 0;
this.storageOffset = 0;
this.names = null;
this.stream = null;
}
function TT_GaspRange()
{
this.maxPPEM = 0;
this.gaspFlag = 0;
}
function TT_Gasp()
{
this.version = 0;
this.numRanges = 0;
this.gaspRanges = null;
}
//#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
function TT_HdmxEntryRec()
{
this.ppem = 0;
this.max_width = 0;
this.widths = null;
}
function TT_HdmxRec()
{
this.version = 0;
this.num_records = 0;
this.records = null;
}
function TT_Kern0_PairRec()
{
this.left = 0;
this.right = 0;
this.value = 0;
}
//#endif
function TT_SBit_MetricsRec()
{
this.height = 0;
this.width = 0;
this.horiBearingX = 0;
this.horiBearingY = 0;
this.horiAdvance = 0;
this.vertBearingX = 0;
this.vertBearingY = 0;
this.vertAdvance = 0;
}
function TT_SBit_Small_Metrics()
{
this.height = 0;
this.width = 0;
this.bearingX = 0;
this.bearingY = 0;
this.advance = 0;
}
function TT_SBit_LineMetricsRec()
{
this.ascender = 0;
this.descender = 0;
this.max_width = 0;
this.caret_slope_numerator = 0;
this.caret_slope_denominator = 0;
this.caret_offset = 0;
this.min_origin_SB = 0;
this.min_advance_SB = 0;
this.max_before_BL = 0;
this.min_after_BL = 0;
this.pad1 = 0;
this.pad2 = 0;
}
function TT_SBit_RangeRec()
{
this.first_glyph = 0;
this.last_glyph = 0;
this.index_format = 0;
this.image_format = 0;
this.image_offset = 0;
this.image_size = 0;
this.metrics = new TT_SBit_MetricsRec();
this.num_glyphs = 0;
this.glyph_offsets = null;
this.glyph_codes = null;
this.table_offset = 0;
}
function TT_SBit_StrikeRec()
{
this.num_ranges = 0;
this.sbit_ranges = null;
this.ranges_offset = 0;
this.color_ref = 0;
this.hori = new TT_SBit_LineMetricsRec();
this.vert = new TT_SBit_LineMetricsRec();
this.start_glyph = 0;
this.end_glyph = 0;
this.x_ppem = 0;
this.y_ppem = 0;
this.bit_depth = 0;
this.flags = 0;
}
function TT_SBit_ComponentRec()
{
this.glyph_code = 0;
this.x_offset = 0;
this.y_offset = 0;
}
function TT_SBit_ScaleRec()
{
this.hori = new TT_SBit_LineMetricsRec();
this.vert = new TT_SBit_LineMetricsRec();
this.x_ppem = 0;
this.y_ppem = 0;
this.x_ppem_substitute = 0;
this.y_ppem_substitute = 0;
}
function TT_Post_20Rec()
{
this.num_glyphs = 0;
this.num_names = 0;
this.glyph_indices = null;
this.glyph_names = null;
}
function TT_Post_25Rec()
{
this.num_glyphs = 0;
this.offsets = null;
}
function TT_Post_NamesRec()
{
this.loaded = false;
this.format = null;
}
//#ifdef TT_CONFIG_OPTION_BDF
function TT_BDFRec()
{
this.table = null;
this.table_end = 0;
this.strings = null;
this.strings_size = 0;
this.num_strikes = 0;
this.loaded = 0;
}
//#endif
function TT_GlyphZoneRec()
{
this.memory = null;
this.max_points = 0;
this.max_contours = 0;
this.n_points = 0; /* number of points in zone */
this.n_contours = 0; /* number of contours */
this.org = null; /* original point coordinates */
this.cur = null; /* current point coordinates */
this.orus = null; /* original (unscaled) point coordinates */
this.tags = null; /* current touch flags */
this.contours = null; /* contour end points */
this._offset_org = 0;
this._offset_cur = 0;
this._offset_orus = 0;
this._offset_tags = 0;
this._offset_contours = 0;
this.first_point = 0; /* offset of first (#0) point */
}
TT_GlyphZoneRec.prototype =
{
Clear : function()
{
this.memory = null;
this.max_points = 0;
this.max_contours = 0;
this.n_points = 0;
this.n_contours = 0;
this.org = null;
this.cur = null;
this.orus = null;
this.tags = null;
this.contours = null;
this._offset_org = 0;
this._offset_cur = 0;
this._offset_orus = 0;
this._offset_tags = 0;
this._offset_contours = 0;
this.first_point = 0;
},
Copy : function(src)
{
this.memory = src.memory;
this.max_points = src.max_points;
this.max_contours = src.max_contours;
this.n_points = src.n_points;
this.n_contours = src.n_contours;
this.org = src.org;
this.cur = src.cur;
this.orus = src.orus;
this.tags = src.tags;
this.contours = src.contours;
this._offset_org = src._offset_org;
this._offset_cur = src._offset_cur;
this._offset_orus = src._offset_orus;
this._offset_tags = src._offset_tags;
this._offset_contours = src._offset_contours;
this.first_point = src.first_point;
}
}
function TT_LoaderRec()
{
this.face = null;
this.size = null;
this.glyph = null;
this.gloader = null;
this.load_flags = 0;
this.glyph_index = 0;
this.stream = null;
this.byte_len = 0;
this.n_contours = 0;
this.bbox = new FT_BBox();
this.left_bearing = 0;
this.advance = 0;
this.linear = 0;
this.linear_def = 0;
this.preserve_pps = 0;
this.pp1 = new FT_Vector();
this.pp2 = new FT_Vector();
this.glyf_offset = 0;
this.base = new TT_GlyphZoneRec();
this.zone = new TT_GlyphZoneRec();
this.exec = null;
this.instructions = null;
this.ins_pos = 0;
this.other = null;
this.top_bearing = 0;
this.vadvance = 0;
this.pp3 = new FT_Vector();
this.pp4 = new FT_Vector();
this.cursor = 0;
this.limit = 0;
this.Clear = function()
{
this.load_flags = 0;
this.glyph_index = 0;
this.stream = null;
this.byte_len = 0;
this.n_contours = 0;
this.bbox.xMin = 0;
this.bbox.yMin = 0;
this.bbox.xMax = 0;
this.bbox.yMax = 0;
this.left_bearing = 0;
this.advance = 0;
this.linear = 0;
this.linear_def = 0;
this.preserve_pps = 0;
this.pp1.x = 0;
this.pp1.y = 0;
this.pp2.x = 0;
this.pp2.y = 0;
this.glyf_offset = 0;
this.exec = null;
this.instructions = null;
this.ins_pos = 0;
this.other = null;
this.top_bearing = 0;
this.vadvance = 0;
this.pp3.x = 0;
this.pp3.y = 0;
this.pp4.x = 0;
this.pp4.y = 0;
this.cursor = 0;
this.limit = 0;
this.gloader = null;
}
}
/******************************************************************************/
// tttables
/******************************************************************************/
function TT_Header()
{
this.Table_Version = 0;
this.Font_Revision = 0;
this.CheckSum_Adjust = 0;
this.Magic_Number = 0;
this.Flags = 0;
this.Units_Per_EM = 0;
this.Created1 = 0;
this.Created2 = 0;
this.Modified1 = 0;
this.Modified2 = 0;
this.xMin = 0;
this.yMin = 0;
this.xMax = 0;
this.yMax = 0;
this.Mac_Style = 0;
this.Lowest_Rec_PPEM = 0;
this.Font_Direction = 0;
this.Index_To_Loc_Format = 0;
this.Glyph_Data_Format = 0;
}
function TT_HoriHeader()
{
this.Version = 0;
this.Ascender = 0;
this.Descender = 0;
this.Line_Gap = 0;
this.advance_Width_Max = 0;
this.min_Left_Side_Bearing = 0;
this.min_Right_Side_Bearing = 0;
this.xMax_Extent = 0;
this.caret_Slope_Rise = 0;
this.caret_Slope_Run = 0;
this.caret_Offset = 0;
this.Reserved1 = 0;
this.Reserved2 = 0;
this.Reserved3 = 0;
this.Reserved4 = 0;
this.metric_Data_Format = 0;
this.number_Of_HMetrics = 0;
this.long_metrics = null;
this.short_metrics = null;
}
function TT_VertHeader()
{
this.Version = 0;
this.Ascender = 0;
this.Descender = 0;
this.Line_Gap = 0;
this.advance_Height_Max = 0;
this.min_Top_Side_Bearing = 0;
this.min_Bottom_Side_Bearing = 0;
this.yMax_Extent = 0;
this.caret_Slope_Rise = 0;
this.caret_Slope_Run = 0;
this.caret_Offset = 0;
this.Reserved1 = 0;
this.Reserved2 = 0;
this.Reserved3 = 0;
this.Reserved4 = 0;
this.metric_Data_Format = 0;
this.number_Of_VMetrics = 0;
this.long_metrics = null;
this.short_metrics = null;
}
function TT_OS2()
{
this.version = 0;
this.xAvgCharWidth = 0;
this.usWeightClass = 0;
this.usWidthClass = 0;
this.fsType = 0;
this.ySubscriptXSize = 0;
this.ySubscriptYSize = 0;
this.ySubscriptXOffset = 0;
this.ySubscriptYOffset = 0;
this.ySuperscriptXSize = 0;
this.ySuperscriptYSize = 0;
this.ySuperscriptXOffset = 0;
this.ySuperscriptYOffset = 0;
this.yStrikeoutSize = 0;
this.yStrikeoutPosition = 0;
this.sFamilyClass = 0;
this.panose = new Array(10);
this.ulUnicodeRange1 = 0; /* Bits 0-31 */
this.ulUnicodeRange2 = 0; /* Bits 32-63 */
this.ulUnicodeRange3 = 0; /* Bits 64-95 */
this.ulUnicodeRange4 = 0; /* Bits 96-127 */
this.achVendID = new Array(4);
this.fsSelection = 0;
this.usFirstCharIndex = 0;
this.usLastCharIndex = 0;
this.sTypoAscender = 0;
this.sTypoDescender = 0;
this.sTypoLineGap = 0;
this.usWinAscent = 0;
this.usWinDescent = 0;
/* only version 1 tables: */
this.ulCodePageRange1 = 0; /* Bits 0-31 */
this.ulCodePageRange2 = 0; /* Bits 32-63 */
/* only version 2 tables: */
this.sxHeight = 0;
this.sCapHeight = 0;
this.usDefaultChar = 0;
this.usBreakChar = 0;
this.usMaxContext = 0;
}
function TT_Postscript()
{
this.FormatType = 0;
this.italicAngle = 0;
this.underlinePosition = 0;
this.underlineThickness = 0;
this.isFixedPitch = 0;
this.minMemType42 = 0;
this.maxMemType42 = 0;
this.minMemType1 = 0;
this.maxMemType1 = 0;
}
function TT_PCLT()
{
this.Version = 0;
this.FontNumber = 0;
this.Pitch = 0;
this.xHeight = 0;
this.Style = 0;
this.TypeFamily = 0;
this.CapHeight = 0;
this.SymbolSet = 0;
this.TypeFace = "";
this.CharacterComplement = "";
this.FileName = "";
this.StrokeWeight = 0;
this.WidthType = 0;
this.SerifStyle = 0;
this.Reserved = 0;
}
function TT_MaxProfile()
{
this.version = 0;
this.numGlyphs = 0;
this.maxPoints = 0;
this.maxContours = 0;
this.maxCompositePoints = 0;
this.maxCompositeContours = 0;
this.maxZones = 0;
this.maxTwilightPoints = 0;
this.maxStorage = 0;
this.maxFunctionDefs = 0;
this.maxInstructionDefs = 0;
this.maxStackElements = 0;
this.maxSizeOfInstructions = 0;
this.maxComponentElements = 0;
this.maxComponentDepth = 0;
}
function FT_Get_Sfnt_Table(face, tag)
{
var table = null;
if (face && ((face.face_flags & FT_Common.FT_FACE_FLAG_SFNT) != 0))
{
var service = FT_FACE_FIND_SERVICE( face, "sfnt-table");
if (service != null)
table = service.get_table(face, tag);
}
return table;
}
function FT_Load_Sfnt_Table(face, tag, offset, buffer, length)
{
if (face == null || ((face.face_flags & FT_Common.FT_FACE_FLAG_SFNT) == 0))
return FT_Common.FT_Err_Invalid_Face_Handle;
var service = FT_FACE_FIND_SERVICE(face, FT_SERVICE_ID_SFNT_TABLE);
if (service == null)
return FT_Common.FT_Err_Unimplemented_Feature;
return service.load_table(face, tag, offset, buffer, length);
}
function FT_Sfnt_Table_Info(face, table_index, tag, length)
{
if (face == null || ((face.face_flags & FT_Common.FT_FACE_FLAG_SFNT) == 0))
return FT_Common.FT_Err_Invalid_Face_Handle;
var service = FT_FACE_FIND_SERVICE(face, FT_SERVICE_ID_SFNT_TABLE);
if (service == null)
return FT_Common.FT_Err_Unimplemented_Feature;
return service.table_info(face, table_index, tag);
}
function FT_Get_CMap_Language_ID(charmap)
{
if (charmap == null || charmap.face == null)
return 0;
var service = FT_FACE_FIND_SERVICE(charmap.face, FT_SERVICE_ID_TT_CMAP);
if (service == null)
return 0;
var cmap_info = new TT_CMapInfo();
if (0 != service.get_cmap_info( charmap, cmap_info))
return 0;
return cmap_info.language;
}
/******************************************************************************/
// ftimage
/******************************************************************************/
function FT_Vector()
{
this.x = 0;
this.y = 0;
}
function dublicate_vector(v)
{
var _v = new FT_Vector();
_v.x = v.x;
_v.y = v.y;
return _v;
}
function FT_BBox()
{
this.xMin = 0;
this.yMin = 0;
this.xMax = 0;
this.yMax = 0;
}
function dublicate_bbox(v)
{
var _v = new FT_BBox();
_v.xMin = v.xMin;
_v.yMin = v.yMin;
_v.xMax = v.xMax;
_v.yMax = v.yMax;
return _v;
}
function FT_Bitmap()
{
this.rows = 0;
this.width = 0;
this.pitch = 0;
this.buffer = null;
this.num_grays = 0;
this.pixel_mode = 0;
this.palette_mode = 0;
this.palette = null;
}
function DoNullBitmap(im)
{
im.rows = 0;
im.width = 0;
im.pitch = 0;
im.buffer = null;
im.num_grays = 0;
im.pixel_mode = 0;
im.palette_mode = 0;
im.palette = null;
}
function FT_Outline()
{
this.n_contours = 0;
this.n_points = 0;
this.points = null;
this.tags = null;
this.contours = null;
this.flags = 0;
}
function EquatingOutline(d, s)
{
d.n_contours = s.n_contours;
d.n_points = s.n_points;
d.points = s.points;
d.tags = s.tags;
d.contours = s.contours;
d.flags = s.flags;
}
function FT_Span()
{
this.x = 0;
this.len = 0;
this.coverage = 0;
}
function FT_Raster_Params()
{
this.target = null;
this.source = null;
this.flags = 0;
this.gray_spans = null;
this.black_spans = null;
this.bit_test = null;
this.bit_set = null;
this.user = null;
this.clip_box = new FT_BBox();
}
/******************************************************************************/
// ftbitmap
/******************************************************************************/
function FT_Bitmap_New(bitmap)
{
DoNullBitmap(bitmap);
}
function FT_Bitmap_Copy(library, source, target)
{
var pitch = source.pitch;
if (source == target)
return 0;
if (source.buffer == null)
{
target.rows = source.rows;
target.width = source.width;
target.pitch = source.pitch;
target.buffer = source.buffer;
target.num_grays = source.num_grays;
target.pixel_mode = source.pixel_mode;
target.palette_mode = source.palette_mode;
target.palette = source.palette;
return 0;
}
if (pitch < 0)
pitch = -pitch;
var size = (pitch * source.rows);
if (target.buffer != null)
{
var target_pitch = target.pitch;
if (target_pitch < 0 )
target_pitch = -target_pitch;
var target_size = (target_pitch * target.rows);
if (target_size != size)
{
target.buffer = null;
target.buffer = g_memory.Alloc(size);//new Array(size);
}
}
else
target.buffer = g_memory.Alloc(size);//new Array(size);
var s = source.buffer;
var d = target.buffer;
for (var i=0;i<size;i++)
d[i]=s[i];
return 0;
}
function FT_Bitmap_Done(library, bitmap)
{
DoNullBitmap(bitmap);
return 0;
}
/******************************************************************************/
// ftsnames
/******************************************************************************/
function FT_SfntName()
{
this.platform_id = 0;
this.encoding_id = 0;
this.language_id = 0;
this.name_id = 0;
this.string = "";
this.string_len = 0;
}
function FT_Get_Sfnt_Name_Count(face)
{
return (face != null && (face.face_flags & FT_Common.FT_FACE_FLAG_SFNT) != 0) ? face.num_names : 0;
}
function FT_Get_Sfnt_Name(face, idx, aname)
{
var error = FT_Common.FT_Err_Invalid_Argument;
if (face != null && (face.face_flags & FT_Common.FT_FACE_FLAG_SFNT) != 0)
{
if (idx < face.num_names)
{
var entry = face.name_table.names[idx];
if (entry.stringLength > 0 && entry.string == null)
{
var stream = face.stream;
error = stream.Seek(entry.stringOffset);
entry.string = stream.ReadString1(entry.stringLength);
error = FT_Error;
if (0 != error)
{
entry.string = null;
entry.stringLength = 0;
}
}
aname.platform_id = entry.platformID;
aname.encoding_id = entry.encodingID;
aname.language_id = entry.languageID;
aname.name_id = entry.nameID;
aname.string = entry.string;
aname.string_len = entry.stringLength;
}
}
return 0;
}
/******************************************************************************/
// ftincrem
/******************************************************************************/
function FT_Incremental_MetricsRec()
{
this.bearing_x = 0;
this.bearing_y = 0;
this.advance = 0;
this.advance_v = 0;
}
function FT_Incremental_FuncsRec()
{
this.get_glyph_data = null;
this.free_glyph_data = null;
this.get_glyph_metrics = null;
}
function FT_Incremental_Interface()
{
this.funcs = null;
this.object = null;
}
/******************************************************************************/
// fttypes
/******************************************************************************/
function FT_Matrix()
{
this.xx = 0;
this.xy = 0;
this.yx = 0;
this.yy = 0;
}
function dublicate_matrix(m)
{
var _m = new FT_Matrix();
_m.xx = m.xx;
_m.xy = m.xy;
_m.yx = m.yx;
_m.yy = m.yy;
return _m;
}
function FT_Data()
{
this.pointer = null;
this.length = 0;
}
function FT_Generic()
{
this.data = null;
this.finalizer = null;
}
function FT_Glyph_Metrics()
{
this.width = 0;
this.height = 0;
this.horiBearingX = 0;
this.horiBearingY = 0;
this.horiAdvance = 0;
this.vertBearingX = 0;
this.vertBearingY = 0;
this.vertAdvance = 0;
}
function FT_Bitmap_Size()
{
this.height = 0;
this.width = 0;
this.size = 0;
this.x_ppem = 0;
this.y_ppem = 0;
}
function FT_CharMapRec()
{
this.face = null;
this.encoding = 0;
this.platform_id = 0;
this.encoding_id = 0;
}
function FT_Face()
{
this.num_faces = 0;
this.face_index = 0;
this.face_flags = 0;
this.style_flags = 0;
this.num_glyphs = 0;
this.family_name = "";
this.style_name = "";
this.num_fixed_sizes = 0;
this.available_sizes = [];
this.num_charmaps = 0;
this.charmaps = [];
this.generic = new FT_Generic();
/*# The following member variables (down to `underline_thickness') */
/*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */
/*# for bitmap fonts. */
this.bbox = new FT_BBox();
this.units_per_EM = 0;
this.ascender = 0;
this.descender = 0;
this.height = 0;
this.max_advance_width = 0;
this.max_advance_height = 0;
this.underline_position = 0;
this.underline_thickness = 0;
this.glyph = null;
this.size = null;
this.charmap = null;
/*@private begin */
this.driver = null;
this.memory = null;
this.stream = null;
this.sizes_list = [];
this.autohint = [];
this.extensions = null;
this.internal = null;
/*@private end */
}
function FT_Size_Metrics()
{
this.x_ppem = 0;
this.y_ppem = 0;
this.x_scale = 0;
this.y_scale = 0;
this.ascender = 0;
this.descender = 0;
this.height = 0;
this.max_advance = 0;
}
FT_Size_Metrics.prototype =
{
Copy : function(src)
{
this.x_ppem = src.x_ppem;
this.y_ppem = src.y_ppem;
this.x_scale = src.x_scale;
this.y_scale = src.y_scale;
this.ascender = src.ascender;
this.descender = src.descender;
this.height = src.height;
this.max_advance = src.max_advance;
}
};
function FT_Size()
{
this.face = null;
this.generic = null;
this.metrics = new FT_Size_Metrics();
this.internal = null;
}
function FT_GlyphSlot()
{
this.library = null;
this.face = null;
this.next = null;
this.reserved = 0; /* retained for binary compatibility */
this.generic = null;
this.metrics = new FT_Glyph_Metrics();
this.linearHoriAdvance = 0;
this.linearVertAdvance = 0;
this.advance = new FT_Vector();
this.format = 0;
this.bitmap = new FT_Bitmap();
this.bitmap_left = 0;
this.bitmap_top = 0;
this.outline = new FT_Outline();
this.num_subglyphs = 0;
this.subglyphs = [];
this.control_data = null;
this.control_len = 0;
this.lsb_delta = 0;
this.rsb_delta = 0;
this.other = null;
this.internal = null;
this.base_root = null;
}
function FT_Open_Args()
{
this.flags = null;
this.memory_base = null;
this.memory_size = null;
this.pathname = "";
this.stream = null;
this.driver = null;
this.num_params = 0;
this.params = null;
}
function FT_Size_RequestRec()
{
this.type = 0;
this.width = 0;
this.height = 0;
this.horiResolution = 0;
this.vertResolution = 0;
}
function FT_CMapRec()
{
this.charmap = new FT_CharMapRec();
this.clazz = null;
this.type = FT_Common.FT_CMAP_0;
}
function __FT_CMapRec(val)
{
switch (val.type)
{
case FT_Common.FT_CMAP_0:
return val;
case FT_Common.FT_CMAP_1:
return val.cmap;
case FT_Common.FT_CMAP_4:
case FT_Common.FT_CMAP_12:
case FT_Common.FT_CMAP_13:
case FT_Common.FT_CMAP_14:
return val.cmap.cmap;
default:
break;
}
return val;
}
function __FT_TTCMapRec(val)
{
switch (val.type)
{
case FT_Common.FT_CMAP_0:
return null;
case FT_Common.FT_CMAP_1:
return val;
case FT_Common.FT_CMAP_4:
case FT_Common.FT_CMAP_12:
case FT_Common.FT_CMAP_13:
case FT_Common.FT_CMAP_14:
return val.cmap;
default:
break;
}
return null;
}
function __FT_CharmapRec(val)
{
switch (val.type)
{
case FT_Common.FT_CMAP_0:
return val.charmap;
case FT_Common.FT_CMAP_1:
return val.cmap.charmap;
case FT_Common.FT_CMAP_4:
case FT_Common.FT_CMAP_12:
case FT_Common.FT_CMAP_13:
case FT_Common.FT_CMAP_14:
return val.cmap.cmap.charmap;
default:
break;
}
return val.charmap;
}
function FT_CMap_ClassRec()
{
this.size = 0;
this.init = null;
this.done = null;
this.char_index = null;
this.char_next = null;
this.char_var_index = null;
this.char_var_default = null;
this.variant_list = null;
this.charvariant_list = null;
this.variantchar_list = null;
}
function create_cmap_class_rec(size_,init_,done_,char_index_,char_next_,var_index_,var_default_,
var_list_,char_var_list_, var_char_list_)
{
var c = new FT_CMap_ClassRec();
c.size = size_;
c.init = init_;
c.done = done_;
c.char_index = char_index_;
c.char_next = char_next_;
c.char_var_index = var_index_;
c.char_var_default = var_default_;
c.variant_list = var_list_;
c.charvariant_list = char_var_list_;
c.variantchar_list = var_char_list_;
return c;
}
function FT_Face_Internal()
{
//#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
this.reserved1 = 0;
this.reserved2 = 0;
//#endif
this.transform_matrix = new FT_Matrix();
this.transform_delta = new FT_Vector();
this.transform_flags = 0;
this.services = new FT_ServiceCache();
//#ifdef FT_CONFIG_OPTION_INCREMENTAL
this.incremental_interface = null;
//#endif
this.ignore_unpatented_hinter = false;
this.refcount = 0;
}
function FT_Slot_Internal()
{
this.loader = null;
this.flags = 0;
this.glyph_transformed = false;
this.glyph_matrix = new FT_Matrix();
this.glyph_delta = new FT_Vector();
this.glyph_hints = null;
}
function FT_Module()
{
this.clazz = null; // FT_Module_Class
this.library = null; // FT_Library
this.memory = null; // FT_Memory
this.generic = null; // FT_Generic
}
function FT_Driver()
{
this.root = new FT_Module();
this.clazz = new FT_Driver_Class();
this.faces_list = [];
this.extensions = null;
this.glyph_loader = null;
}
function FT_Module_Class()
{
this.flags = 0;
this.name = "";
this.version = 0;
this.requires = 0;
this.module_interface = null;
this.init = null;
this.done = null;
this.get_interface = null;
}
/******************************************************************************/
// outline
/******************************************************************************/
function FT_Outline_New(library, numPoints, numContours, anoutline)
{
if (library == null)
return FT_Common.FT_Err_Invalid_Library_Handle;
return FT_Outline_New_Internal(library.Memory, numPoints, numContours, anoutline);
}
function FT_Outline_New_Internal(memory, numPoints, numContours, anoutline)
{
if (null == anoutline || null == memory)
return FT_Common.FT_Err_Invalid_Argument;
var _points = new Array(numPoints);
for (var i = 0; i < numPoints; i++)
_points[i] = new FT_Vector();
var _tags = new Array(numPoints);
for (var i = 0; i < numPoints; i++)
_tags[i] = 0;
var _contours = new Array(numContours);
for (var i = 0; i < numContours; i++)
_contours[i] = 0;
anoutline.points = _points;
anoutline.tags = _tags;
anoutline.contours = _contours;
anoutline.n_points = numPoints & 0xFFFF;
anoutline.n_contours = numContours & 0xFFFF;
anoutline.flags |= FT_Common.FT_OUTLINE_OWNER;
return 0;
}
function FT_Outline_Check(outline)
{
if (outline != null)
{
var n_points = outline.n_points;
var n_contours = outline.n_contours;
var end0, end;
var n;
if (n_points == 0 && n_contours == 0)
return 0;
if (n_points <= 0 || n_contours <= 0)
return FT_Common.FT_Err_Invalid_Argument;
end0 = end = -1;
var _c = outline.contours;
for (n = 0; n < n_contours; n++)
{
end = _c[n];
if (end <= end0 || end >= n_points)
return FT_Common.FT_Err_Invalid_Argument;
end0 = end;
}
if ( end != n_points - 1 )
return FT_Common.FT_Err_Invalid_Argument;
return 0;
}
return FT_Common.FT_Err_Invalid_Argument;
}
function FT_Outline_Copy(source, target)
{
if (null == source || null == target || source.n_points != target.n_points || source.n_contours != target.n_contours)
return FT_Common.FT_Err_Invalid_Argument;
if (source == target)
return 0;
var n_p = source.n_points;
var s_p = source.points;
var d_p = target.points;
var s_t = source.tags;
var t_t = target.tags;
for (var i = 0; i < n_p; i++)
{
d_p[i].x = s_p[i].x;
d_p[i].y = s_p[i].y;
t_t[i] = s_t[i];
}
var n_c = source.n_contours;
var s_c = source.contours;
var t_c = target.contours;
for (var i = 0; i < source.n_contours; i++)
{
t_c[i] = s_c[i];
}
var is_owner = target.flags & FT_Common.FT_OUTLINE_OWNER;
target.flags = source.flags;
target.flags &= ~FT_Common.FT_OUTLINE_OWNER;
target.flags |= is_owner;
return 0;
}
function FT_Outline_Done_Internal(memory, outline)
{
if (memory != null && outline != null)
{
if (outline.flags & FT_Common.FT_OUTLINE_OWNER)
{
outline.points = null;
outline.tags = null;
outline.contours = null;
}
outline.n_points = 0;
outline.n_contours = 0;
outline.flags = 0;
return 0;
}
else
return FT_Common.FT_Err_Invalid_Argument;
}
function FT_Outline_Done(library, outline)
{
if (library == null)
return FT_Common.FT_Err_Invalid_Library_Handle;
return FT_Outline_Done_Internal(library.memory, outline);
}
/******************************************************************************/
// obj
/******************************************************************************/
function find_unicode_charmap(face)
{
if (null == face || null == face.charmaps)
return FT_Common.FT_Err_Invalid_CharMap_Handle;
var count = Math.min(face.charmaps.length, face.num_charmaps);
if (0 == count)
return FT_Common.FT_Err_Invalid_CharMap_Handle;
var cur = count - 1;
for ( ; cur >= 0; cur--)
{
var cmap = __FT_CharmapRec(face.charmaps[cur]);
if (cmap.encoding == FT_Common.FT_ENCODING_UNICODE)
{
if ((cmap.platform_id == FT_Common.TT_PLATFORM_MICROSOFT && cmap.encoding_id == FT_Common.TT_MS_ID_UCS_4) ||
(cmap.platform_id == FT_Common.TT_PLATFORM_APPLE_UNICODE && cmap.encoding_id == FT_Common.TT_APPLE_ID_UNICODE_32))
{
//#ifdef FT_MAX_CHARMAP_CACHEABLE
if (cur > FT_Common.FT_MAX_CHARMAP_CACHEABLE)
{
continue;
}
//#endif
face.charmap = face.charmaps[cur];
return FT_Common.FT_Err_Ok;
}
}
}
cur = count - 1;
for ( ; cur >= 0; cur--)
{
var cmap = __FT_CharmapRec(face.charmaps[cur]);
if (cmap.encoding == FT_Common.FT_ENCODING_UNICODE)
{
//#ifdef FT_MAX_CHARMAP_CACHEABLE
if (cur > FT_Common.FT_MAX_CHARMAP_CACHEABLE)
{
continue;
}
//#endif
face.charmap = face.charmaps[cur];
return FT_Common.FT_Err_Ok;
}
}
return FT_Common.FT_Err_Invalid_CharMap_Handle;
}
function ft_glyphslot_init(slot)
{
var driver = slot.face.driver;
slot.library = driver.library;
slot.internal = new FT_Slot_Internal();
var error = 0;
if ((driver.flags & FT_Common.FT_MODULE_DRIVER_NO_OUTLINES) == 0)
slot.internal.loader = FT_GlyphLoader_New(driver.memory);
if (driver.clazz.init_slot)
error = driver.clazz.init_slot(slot);
return error;
}
function ft_glyphslot_free_bitmap(slot)
{
if (slot.internal != null && (slot.internal.flags & FT_Common.FT_GLYPH_OWN_BITMAP) != 0)
{
slot.bitmap.buffer = null;
slot.internal.flags &= ~FT_Common.FT_GLYPH_OWN_BITMAP;
}
else
{
slot.bitmap.buffer = null;
}
}
function ft_glyphslot_set_bitmap(slot, buffer)
{
ft_glyphslot_free_bitmap(slot);
slot.bitmap.buffer = buffer;
}
function ft_glyphslot_alloc_bitmap(slot, size)
{
if ((slot.internal.flags & FT_Common.FT_GLYPH_OWN_BITMAP) != 0)
slot.bitmap.buffer = null;
else
slot.internal.flags |= FT_Common.FT_GLYPH_OWN_BITMAP;
slot.bitmap.buffer = g_memory.Alloc(size);
return 0;
}
function ft_glyphslot_clear(slot)
{
ft_glyphslot_free_bitmap(slot);
var metrics = slot.metrics;
metrics.width = 0;
metrics.height = 0;
metrics.horiBearingX = 0;
metrics.horiBearingY = 0;
metrics.horiAdvance = 0;
metrics.vertBearingX = 0;
metrics.vertBearingY = 0;
metrics.vertAdvance = 0;
var outl = slot.outline;
outl.n_contours = 0;
outl.n_points = 0;
outl.contours = null;
outl.points = null;
outl.tags = null;
outl.flags = 0;
slot.bitmap.width = 0;
slot.bitmap.rows = 0;
slot.bitmap.pitch = 0;
slot.bitmap.pixel_mode = 0;
slot.bitmap_left = 0;
slot.bitmap_top = 0;
slot.num_subglyphs = 0;
slot.subglyphs = 0;
slot.control_data = 0;
slot.control_len = 0;
slot.other = 0;
slot.format = FT_Common.FT_GLYPH_FORMAT_NONE;
slot.linearHoriAdvance = 0;
slot.linearVertAdvance = 0;
slot.lsb_delta = 0;
slot.rsb_delta = 0;
}
function ft_glyphslot_done(slot)
{
var clazz = slot.face.driver.clazz;
if (clazz.done_slot != null)
clazz.done_slot(slot);
ft_glyphslot_free_bitmap(slot);
slot.internal = null;
}
function ft_glyphslot_grid_fit_metrics(slot, vertical)
{
var metrics = slot.metrics;
var right, bottom;
if (1 == vertical)
{
metrics.horiBearingX = FT_PIX_FLOOR(metrics.horiBearingX);
metrics.horiBearingY = FT_PIX_CEIL (metrics.horiBearingY);
right = FT_PIX_CEIL(metrics.vertBearingX + metrics.width);
bottom = FT_PIX_CEIL(metrics.vertBearingY + metrics.height);
metrics.vertBearingX = FT_PIX_FLOOR(metrics.vertBearingX);
metrics.vertBearingY = FT_PIX_FLOOR(metrics.vertBearingY);
metrics.width = right - metrics.vertBearingX;
metrics.height = bottom - metrics.vertBearingY;
}
else
{
metrics.vertBearingX = FT_PIX_FLOOR(metrics.vertBearingX);
metrics.vertBearingY = FT_PIX_FLOOR(metrics.vertBearingY);
right = FT_PIX_CEIL (metrics.horiBearingX + metrics.width);
bottom = FT_PIX_FLOOR(metrics.horiBearingY - metrics.height);
metrics.horiBearingX = FT_PIX_FLOOR(metrics.horiBearingX);
metrics.horiBearingY = FT_PIX_CEIL (metrics.horiBearingY);
metrics.width = right - metrics.horiBearingX;
metrics.height = metrics.horiBearingY - bottom;
}
metrics.horiAdvance = FT_PIX_ROUND(metrics.horiAdvance);
metrics.vertAdvance = FT_PIX_ROUND(metrics.vertAdvance);
}
function ft_synthesize_vertical_metrics(metrics, advance)
{
var height = metrics.height;
/* compensate for glyph with bbox above/below the baseline */
if (metrics.horiBearingY < 0)
{
if (height < metrics.horiBearingY)
height = metrics.horiBearingY;
}
else if (metrics.horiBearingY > 0)
height -= metrics.horiBearingY;
/* the factor 1.2 is a heuristical value */
if (advance == 0)
advance = parseInt(height * 12 / 10);
metrics.vertBearingX = parseInt(metrics.horiBearingX - metrics.horiAdvance / 2);
metrics.vertBearingY = parseInt((advance - height) / 2);
metrics.vertAdvance = advance;
}
\ No newline at end of file
function FT_MAKE_TAG(a,b,c,d)
{
var r = a.charCodeAt(0) << 24 | b.charCodeAt(0) << 16 | c.charCodeAt(0) << 8 | d.charCodeAt(0);
if (r < 0)
r+=FT_Common.a_i;
return r;
}
function _FT_Common()
{
// GENERATOR_START_CONSTANTS
this.FT_ENCODING_NONE = 0;
this.FT_ENCODING_MS_SYMBOL = FT_MAKE_TAG("s","y","m","b");
this.FT_ENCODING_UNICODE = FT_MAKE_TAG("u","n","i","c");
this.FT_ENCODING_SJIS = FT_MAKE_TAG("s","j","i","s");
this.FT_ENCODING_GB2312 = FT_MAKE_TAG("g","b"," "," ");
this.FT_ENCODING_BIG5 = FT_MAKE_TAG("b","i","g","5");
this.FT_ENCODING_WANSUNG = FT_MAKE_TAG("w","a","n","s");
this.FT_ENCODING_JOHAB = FT_MAKE_TAG("j","o","h","a");
/* for backwards compatibility */
this.FT_ENCODING_MS_SJIS = this.FT_ENCODING_SJIS;
this.FT_ENCODING_MS_GB2312 = this.FT_ENCODING_GB2312;
this.FT_ENCODING_MS_BIG5 = this.FT_ENCODING_BIG5;
this.FT_ENCODING_MS_WANSUNG = this.FT_ENCODING_WANSUNG;
this.FT_ENCODING_MS_JOHAB = this.FT_ENCODING_JOHAB;
this.FT_ENCODING_ADOBE_STANDARD = FT_MAKE_TAG("A","D","O","B");
this.FT_ENCODING_ADOBE_EXPERT = FT_MAKE_TAG("A","D","B","E");
this.FT_ENCODING_ADOBE_CUSTOM = FT_MAKE_TAG("A","D","B","C");
this.FT_ENCODING_ADOBE_LATIN_1 = FT_MAKE_TAG("l","a","t","1");
this.FT_ENCODING_OLD_LATIN_2 = FT_MAKE_TAG("l","a","t","2");
this.FT_ENCODING_APPLE_ROMAN = FT_MAKE_TAG("a","r","m","n");
// modules types
this.FT_MODULE_FONT_DRIVER = 1;
this.FT_MODULE_RENDERER = 2;
this.FT_MODULE_HINTER = 4;
this.FT_MODULE_STYLER = 8;
this.FT_MODULE_DRIVER_SCALABLE = 0x100;
this.FT_MODULE_DRIVER_NO_OUTLINES = 0x200;
this.FT_MODULE_DRIVER_HAS_HINTER = 0x400;
// errors codes
this.FT_Err_Ok = 0x00;
this.FT_Err_Cannot_Open_Resource = 0x01;
this.FT_Err_Unknown_File_Format = 0x02;
this.FT_Err_Invalid_File_Format = 0x03;
this.FT_Err_Invalid_Version = 0x04;
this.FT_Err_Lower_Module_Version = 0x05;
this.FT_Err_Invalid_Argument = 0x06;
this.FT_Err_Unimplemented_Feature = 0x07;
this.FT_Err_Invalid_Table = 0x08;
this.FT_Err_Invalid_Offset = 0x09;
this.FT_Err_Array_Too_Large = 0x0A;
/* glyph/character errors */
this.FT_Err_Invalid_Glyph_Index = 0x10;
this.FT_Err_Invalid_Character_Code = 0x11;
this.FT_Err_Invalid_Glyph_Format = 0x12;
this.FT_Err_Cannot_Render_Glyph = 0x13;
this.FT_Err_Invalid_Outline = 0x14;
this.FT_Err_Invalid_Composite = 0x15;
this.FT_Err_Too_Many_Hints = 0x16;
this.FT_Err_Invalid_Pixel_Size = 0x17;
/* handle errors */
this.FT_Err_Invalid_Handle = 0x20;
this.FT_Err_Invalid_Library_Handle = 0x21;
this.FT_Err_Invalid_Driver_Handle = 0x22;
this.FT_Err_Invalid_Face_Handle = 0x23;
this.FT_Err_Invalid_Size_Handle = 0x24;
this.FT_Err_Invalid_Slot_Handle = 0x25;
this.FT_Err_Invalid_CharMap_Handle = 0x26;
this.FT_Err_Invalid_Cache_Handle = 0x27;
this.FT_Err_Invalid_Stream_Handle = 0x28;
/* driver errors */
this.FT_Err_Too_Many_Drivers = 0x30;
this.FT_Err_Too_Many_Extensions = 0x31;
/* memory errors */
this.FT_Err_Out_Of_Memory = 0x40;
this.FT_Err_Unlisted_Object = 0x41;
/* stream errors */
this.FT_Err_Cannot_Open_Stream = 0x51;
this.FT_Err_Invalid_Stream_Seek = 0x52;
this.FT_Err_Invalid_Stream_Skip = 0x53;
this.FT_Err_Invalid_Stream_Read = 0x54;
this.FT_Err_Invalid_Stream_Operation = 0x55;
this.FT_Err_Invalid_Frame_Operation = 0x56;
this.FT_Err_Nested_Frame_Access = 0x57;
this.FT_Err_Invalid_Frame_Read = 0x58;
/* raster errors */
this.FT_Err_Raster_Uninitialized = 0x60;
this.FT_Err_Raster_Corrupted = 0x61;
this.FT_Err_Raster_Overflow = 0x62;
this.FT_Err_Raster_Negative_Height = 0x63;
/* cache errors */
this.FT_Err_Too_Many_Caches = 0x70;
/* TrueType and SFNT errors */
this.FT_Err_Invalid_Opcode = 0x80;
this.FT_Err_Too_Few_Arguments = 0x81;
this.FT_Err_Stack_Overflow = 0x82;
this.FT_Err_Code_Overflow = 0x83;
this.FT_Err_Bad_Argument = 0x84;
this.FT_Err_Divide_By_Zero = 0x85;
this.FT_Err_Invalid_Reference = 0x86;
this.FT_Err_Debug_OpCode = 0x87;
this.FT_Err_ENDF_In_Exec_Stream = 0x88;
this.FT_Err_Nested_DEFS = 0x89;
this.FT_Err_Invalid_CodeRange = 0x8A;
this.FT_Err_Execution_Too_Long = 0x8B;
this.FT_Err_Too_Many_Function_Defs = 0x8C;
this.FT_Err_Too_Many_Instruction_Defs = 0x8D;
this.FT_Err_Table_Missing = 0x8E;
this.FT_Err_Horiz_Header_Missing = 0x8F;
this.FT_Err_Locations_Missing = 0x90;
this.FT_Err_Name_Table_Missing = 0x91;
this.FT_Err_CMap_Table_Missing = 0x92;
this.FT_Err_Hmtx_Table_Missing = 0x93;
this.FT_Err_Post_Table_Missing = 0x94;
this.FT_Err_Invalid_Horiz_Metrics = 0x95;
this.FT_Err_Invalid_CharMap_Format = 0x96;
this.FT_Err_Invalid_PPem = 0x97;
this.FT_Err_Invalid_Vert_Metrics = 0x98;
this.FT_Err_Could_Not_Find_Context = 0x99;
this.FT_Err_Invalid_Post_Table_Format = 0x9A;
this.FT_Err_Invalid_Post_Table = 0x9B;
/* CFF, CID, and Type 1 errors */
this.FT_Err_Syntax_Error = 0xA0;
this.FT_Err_Stack_Underflow = 0xA1;
this.FT_Err_Ignore = 0xA2;
this.FT_Err_No_Unicode_Glyph_Name = 0xA3;
/* BDF errors */
this.FT_Err_Missing_Startfont_Field = 0xB0;
this.FT_Err_Missing_Font_Field = 0xB1;
this.FT_Err_Missing_Size_Field = 0xB2;
this.FT_Err_Missing_Fontboundingbox_Field = 0xB3;
this.FT_Err_Missing_Chars_Field = 0xB4;
this.FT_Err_Missing_Startchar_Field = 0xB5;
this.FT_Err_Missing_Encoding_Field = 0xB6;
this.FT_Err_Missing_Bbx_Field = 0xB7;
this.FT_Err_Bbx_Too_Big = 0xB8;
this.FT_Err_Corrupted_Font_Header = 0xB9;
this.FT_Err_Corrupted_Font_Glyphs = 0xBA;
this.FT_Mod_Err = 0x100;
//
this.BDF_PROPERTY_TYPE_NONE = 0;
this.BDF_PROPERTY_TYPE_ATOM = 1;
this.BDF_PROPERTY_TYPE_INTEGER = 2;
this.BDF_PROPERTY_TYPE_CARDINAL = 3;
//
this.TT_CMAP_FLAG_UNSORTED = 1;
this.TT_CMAP_FLAG_OVERLAPPING = 2;
this.m_c = 0x7F;
this.m_s = 0x7FFF;
this.m_i = 0x7FFFFFFF;
this.a_c = 0xFF + 1;
this.a_s = 0xFFFF + 1;
this.a_i = 0xFFFFFFFF + 1;
// base
this.FT_MAX_CHARMAP_CACHEABLE = 15;
this.TT_PLATFORM_APPLE_UNICODE = 0;
this.TT_PLATFORM_MACINTOSH = 1;
this.TT_PLATFORM_ISO = 2;
this.TT_PLATFORM_MICROSOFT = 3;
this.TT_PLATFORM_CUSTOM = 4;
this.TT_PLATFORM_ADOBE = 7;
//
this.TT_MAC_ID_ROMAN = 0;
//
this.TT_MS_ID_SYMBOL_CS = 0;
this.TT_MS_ID_UNICODE_CS = 1;
this.TT_MS_ID_SJIS = 2;
this.TT_MS_ID_GB2312 = 3;
this.TT_MS_ID_BIG_5 = 4;
this.TT_MS_ID_WANSUNG = 5;
this.TT_MS_ID_JOHAB = 6;
this.TT_MS_ID_UCS_4 = 10;
this.TT_APPLE_ID_DEFAULT = 0;
this.TT_APPLE_ID_UNICODE_1_1 = 1;
this.TT_APPLE_ID_ISO_10646 = 2;
this.TT_APPLE_ID_UNICODE_2_0 = 3;
this.TT_APPLE_ID_UNICODE_32 = 4;
this.TT_APPLE_ID_VARIANT_SELECTOR = 5;
// true type tags
this.TTAG_avar = FT_MAKE_TAG("a","v","a","r");
this.TTAG_BASE = FT_MAKE_TAG("B","A","S","E");
this.TTAG_bdat = FT_MAKE_TAG("b","d","a","t");
this.TTAG_BDF = FT_MAKE_TAG("B","D","F"," ");
this.TTAG_bhed = FT_MAKE_TAG("b","h","e","d");
this.TTAG_bloc = FT_MAKE_TAG("b","l","o","c");
this.TTAG_bsln = FT_MAKE_TAG("b","s","l","n");
this.TTAG_CFF = FT_MAKE_TAG("C","F","F"," ");
this.TTAG_CID = FT_MAKE_TAG("C","I","D"," ");
this.TTAG_cmap = FT_MAKE_TAG("c","m","a","p");
this.TTAG_cvar = FT_MAKE_TAG("c","v","a","r");
this.TTAG_cvt = FT_MAKE_TAG("c","v","t"," ");
this.TTAG_DSIG = FT_MAKE_TAG("D","S","I","G");
this.TTAG_EBDT = FT_MAKE_TAG("E","B","D","T");
this.TTAG_EBLC = FT_MAKE_TAG("E","B","L","C");
this.TTAG_EBSC = FT_MAKE_TAG("E","B","S","C");
this.TTAG_feat = FT_MAKE_TAG("f","e","a","t");
this.TTAG_FOND = FT_MAKE_TAG("F","O","N","D");
this.TTAG_fpgm = FT_MAKE_TAG("f","p","g","m");
this.TTAG_fvar = FT_MAKE_TAG("f","v","a","r");
this.TTAG_gasp = FT_MAKE_TAG("g","a","s","p");
this.TTAG_GDEF = FT_MAKE_TAG("G","D","E","F");
this.TTAG_glyf = FT_MAKE_TAG("g","l","y","f");
this.TTAG_GPOS = FT_MAKE_TAG("G","P","O","S");
this.TTAG_GSUB = FT_MAKE_TAG("G","S","U","B");
this.TTAG_gvar = FT_MAKE_TAG("g","v","a","r");
this.TTAG_hdmx = FT_MAKE_TAG("h","d","m","x");
this.TTAG_head = FT_MAKE_TAG("h","e","a","d");
this.TTAG_hhea = FT_MAKE_TAG("h","h","e","a");
this.TTAG_hmtx = FT_MAKE_TAG("h","m","t","x");
this.TTAG_JSTF = FT_MAKE_TAG("J","S","T","F");
this.TTAG_just = FT_MAKE_TAG("j","u","s","t");
this.TTAG_kern = FT_MAKE_TAG("k","e","r","n");
this.TTAG_lcar = FT_MAKE_TAG("l","c","a","r");
this.TTAG_loca = FT_MAKE_TAG("l","o","c","a");
this.TTAG_LTSH = FT_MAKE_TAG("L","T","S","H");
this.TTAG_LWFN = FT_MAKE_TAG("L","W","F","N");
this.TTAG_MATH = FT_MAKE_TAG("M","A","T","H");
this.TTAG_maxp = FT_MAKE_TAG("m","a","x","p");
this.TTAG_META = FT_MAKE_TAG("M","E","T","A");
this.TTAG_MMFX = FT_MAKE_TAG("M","M","F","X");
this.TTAG_MMSD = FT_MAKE_TAG("M","M","S","D");
this.TTAG_mort = FT_MAKE_TAG("m","o","r","t");
this.TTAG_morx = FT_MAKE_TAG("m","o","r","x");
this.TTAG_name = FT_MAKE_TAG("n","a","m","e");
this.TTAG_opbd = FT_MAKE_TAG("o","p","b","d");
this.TTAG_OS2 = FT_MAKE_TAG("O","S","/","2");
this.TTAG_OTTO = FT_MAKE_TAG("O","T","T","O");
this.TTAG_PCLT = FT_MAKE_TAG("P","C","L","T");
this.TTAG_POST = FT_MAKE_TAG("P","O","S","T");
this.TTAG_post = FT_MAKE_TAG("p","o","s","t");
this.TTAG_prep = FT_MAKE_TAG("p","r","e","p");
this.TTAG_prop = FT_MAKE_TAG("p","r","o","p");
this.TTAG_sfnt = FT_MAKE_TAG("s","f","n","t");
this.TTAG_SING = FT_MAKE_TAG("S","I","N","G");
this.TTAG_trak = FT_MAKE_TAG("t","r","a","k");
this.TTAG_true = FT_MAKE_TAG("t","r","u","e");
this.TTAG_ttc = FT_MAKE_TAG("t","t","c"," ");
this.TTAG_ttcf = FT_MAKE_TAG("t","t","c","f");
this.TTAG_TYP1 = FT_MAKE_TAG("T","Y","P","1");
this.TTAG_typ1 = FT_MAKE_TAG("t","y","p","1");
this.TTAG_VDMX = FT_MAKE_TAG("V","D","M","X");
this.TTAG_vhea = FT_MAKE_TAG("v","h","e","a");
this.TTAG_vmtx = FT_MAKE_TAG("v","m","t","x");
//
this.FT_FACE_FLAG_SCALABLE = (1 << 0);
this.FT_FACE_FLAG_FIXED_SIZES = (1 << 1);
this.FT_FACE_FLAG_FIXED_WIDTH = (1 << 2);
this.FT_FACE_FLAG_SFNT = (1 << 3);
this.FT_FACE_FLAG_HORIZONTAL = (1 << 4);
this.FT_FACE_FLAG_VERTICAL = (1 << 5);
this.FT_FACE_FLAG_KERNING = (1 << 6);
this.FT_FACE_FLAG_FAST_GLYPHS = (1 << 7);
this.FT_FACE_FLAG_MULTIPLE_MASTERS = (1 << 8);
this.FT_FACE_FLAG_GLYPH_NAMES = (1 << 9);
this.FT_FACE_FLAG_EXTERNAL_STREAM = (1 << 10);
this.FT_FACE_FLAG_HINTER = (1 << 11);
this.FT_FACE_FLAG_CID_KEYED = (1 << 12);
this.FT_FACE_FLAG_TRICKY = (1 << 13);
this.FT_SIZE_REQUEST_TYPE_NOMINAL = 0;
this.FT_SIZE_REQUEST_TYPE_REAL_DIM = 1;
this.FT_SIZE_REQUEST_TYPE_BBOX = 2;
this.FT_SIZE_REQUEST_TYPE_CELL = 3;
this.FT_SIZE_REQUEST_TYPE_SCALES = 4;
this.FT_SIZE_REQUEST_TYPE_MAX = 5;
this.FT_LOAD_DEFAULT = 0x0;
this.FT_LOAD_NO_SCALE = 0x1;
this.FT_LOAD_NO_HINTING = 0x2;
this.FT_LOAD_RENDER = 0x4;
this.FT_LOAD_NO_BITMAP = 0x8;
this.FT_LOAD_VERTICAL_LAYOUT = 0x10;
this.FT_LOAD_FORCE_AUTOHINT = 0x20;
this.FT_LOAD_CROP_BITMAP = 0x40;
this.FT_LOAD_PEDANTIC = 0x80;
this.FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH = 0x200;
this.FT_LOAD_NO_RECURSE = 0x400;
this.FT_LOAD_IGNORE_TRANSFORM = 0x800;
this.FT_LOAD_MONOCHROME = 0x1000;
this.FT_LOAD_LINEAR_DESIGN = 0x2000;
this.FT_LOAD_NO_AUTOHINT = 0x8000;
this.FT_GLYPH_FORMAT_NONE = 0;
this.FT_GLYPH_FORMAT_COMPOSITE = FT_MAKE_TAG("c","o","m","p");
this.FT_GLYPH_FORMAT_BITMAP = FT_MAKE_TAG("b","i","t","s");
this.FT_GLYPH_FORMAT_OUTLINE = FT_MAKE_TAG("o","u","t","l");
this.FT_GLYPH_FORMAT_PLOTTER = FT_MAKE_TAG("p","l","o","t");
this.FT_RENDER_MODE_NORMAL = 0;
this.FT_RENDER_MODE_LIGHT = 1;
this.FT_RENDER_MODE_MONO = 2;
this.FT_RENDER_MODE_LCD = 3;
this.FT_RENDER_MODE_LCD_V = 4;
this.FT_RENDER_MODE_MAX = 5;
this.FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS = 1;
this.FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES = 2;
this.FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID = 4;
this.FT_SUBGLYPH_FLAG_SCALE = 8;
this.FT_SUBGLYPH_FLAG_XY_SCALE = 0x40;
this.FT_SUBGLYPH_FLAG_2X2 = 0x80;
this.FT_SUBGLYPH_FLAG_USE_MY_METRICS = 0x200;
this.FT_LOAD_ADVANCE_ONLY = 0x100;
this.FT_LOAD_SBITS_ONLY = 0x4000;
this.FT_KERNING_DEFAULT = 0;
this.FT_KERNING_UNFITTED = 1;
this.FT_KERNING_UNSCALED = 2;
//
this.TT_NAME_ID_COPYRIGHT = 0;
this.TT_NAME_ID_FONT_FAMILY = 1;
this.TT_NAME_ID_FONT_SUBFAMILY = 2;
this.TT_NAME_ID_UNIQUE_ID = 3;
this.TT_NAME_ID_FULL_NAME = 4;
this.TT_NAME_ID_VERSION_STRING = 5;
this.TT_NAME_ID_PS_NAME = 6;
this.TT_NAME_ID_TRADEMARK = 7;
this.TT_NAME_ID_MANUFACTURER = 8;
this.TT_NAME_ID_DESIGNER = 9;
this.TT_NAME_ID_DESCRIPTION = 10;
this.TT_NAME_ID_VENDOR_URL = 11;
this.TT_NAME_ID_DESIGNER_URL = 12;
this.TT_NAME_ID_LICENSE = 13;
this.TT_NAME_ID_LICENSE_URL = 14;
this.TT_NAME_ID_PREFERRED_FAMILY = 16;
this.TT_NAME_ID_PREFERRED_SUBFAMILY = 17;
this.TT_NAME_ID_MAC_FULL_NAME = 18;
this.TT_NAME_ID_SAMPLE_TEXT = 19;
this.TT_NAME_ID_CID_FINDFONT_NAME = 20;
this.TT_NAME_ID_WWS_FAMILY = 21;
this.TT_NAME_ID_WWS_SUBFAMILY = 22;
//
this.FT_STYLE_FLAG_ITALIC = 1;
this.FT_STYLE_FLAG_BOLD = 2;
//
this.FT_RASTER_FLAG_DEFAULT = 0;
this.FT_RASTER_FLAG_AA = 1;
this.FT_RASTER_FLAG_DIRECT = 2;
this.FT_RASTER_FLAG_CLIP = 4;
//
this.FT_CURVE_TAG_ON = 1;
this.FT_CURVE_TAG_CONIC = 0;
this.FT_CURVE_TAG_CUBIC = 2;
//
this.FT_OUTLINE_NONE = 0x0;
this.FT_OUTLINE_OWNER = 0x1;
this.FT_OUTLINE_EVEN_ODD_FILL = 0x2;
this.FT_OUTLINE_REVERSE_FILL = 0x4;
this.FT_OUTLINE_IGNORE_DROPOUTS = 0x8;
this.FT_OUTLINE_SMART_DROPOUTS = 0x10;
this.FT_OUTLINE_INCLUDE_STUBS = 0x20;
this.FT_OUTLINE_HIGH_PRECISION = 0x100;
this.FT_OUTLINE_SINGLE_PASS = 0x200;
//
this.FT_GLYPH_OWN_BITMAP = 0x1;
//
this.FT_PIXEL_MODE_NONE = 0;
this.FT_PIXEL_MODE_MONO = 1;
this.FT_PIXEL_MODE_GRAY = 2;
this.FT_PIXEL_MODE_GRAY2 = 3;
this.FT_PIXEL_MODE_GRAY4 = 4;
this.FT_PIXEL_MODE_LCD = 5;
this.FT_PIXEL_MODE_LCD_V = 6;
this.FT_PIXEL_MODE_MAX = 7;
this.ErrorLongJump = -100;
//
this.FT_GLYPH_BBOX_UNSCALED = 0;
this.FT_GLYPH_BBOX_SUBPIXELS = 0;
this.FT_GLYPH_BBOX_GRIDFIT = 1;
this.FT_GLYPH_BBOX_TRUNCATE = 2;
this.FT_GLYPH_BBOX_PIXELS = 3;
// GX_TupleCountFlags
this.GX_TC_TUPLES_SHARE_POINT_NUMBERS = 0x8000;
this.GX_TC_RESERVED_TUPLE_FLAGS = 0x7000;
this.GX_TC_TUPLE_COUNT_MASK = 0x0FFF;
// GX_TupleIndexFlags
this.GX_TI_EMBEDDED_TUPLE_COORD = 0x8000;
this.GX_TI_INTERMEDIATE_TUPLE = 0x4000;
this.GX_TI_PRIVATE_POINT_NUMBERS = 0x2000;
this.GX_TI_RESERVED_TUPLE_FLAG = 0x1000;
this.GX_TI_TUPLE_INDEX_MASK = 0x0FFF;
//
this.TTAG_wght = FT_MAKE_TAG("w","g","h","t");
this.TTAG_wdth = FT_MAKE_TAG("w","d","t","h");
this.TTAG_opsz = FT_MAKE_TAG("o","p","s","z");
this.TTAG_slnt = FT_MAKE_TAG("s","l","n","t");
//
this.FT_PARAM_TAG_UNPATENTED_HINTING = FT_MAKE_TAG("u","n","p","a");
// это для типа указателя на cmap
this.FT_CMAP_0 = 0;
this.FT_CMAP_1 = 1;
this.FT_CMAP_4 = 2;
this.FT_CMAP_12 = 3;
this.FT_CMAP_13 = 4;
this.FT_CMAP_14 = 5;
// t1types
this.T1_BLEND_UNDERLINE_POSITION = 0;
this.T1_BLEND_UNDERLINE_THICKNESS = 1;
this.T1_BLEND_ITALIC_ANGLE = 2;
this.T1_BLEND_BLUE_VALUES = 3;
this.T1_BLEND_OTHER_BLUES = 4;
this.T1_BLEND_STANDARD_WIDTH = 5;
this.T1_BLEND_STANDARD_HEIGHT = 6;
this.T1_BLEND_STEM_SNAP_WIDTHS = 7;
this.T1_BLEND_STEM_SNAP_HEIGHTS = 8;
this.T1_BLEND_BLUE_SCALE = 9;
this.T1_BLEND_BLUE_SHIFT = 10;
this.T1_BLEND_FAMILY_BLUES = 11;
this.T1_BLEND_FAMILY_OTHER_BLUES = 12;
this.T1_BLEND_FORCE_BOLD = 13;
this.T1_BLEND_MAX = 14;
this.T1_MAX_MM_DESIGNS = 16;
this.T1_MAX_MM_AXIS = 4;
this.T1_MAX_MM_MAP_POINTS = 20;
this.T1_ENCODING_TYPE_NONE = 0;
this.T1_ENCODING_TYPE_ARRAY = 1;
this.T1_ENCODING_TYPE_STANDARD = 2;
this.T1_ENCODING_TYPE_ISOLATIN1 = 3;
this.T1_ENCODING_TYPE_EXPERT = 4;
// keys
this.PS_DICT_FONT_TYPE = 0;
this.PS_DICT_FONT_MATRIX = 1;
this.PS_DICT_FONT_BBOX = 2;
this.PS_DICT_PAINT_TYPE = 3;
this.PS_DICT_FONT_NAME = 4;
this.PS_DICT_UNIQUE_ID = 5;
this.PS_DICT_NUM_CHAR_STRINGS = 6;
this.PS_DICT_CHAR_STRING_KEY = 7;
this.PS_DICT_CHAR_STRING = 8;
this.PS_DICT_ENCODING_TYPE = 9;
this.PS_DICT_ENCODING_ENTRY = 10;
/* conventionally in the font Private dictionary */
this.PS_DICT_NUM_SUBRS = 11;
this.PS_DICT_SUBR = 12;
this.PS_DICT_STD_HW = 13;
this.PS_DICT_STD_VW = 14;
this.PS_DICT_NUM_BLUE_VALUES = 15;
this.PS_DICT_BLUE_VALUE = 16;
this.PS_DICT_BLUE_FUZZ = 17;
this.PS_DICT_NUM_OTHER_BLUES = 18;
this.PS_DICT_OTHER_BLUE = 19;
this.PS_DICT_NUM_FAMILY_BLUES = 20;
this.PS_DICT_FAMILY_BLUE = 21;
this.PS_DICT_NUM_FAMILY_OTHER_BLUES = 22;
this.PS_DICT_FAMILY_OTHER_BLUE = 23;
this.PS_DICT_BLUE_SCALE = 24;
this.PS_DICT_BLUE_SHIFT = 25;
this.PS_DICT_NUM_STEM_SNAP_H = 26;
this.PS_DICT_STEM_SNAP_H = 27;
this.PS_DICT_NUM_STEM_SNAP_V = 28;
this.PS_DICT_STEM_SNAP_V = 29;
this.PS_DICT_FORCE_BOLD = 30;
this.PS_DICT_RND_STEM_UP = 31;
this.PS_DICT_MIN_FEATURE = 32;
this.PS_DICT_LEN_IV = 33;
this.PS_DICT_PASSWORD = 34;
this.PS_DICT_LANGUAGE_GROUP = 35;
/* conventionally in the font FontInfo dictionary */
this.PS_DICT_VERSION = 36;
this.PS_DICT_NOTICE = 37;
this.PS_DICT_FULL_NAME = 38;
this.PS_DICT_FAMILY_NAME = 39;
this.PS_DICT_WEIGHT = 40;
this.PS_DICT_IS_FIXED_PITCH = 41;
this.PS_DICT_UNDERLINE_POSITION = 42;
this.PS_DICT_UNDERLINE_THICKNESS = 43;
this.PS_DICT_FS_TYPE = 44;
this.PS_DICT_ITALIC_ANGLE = 45;
this.PS_DICT_MAX = this.PS_DICT_ITALIC_ANGLE;
this.TT_ADOBE_ID_STANDARD = 0;
this.TT_ADOBE_ID_EXPERT = 1;
this.TT_ADOBE_ID_CUSTOM = 2;
this.TT_ADOBE_ID_LATIN_1 = 3;
// PSAUX
this.T1_TOKEN_TYPE_NONE = 0;
this.T1_TOKEN_TYPE_ANY = 1;
this.T1_TOKEN_TYPE_STRING = 2;
this.T1_TOKEN_TYPE_ARRAY = 3;
this.T1_TOKEN_TYPE_KEY = 4;
this.T1_TOKEN_TYPE_MAX = 5;
this.T1_FIELD_TYPE_NONE = 0;
this.T1_FIELD_TYPE_BOOL = 1;
this.T1_FIELD_TYPE_INTEGER = 2;
this.T1_FIELD_TYPE_FIXED = 3;
this.T1_FIELD_TYPE_FIXED_1000 = 4;
this.T1_FIELD_TYPE_STRING = 5;
this.T1_FIELD_TYPE_KEY = 6;
this.T1_FIELD_TYPE_BBOX = 7;
this.T1_FIELD_TYPE_INTEGER_ARRAY = 8;
this.T1_FIELD_TYPE_FIXED_ARRAY = 9;
this.T1_FIELD_TYPE_CALLBACK = 10;
this.T1_FIELD_TYPE_MAX = 11;
this.T1_FIELD_LOCATION_CID_INFO = 0;
this.T1_FIELD_LOCATION_FONT_DICT = 1;
this.T1_FIELD_LOCATION_FONT_EXTRA = 2;
this.T1_FIELD_LOCATION_FONT_INFO = 3;
this.T1_FIELD_LOCATION_PRIVATE = 4;
this.T1_FIELD_LOCATION_BBOX = 5;
this.T1_FIELD_LOCATION_LOADER = 6;
this.T1_FIELD_LOCATION_FACE = 7;
this.T1_FIELD_LOCATION_BLEND = 8;
this.T1_FIELD_LOCATION_MAX = 9;
this.T1_FIELD_DICT_FONTDICT = 1;
this.T1_FIELD_DICT_PRIVATE = 2;
this.T1_Parse_Start = 0;
this.T1_Parse_Have_Width = 1;
this.T1_Parse_Have_Moveto = 2;
this.T1_Parse_Have_Path = 3;
this.T1_MAX_CHARSTRINGS_OPERANDS = 256;
this.AFM_VALUE_TYPE_STRING = 0;
this.AFM_VALUE_TYPE_NAME = 1;
this.AFM_VALUE_TYPE_FIXED = 2;
this.AFM_VALUE_TYPE_INTEGER = 3;
this.AFM_VALUE_TYPE_BOOL = 4;
this.AFM_VALUE_TYPE_INDEX = 5;
this.AFM_STREAM_STATUS_NORMAL = 0;
this.AFM_STREAM_STATUS_EOC = 1;
this.AFM_STREAM_STATUS_EOL = 2;
this.AFM_STREAM_STATUS_EOF = 3;
this.AFM_MAX_ARGUMENTS = 5;
this.AFM_TOKEN_ASCENDER = 0;
this.AFM_TOKEN_AXISLABEL = 1;
this.AFM_TOKEN_AXISTYPE = 2;
this.AFM_TOKEN_B = 3;
this.AFM_TOKEN_BLENDAXISTYPES = 4;
this.AFM_TOKEN_BLENDDESIGNMAP = 5;
this.AFM_TOKEN_BLENDDESIGNPOSITIONS = 6;
this.AFM_TOKEN_C = 7;
this.AFM_TOKEN_CC = 8;
this.AFM_TOKEN_CH = 9;
this.AFM_TOKEN_CAPHEIGHT = 10;
this.AFM_TOKEN_CHARWIDTH = 11;
this.AFM_TOKEN_CHARACTERSET = 12;
this.AFM_TOKEN_CHARACTERS = 13;
this.AFM_TOKEN_DESCENDER = 14;
this.AFM_TOKEN_ENCODINGSCHEME = 15;
this.AFM_TOKEN_ENDAXIS = 16;
this.AFM_TOKEN_ENDCHARMETRICS = 17;
this.AFM_TOKEN_ENDCOMPOSITES = 18;
this.AFM_TOKEN_ENDDIRECTION = 19;
this.AFM_TOKEN_ENDFONTMETRICS = 20;
this.AFM_TOKEN_ENDKERNDATA = 21;
this.AFM_TOKEN_ENDKERNPAIRS = 22;
this.AFM_TOKEN_ENDTRACKKERN = 23;
this.AFM_TOKEN_ESCCHAR = 24;
this.AFM_TOKEN_FAMILYNAME = 25;
this.AFM_TOKEN_FONTBBOX = 26;
this.AFM_TOKEN_FONTNAME = 27;
this.AFM_TOKEN_FULLNAME = 28;
this.AFM_TOKEN_ISBASEFONT = 29;
this.AFM_TOKEN_ISCIDFONT = 30;
this.AFM_TOKEN_ISFIXEDPITCH = 31;
this.AFM_TOKEN_ISFIXEDV = 32;
this.AFM_TOKEN_ITALICANGLE = 33;
this.AFM_TOKEN_KP = 34;
this.AFM_TOKEN_KPH = 35;
this.AFM_TOKEN_KPX = 36;
this.AFM_TOKEN_KPY = 37;
this.AFM_TOKEN_L = 38;
this.AFM_TOKEN_MAPPINGSCHEME = 39;
this.AFM_TOKEN_METRICSSETS = 40;
this.AFM_TOKEN_N = 41;
this.AFM_TOKEN_NOTICE = 42;
this.AFM_TOKEN_PCC = 43;
this.AFM_TOKEN_STARTAXIS = 44;
this.AFM_TOKEN_STARTCHARMETRICS = 45;
this.AFM_TOKEN_STARTCOMPOSITES = 46;
this.AFM_TOKEN_STARTDIRECTION = 47;
this.AFM_TOKEN_STARTFONTMETRICS = 48;
this.AFM_TOKEN_STARTKERNDATA = 49;
this.AFM_TOKEN_STARTKERNPAIRS = 50;
this.AFM_TOKEN_STARTKERNPAIRS0 = 51;
this.AFM_TOKEN_STARTKERNPAIRS1 = 52;
this.AFM_TOKEN_STARTTRACKKERN = 53;
this.AFM_TOKEN_STDHW = 54;
this.AFM_TOKEN_STDVW = 55;
this.AFM_TOKEN_TRACKKERN = 56;
this.AFM_TOKEN_UNDERLINEPOSITION = 57;
this.AFM_TOKEN_UNDERLINETHICKNESS = 58;
this.AFM_TOKEN_VV = 59;
this.AFM_TOKEN_VVECTOR = 60;
this.AFM_TOKEN_VERSION = 61;
this.AFM_TOKEN_W = 62;
this.AFM_TOKEN_W0 = 63;
this.AFM_TOKEN_W0X = 64;
this.AFM_TOKEN_W0Y = 65;
this.AFM_TOKEN_W1 = 66;
this.AFM_TOKEN_W1X = 67;
this.AFM_TOKEN_W1Y = 68;
this.AFM_TOKEN_WX = 69;
this.AFM_TOKEN_WY = 70;
this.AFM_TOKEN_WEIGHT = 71;
this.AFM_TOKEN_WEIGHTVECTOR = 72;
this.AFM_TOKEN_XHEIGHT = 73;
this.N_AFM_TOKENS = 74;
this.AFM_TOKEN_UNKNOWN = 75;
this.T1_MAX_TABLE_ELEMENTS = 32;
this.T1_MAX_SUBRS_CALLS = 16;
this.TABLE_EXTEND = 5;
// константы строковые
this.SYMBOL_CONST_SR = "\r".charCodeAt(0);
this.SYMBOL_CONST_SN = "\n".charCodeAt(0);
this.SYMBOL_CONST_ST = "\t".charCodeAt(0);
this.SYMBOL_CONST_SF = "\f".charCodeAt(0);
this.SYMBOL_CONST_S0 = "\0".charCodeAt(0);
this.SYMBOL_CONST_SPACE = " ".charCodeAt(0);
this.SYMBOL_CONST_LS1 = "(".charCodeAt(0);
this.SYMBOL_CONST_LS2 = "[".charCodeAt(0);
this.SYMBOL_CONST_LS3 = "{".charCodeAt(0);
this.SYMBOL_CONST_RS1 = ")".charCodeAt(0);
this.SYMBOL_CONST_RS2 = "]".charCodeAt(0);
this.SYMBOL_CONST_RS3 = "}".charCodeAt(0);
this.SYMBOL_CONST_BS = "/".charCodeAt(0);
this.SYMBOL_CONST_SS = "\\".charCodeAt(0);
this.SYMBOL_CONST_MATH_1 = "<".charCodeAt(0);
this.SYMBOL_CONST_MATH_2 = ">".charCodeAt(0);
this.SYMBOL_CONST_MATH_3 = "%".charCodeAt(0);
this.SYMBOL_CONST_MATH_MINUS = "-".charCodeAt(0);
this.SYMBOL_CONST_MATH_PLUS = "+".charCodeAt(0);
this.SYMBOL_CONST_0 = "0".charCodeAt(0);
this.SYMBOL_CONST_7 = "7".charCodeAt(0);
this.SYMBOL_CONST_9 = "9".charCodeAt(0);
this.SYMBOL_CONST_a = "a".charCodeAt(0);
this.SYMBOL_CONST_b = "b".charCodeAt(0);
this.SYMBOL_CONST_c = "c".charCodeAt(0);
this.SYMBOL_CONST_d = "d".charCodeAt(0);
this.SYMBOL_CONST_e = "e".charCodeAt(0);
this.SYMBOL_CONST_f = "f".charCodeAt(0);
this.SYMBOL_CONST_g = "g".charCodeAt(0);
this.SYMBOL_CONST_h = "h".charCodeAt(0);
this.SYMBOL_CONST_i = "i".charCodeAt(0);
this.SYMBOL_CONST_j = "j".charCodeAt(0);
this.SYMBOL_CONST_k = "k".charCodeAt(0);
this.SYMBOL_CONST_l = "l".charCodeAt(0);
this.SYMBOL_CONST_m = "m".charCodeAt(0);
this.SYMBOL_CONST_n = "n".charCodeAt(0);
this.SYMBOL_CONST_o = "o".charCodeAt(0);
this.SYMBOL_CONST_p = "p".charCodeAt(0);
this.SYMBOL_CONST_q = "q".charCodeAt(0);
this.SYMBOL_CONST_r = "r".charCodeAt(0);
this.SYMBOL_CONST_s = "s".charCodeAt(0);
this.SYMBOL_CONST_t = "t".charCodeAt(0);
this.SYMBOL_CONST_u = "u".charCodeAt(0);
this.SYMBOL_CONST_v = "v".charCodeAt(0);
this.SYMBOL_CONST_w = "w".charCodeAt(0);
this.SYMBOL_CONST_x = "x".charCodeAt(0);
this.SYMBOL_CONST_y = "y".charCodeAt(0);
this.SYMBOL_CONST_z = "z".charCodeAt(0);
this.SYMBOL_CONST_A = "A".charCodeAt(0);
this.SYMBOL_CONST_B = "B".charCodeAt(0);
this.SYMBOL_CONST_C = "C".charCodeAt(0);
this.SYMBOL_CONST_D = "D".charCodeAt(0);
this.SYMBOL_CONST_E = "E".charCodeAt(0);
this.SYMBOL_CONST_F = "F".charCodeAt(0);
this.SYMBOL_CONST_G = "G".charCodeAt(0);
this.SYMBOL_CONST_H = "H".charCodeAt(0);
this.SYMBOL_CONST_I = "I".charCodeAt(0);
this.SYMBOL_CONST_J = "J".charCodeAt(0);
this.SYMBOL_CONST_K = "K".charCodeAt(0);
this.SYMBOL_CONST_L = "L".charCodeAt(0);
this.SYMBOL_CONST_M = "M".charCodeAt(0);
this.SYMBOL_CONST_N = "N".charCodeAt(0);
this.SYMBOL_CONST_O = "O".charCodeAt(0);
this.SYMBOL_CONST_P = "P".charCodeAt(0);
this.SYMBOL_CONST_Q = "Q".charCodeAt(0);
this.SYMBOL_CONST_R = "R".charCodeAt(0);
this.SYMBOL_CONST_S = "S".charCodeAt(0);
this.SYMBOL_CONST_T = "T".charCodeAt(0);
this.SYMBOL_CONST_U = "U".charCodeAt(0);
this.SYMBOL_CONST_V = "V".charCodeAt(0);
this.SYMBOL_CONST_W = "W".charCodeAt(0);
this.SYMBOL_CONST_X = "X".charCodeAt(0);
this.SYMBOL_CONST_Y = "Y".charCodeAt(0);
this.SYMBOL_CONST_Z = "Z".charCodeAt(0);
this.SYMBOL_CONST_VOSCL = "!".charCodeAt(0);
this.SYMBOL_CONST_VOPROS = "?".charCodeAt(0);
this.SYMBOL_CONST_LOGOR = "|".charCodeAt(0);
this.SYMBOL_CONST_POINT = ".".charCodeAt(0);
this.SYMBOL_CONST_SHARP = "#".charCodeAt(0);
this.SYMBOL_CONST_SERP = ";".charCodeAt(0);
this.SYMBOL_CONST__ = "_".charCodeAt(0);
this.op_none = 0;
this.op_endchar = 1;
this.op_hsbw = 2;
this.op_seac = 3;
this.op_sbw = 4;
this.op_closepath = 5;
this.op_hlineto = 6;
this.op_hmoveto = 7;
this.op_hvcurveto = 8;
this.op_rlineto = 9;
this.op_rmoveto = 10;
this.op_rrcurveto = 11;
this.op_vhcurveto = 12;
this.op_vlineto = 13;
this.op_vmoveto = 14;
this.op_dotsection = 15;
this.op_hstem = 16;
this.op_hstem3 = 17;
this.op_vstem = 18;
this.op_vstem3 = 19;
this.op_div = 20;
this.op_callothersubr = 21;
this.op_callsubr = 22;
this.op_pop = 23;
this.op_return = 24;
this.op_setcurrentpoint = 25;
this.op_unknown15 = 26;
this.op_max = 27;
// cff
this.CFF_MAX_CID_FONTS = 256;
this.CFF_MAX_STACK_DEPTH = 96;
this.CFF_CODE_TOPDICT = 0x1000;
this.CFF_CODE_PRIVATE = 0x2000;
this.CFFCODE_TOPDICT = 0x1000;
this.CFFCODE_PRIVATE = 0x2000;
this.cff_kind_none = 0;
this.cff_kind_num = 1;
this.cff_kind_fixed = 2;
this.cff_kind_fixed_thousand = 3;
this.cff_kind_string = 4;
this.cff_kind_bool = 5;
this.cff_kind_delta = 6;
this.cff_kind_callback = 7;
this.cff_kind_max = 8;
this.CFF_MAX_OPERANDS = 48;
this.CFF_MAX_SUBRS_CALLS = 32;
this.CFF_MAX_TRANS_ELEMENTS = 32;
this.CFF_COUNT_CHECK_WIDTH = 0x80;
this.CFF_COUNT_EXACT = 0x40;
this.CFF_COUNT_CLEAR_STACK = 0x20;
this.cff_op_unknown = 0;
this.cff_op_rmoveto = 1;
this.cff_op_hmoveto = 2;
this.cff_op_vmoveto = 3;
this.cff_op_rlineto = 4;
this.cff_op_hlineto = 5;
this.cff_op_vlineto = 6;
this.cff_op_rrcurveto = 7;
this.cff_op_hhcurveto = 8;
this.cff_op_hvcurveto = 9;
this.cff_op_rcurveline = 10;
this.cff_op_rlinecurve = 11;
this.cff_op_vhcurveto = 12;
this.cff_op_vvcurveto = 13;
this.cff_op_flex = 14;
this.cff_op_hflex = 15;
this.cff_op_hflex1 = 16;
this.cff_op_flex1 = 17;
this.cff_op_endchar = 18;
this.cff_op_hstem = 19;
this.cff_op_vstem = 20;
this.cff_op_hstemhm = 21;
this.cff_op_vstemhm = 22;
this.cff_op_hintmask = 23;
this.cff_op_cntrmask = 24;
this.cff_op_dotsection = 25;
this.cff_op_abs = 26;
this.cff_op_add = 27;
this.cff_op_sub = 28;
this.cff_op_div = 29;
this.cff_op_neg = 30;
this.cff_op_random = 31;
this.cff_op_mul = 32;
this.cff_op_sqrt = 33;
this.cff_op_blend = 34;
this.cff_op_drop = 35;
this.cff_op_exch = 36;
this.cff_op_index = 37;
this.cff_op_roll = 38;
this.cff_op_dup = 39;
this.cff_op_put = 40;
this.cff_op_get = 41;
this.cff_op_store = 42;
this.cff_op_load = 43;
this.cff_op_and = 44;
this.cff_op_or = 45;
this.cff_op_not = 46;
this.cff_op_eq = 47;
this.cff_op_ifelse = 48;
this.cff_op_callsubr = 49;
this.cff_op_callgsubr = 50;
this.cff_op_return = 51;
/* Type 1 opcodes: invalid but seen in real life */
this.cff_op_hsbw = 52;
this.cff_op_closepath = 53;
this.cff_op_callothersubr = 54;
this.cff_op_pop = 55;
this.cff_op_seac = 56;
this.cff_op_sbw = 57;
this.cff_op_setcurrentpoint = 58;
this.cff_op_max = 59;
// t1
this.T1_PRIVATE = 1;
this.T1_FONTDIR_AFTER_PRIVATE = 2;
// ttinterp
this.TT_MAX_CODE_RANGES = 3;
this.tt_coderange_none = 0;
this.tt_coderange_font = 1;
this.tt_coderange_cvt = 2;
this.tt_coderange_glyph = 3;
this.SPH_OPTION_BITMAP_WIDTHS = false;
this.SPH_OPTION_SET_SUBPIXEL = true;
this.SPH_OPTION_SET_GRAYSCALE = false;
this.SPH_OPTION_SET_COMPATIBLE_WIDTHS = false;
this.SPH_OPTION_SET_RASTERIZER_VERSION = 38;
this.SPH_TWEAK_ALLOW_X_DMOVE = 0x0000001;
this.SPH_TWEAK_ALLOW_X_DMOVEX = 0x0000002;
this.SPH_TWEAK_ALLOW_X_MOVE_ZP2 = 0x0000004;
this.SPH_TWEAK_ALWAYS_DO_DELTAP = 0x0000008;
this.SPH_TWEAK_ALWAYS_SKIP_DELTAP = 0x0000010;
this.SPH_TWEAK_COURIER_NEW_2_HACK = 0x0000020;
this.SPH_TWEAK_DEEMBOLDEN = 0x0000040;
this.SPH_TWEAK_DELTAP_SKIP_EXAGGERATED_VALUES = 0x0000080;
this.SPH_TWEAK_DO_SHPIX = 0x0000100;
this.SPH_TWEAK_EMBOLDEN = 0x0000200;
this.SPH_TWEAK_MIAP_HACK = 0x0000400;
this.SPH_TWEAK_NORMAL_ROUND = 0x0000800;
this.SPH_TWEAK_NO_ALIGNRP_AFTER_IUP = 0x0001000;
this.SPH_TWEAK_NO_CALL_AFTER_IUP = 0x0002000;
this.SPH_TWEAK_NO_DELTAP_AFTER_IUP = 0x0004000;
this.SPH_TWEAK_PIXEL_HINTING = 0x0008000;
this.SPH_TWEAK_RASTERIZER_35 = 0x0010000;
this.SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES = 0x0020000;
this.SPH_TWEAK_SKIP_INLINE_DELTAS = 0x0040000;
this.SPH_TWEAK_SKIP_IUP = 0x0080000;
this.SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES = 0x0100000;
this.SPH_TWEAK_SKIP_OFFPIXEL_Y_MOVES = 0x0200000;
this.SPH_TWEAK_TIMES_NEW_ROMAN_HACK = 0x0400000;
this.SPH_TWEAK_MIRP_CVT_ZERO = 0x0800000;
this.FT_CURVE_TAG_HAS_SCANMODE = 4;
this.FT_CURVE_TAG_TOUCH_X = 8; /* reserved for the TrueType hinter */
this.FT_CURVE_TAG_TOUCH_Y = 16; /* reserved for the TrueType hinter */
this.FT_CURVE_TAG_TOUCH_BOTH = (this.FT_CURVE_TAG_TOUCH_X | this.FT_CURVE_TAG_TOUCH_Y);
this.FT_ORIENTATION_TRUETYPE = 0;
this.FT_ORIENTATION_POSTSCRIPT = 1;
this.FT_ORIENTATION_FILL_RIGHT = this.FT_ORIENTATION_TRUETYPE;
this.FT_ORIENTATION_FILL_LEFT = this.FT_ORIENTATION_POSTSCRIPT;
this.FT_ORIENTATION_NONE = 2;
this.FT_ANGLE_PI = (180 << 16);
this.FT_ANGLE_PI2 = (this.FT_ANGLE_PI / 2);
this.FT_TRIG_MAX_ITERS = 23;
this.FT_TRIG_SCALE = 0x9B74EDA8;
if (this.FT_TRIG_SCALE < 0)
this.FT_TRIG_SCALE = this.IntToUInt(this.FT_TRIG_SCALE);
this.tt_coderange_none = 0;
this.tt_coderange_font = 1;
this.tt_coderange_cvt = 2;
this.tt_coderange_glyph = 3;
this.MAX_RUNNABLE_OPCODES = 1000000;
this.ARGS_ARE_WORDS = 0x0001;
this.ARGS_ARE_XY_VALUES = 0x0002;
this.ROUND_XY_TO_GRID = 0x0004;
this.WE_HAVE_A_SCALE = 0x0008;
this.MORE_COMPONENTS = 0x0020;
this.WE_HAVE_AN_XY_SCALE = 0x0040;
this.WE_HAVE_A_2X2 = 0x0080;
this.WE_HAVE_INSTR = 0x0100;
this.USE_MY_METRICS = 0x0200;
this.OVERLAP_COMPOUND = 0x0400;
this.SCALED_COMPONENT_OFFSET = 0x0800;
this.UNSCALED_COMPONENT_OFFSET = 0x1000;
// GENERATOR_END_CONSTANTS
this.UintToInt = function(v){
return (v>FT_Common.m_i)?v-FT_Common.a_i:v;
}
this.UShort_To_Short = function(v){
return (v>FT_Common.m_s)?v-FT_Common.a_s:v;
}
this.IntToUInt = function(v){
return (v<0)?v+FT_Common.a_i:v;
}
this.Short_To_UShort = function(v){
return (v<0)?v+FT_Common.a_s:v;
}
this.memset = function(d,v,s)
{
for (var i=0;i<s;i++)
d[i]=v;
}
this.memcpy = function(d,s,l)
{
for (var i=0;i<l;i++)
d[i]=s[i];
}
this.memset_p = function(d,v,s)
{
var _d = d.data;
var _e = d.pos+s;
for (var i=d.pos;i<_e;i++)
_d[i]=v;
}
this.memcpy_p = function(d,s,l)
{
var _d1=d.data;
var _p1=d.pos;
var _d2=s.data;
var _p2=s.pos;
for (var i=0;i<l;i++)
_d1[_p1++]=_d2[_p2++];
}
this.memcpy_p2 = function(d,s,p,l)
{
var _d1=d.data;
var _p1=d.pos;
var _p2=p;
for (var i=0;i<l;i++)
_d1[_p1++]=s[_p2++];
}
this.realloc = function(memory, pointer, cur_count, new_count)
{
var ret = { block: null, err : 0, size : new_count};
if (cur_count < 0 || new_count < 0)
{
/* may help catch/prevent nasty security issues */
ret.err = FT_Common.FT_Err_Invalid_Argument;
}
else if (new_count == 0)
{
ret.block = null;
}
else if (cur_count == 0)
{
ret.block = memory.Alloc(new_count);
}
else
{
var block2 = memory.Alloc(new_count);
FT_Common.memcpy_p(block2, pointer, cur_count);
ret.block = block2;
}
return ret;
}
this.realloc_long = function(memory, pointer, cur_count, new_count)
{
var ret = { block: null, err : 0, size : new_count};
if (cur_count < 0 || new_count < 0)
{
/* may help catch/prevent nasty security issues */
ret.err = FT_Common.FT_Err_Invalid_Argument;
}
else if (new_count == 0)
{
ret.block = null;
}
else if (cur_count == 0)
{
ret.block = CreateIntArray(new_count);
}
else
{
var block2 = CreateIntArray(new_count);
for (var i = 0; i < cur_count; i++)
block2[i] = pointer[i];
ret.block = block2;
}
return ret;
}
}
var FT_Common = new _FT_Common();
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
/******************************************************************************/
// cidgload
/******************************************************************************/
function cid_load_glyph(decoder, glyph_index)
{
var face = decoder.builder.face;
var cid = face.cid;
var memory = face.memory;
var fd_select;
var stream = face.cid_stream;
var error = 0;
var charstring = null;
var glyph_length = 0;
var psaux = face.psaux;
//#ifdef FT_CONFIG_OPTION_INCREMENTAL
var inc = face.internal.incremental_interface;
//#endif
//#ifdef FT_CONFIG_OPTION_INCREMENTAL
if (inc != null)
{
var glyph_data = new FT_Data();
error = inc.funcs.get_glyph_data(inc.object, glyph_index, glyph_data);
if (error != 0)
return error;
var p = glyph_data.pointer;
fd_select = cid_get_offset(p, cid.fd_bytes);
if (glyph_data.length != 0)
{
glyph_length = glyph_data.length - cid.fd_bytes;
charstring = memory.Alloc(glyph_length);
var _data = glyph_data.pointer.data;
var _start = glyph_data.pointer.pos + cid.fd_bytes;
for (var i = 0; i < glyph_length; i++)
charstring[i] = _data[_start + i];
}
inc.funcs.free_glyph_data(inc.object, glyph_data);
glyph_data = null;
}
else
{
//#endif /* FT_CONFIG_OPTION_INCREMENTAL */
var entry_len = cid.fd_bytes + cid.gd_bytes;
error = stream.Seek(cid.data_offset + cid.cidmap_offset + glyph_index * entry_len);
if (error != 0)
return error;
error = stream.EnterFrame(2 * entry_len);
if (error != 0)
return error;
var p = new CPointer();
p.data = stream.data;
p.pos = stream.cur;
fd_select = cid_get_offset(p, cid.fd_bytes);
var off1 = cid_get_offset(p, cid.gd_bytes);
p.pos += cid.fd_bytes;
glyph_length = cid_get_offset(p, cid.gd_bytes) - off1;
stream.ExitFrame();
if (fd_select >= cid.num_dicts)
return FT_Common.FT_Err_Invalid_Offset;
if (glyph_length == 0)
return error;
charstring = memory.Alloc(glyph_length);
error = stream.ReadAt(cid.data_offset + off1, charstring, glyph_length);
if (error != 0)
return error;
}
var cid_subrs = face.subrs[fd_select];
/* Set up subrs */
decoder.num_subrs = cid_subrs.num_subrs;
decoder.subrs = cid_subrs.code;
decoder.subrs_len = 0;
/* Set up font matrix */
var dict = cid.font_dicts[fd_select];
decoder.font_matrix = dublicate_matrix(dict.font_matrix);
decoder.font_offset = dublicate_vector(dict.font_offset);
decoder.lenIV = dict.private_dict.lenIV;
/* Decode the charstring. */
/* Adjustment for seed bytes. */
var cs_offset = (decoder.lenIV >= 0 ? decoder.lenIV : 0);
/* Decrypt only if lenIV >= 0. */
if (decoder.lenIV >= 0)
psaux.t1_decrypt(charstring, glyph_length, 4330);
error = decoder.funcs.parse_charstrings(decoder, charstring + cs_offset, glyph_length - cs_offset);
charstring = null;
//#ifdef FT_CONFIG_OPTION_INCREMENTAL
if (!error && inc && inc.funcs.get_glyph_metrics)
{
var metrics = new FT_Incremental_MetricsRec();
metrics.bearing_x = (FT_RoundFix(decoder.builder.left_bearing.x) >> 16);
metrics.bearing_y = 0;
metrics.advance = (FT_RoundFix(decoder.builder.advance.x) >> 16);
metrics.advance_v = (FT_RoundFix(decoder.builder.advance.y) >> 16);
error = inc.funcs.get_glyph_metrics(inc.object, glyph_index, false, metrics);
decoder.builder.left_bearing.x = (metrics.bearing_x << 16);
decoder.builder.advance.x = (metrics.advance << 16);
decoder.builder.advance.y = (metrics.advance_v << 16);
}
//#endif /* FT_CONFIG_OPTION_INCREMENTAL */
return error;
}
function cid_slot_load_glyph(glyph, cidsize, glyph_index, load_flags)
{
var error = null;
var decoder = new T1_DecoderRec();
var face = glyph.face;
var psaux = face.psaux;
if (glyph_index >= face.num_glyphs)
return FT_Common.FT_Err_Invalid_Argument;
if (load_flags & FT_Common.FT_LOAD_NO_RECURSE)
load_flags |= (FT_Common.FT_LOAD_NO_SCALE | FT_Common.FT_LOAD_NO_HINTING);
glyph.x_scale = cidsize.metrics.x_scale;
glyph.y_scale = cidsize.metrics.y_scale;
glyph.outline.n_points = 0;
glyph.outline.n_contours = 0;
var hinting = ((load_flags & FT_Common.FT_LOAD_NO_SCALE) == 0 && (load_flags & FT_Common.FT_LOAD_NO_HINTING) == 0) ? 1 : 0;
glyph.format = FT_Common.FT_GLYPH_FORMAT_OUTLINE;
error = psaux.t1_decoder_funcs.init(decoder, glyph.face, cidsize, glyph, null, null, hinting, FT_LOAD_TARGET_MODE(load_flags), cid_load_glyph);
if (error != 0)
return error;
/* TODO: initialize decoder.len_buildchar and decoder.buildchar */
/* if we ever support CID-keyed multiple master fonts */
/* set up the decoder */
decoder.builder.no_recurse = ((load_flags & FT_Common.FT_LOAD_NO_RECURSE) != 0);
error = cid_load_glyph(decoder, glyph_index);
if (error != 0)
return error;
var font_matrix = dublicate_matrix(decoder.font_matrix);
var font_offset = dublicate_vector(decoder.font_offset);
/* save new glyph tables */
psaux.t1_decoder_funcs.done(decoder);
decoder = null;
/* now set the metrics -- this is rather simple, as */
/* the left side bearing is the xMin, and the top side */
/* bearing the yMax */
glyph.outline.flags &= FT_Common.FT_OUTLINE_OWNER;
glyph.outline.flags |= FT_Common.FT_OUTLINE_REVERSE_FILL;
/* for composite glyphs, return only left side bearing and */
/* advance width */
if (load_flags & FT_Common.FT_LOAD_NO_RECURSE)
{
var internal = glyph.internal;
glyph.metrics.horiBearingX = (FT_RoundFix(decoder.builder.left_bearing.x) >> 16);
glyph.metrics.horiAdvance = (FT_RoundFix(decoder.builder.advance.x) >> 16);
internal.glyph_matrix = dublicate_matrix(font_matrix);
internal.glyph_delta = dublicate_vector(font_offset);
internal.glyph_transformed = 1;
}
else
{
var metrics = glyph.metrics;
/* copy the _unscaled_ advance width */
metrics.horiAdvance = (FT_RoundFix(decoder.builder.advance.x) >> 16);
glyph.linearHoriAdvance = (FT_RoundFix(decoder.builder.advance.x) >> 16);
glyph.internal.glyph_transformed = 0;
/* make up vertical ones */
metrics.vertAdvance = (face.cid.font_bbox.yMax - face.cid.font_bbox.yMin) >> 16;
glyph.linearVertAdvance = metrics.vertAdvance;
glyph.format = FT_Common.FT_GLYPH_FORMAT_OUTLINE;
if (cidsize.metrics.y_ppem < 24)
cidglyph.outline.flags |= FT_Common.FT_OUTLINE_HIGH_PRECISION;
/* apply the font matrix */
FT_Outline_Transform(glyph.outline, font_matrix);
FT_Outline_Translate(glyph.outline, font_offset.x, font_offset.y);
var advance = new FT_Vector();
advance.x = metrics.horiAdvance;
advance.y = 0;
FT_Vector_Transform(advance, font_matrix);
metrics.horiAdvance = advance.x + font_offset.x;
advance.x = 0;
advance.y = metrics.vertAdvance;
FT_Vector_Transform(advance, font_matrix);
metrics.vertAdvance = advance.y + font_offset.y;
if ((load_flags & FT_Common.FT_LOAD_NO_SCALE) == 0)
{
/* scale the outline and the metrics */
var cur = decoder.builder.base;
var vec = cur.points;
var x_scale = glyph.x_scale;
var y_scale = glyph.y_scale;
/* First of all, scale the points */
if (!hinting || decoder.builder.hints_funcs == null)
{
for (var n = cur.n_points; n > 0; n--, vec++)
{
cur.points[vec].x = FT_MulFix(cur.points[vec].x, x_scale);
cur.points[vec].y = FT_MulFix(cur.points[vec].y, y_scale);
}
}
/* Then scale the metrics */
metrics.horiAdvance = FT_MulFix(metrics.horiAdvance, x_scale);
metrics.vertAdvance = FT_MulFix(metrics.vertAdvance, y_scale);
}
/* compute the other metrics */
var cbox = new FT_BBox();
FT_Outline_Get_CBox(glyph.outline, cbox);
metrics.width = cbox.xMax - cbox.xMin;
metrics.height = cbox.yMax - cbox.yMin;
metrics.horiBearingX = cbox.xMin;
metrics.horiBearingY = cbox.yMax;
if (load_flags & FT_Common.FT_LOAD_VERTICAL_LAYOUT)
{
/* make up vertical ones */
ft_synthesize_vertical_metrics(metrics, metrics.vertAdvance);
}
}
return error;
}
/******************************************************************************/
// cidparse
/******************************************************************************/
function CID_Parser()
{
this.root = new PS_ParserRec();
this.stream = null;
this.postscript = null;
this.postscript_len = 0;
this.data_offset = 0;
this.binary_length = 0;
this.cid = null;
this.num_dict = 0;
this.clear = function()
{
this.root.cursor = 0;
this.root.base = null;
this.root.limit = 0;
this.root.error = 0;
this.root.memory = null;
this.funcs = null;
this.stream = null;
this.postscript = null;
this.postscript_len = 0;
this.data_offset = 0;
this.binary_length = 0;
this.cid = null;
this.num_dict = 0;
}
}
function cid_parser_new(parser, stream, memory, psaux)
{
parser.clear();
psaux.ps_parser_funcs.init(parser.root, null, 0, memory);
parser.stream = stream;
var base_offset = stream.pos;
var offset = 0;
/* first of all, check the font format in the header */
var error = stream.EnterFrame(31);
if (error != 0)
return error;
var cur_str = stream.GetString1(31);
if (cur_str != "%!PS-Adobe-3.0 Resource-CIDFont")
return FT_Common.FT_Err_Unknown_File_Format;
stream.ExitFrame();
/* now, read the rest of the file until we find */
/* `StartData' or `/sfnts' */
var limit = 0;
while (true)
{
var buffer = memory.Alloc(256 + 10);
var read_len = 256 + 10; /* same as signed FT_Stream->size */
var p = dublicate_pointer(buffer);
for (offset = stream.pos; ; offset += 256)
{
var stream_len = stream.size - stream.pos;/* same as signed FT_Stream->size */
if (stream_len == 0)
return FT_Common.FT_Err_Unknown_File_Format;
read_len = Math.min(read_len, stream_len);
error = stream.Read(p, read_len);
if (error != 0)
return error;
if (read_len < 256)
p[read_len] = FT_Common.SYMBOL_CONST_S0;
limit = p.pos + read_len - 10;
p.pos = buffer.pos;
var bIsGoToFound = 0;
for (; p.pos < limit; p.pos++)
{
if ((p.data[p.pos] == FT_Common.SYMBOL_CONST_S) && (_strncmp_data(p, "StartData", 9) == 0))
{
/* save offset of binary data after `StartData' */
offset += (p.pos - buffer.pos + 10);
bIsGoToFound = 1;
break;
}
else if ((p.data[p.pos + 1] == FT_Common.SYMBOL_CONST_s) && (_strncmp_data(p, "/sfnts", 6) == 0))
{
offset += (p.pos - buffer.pos + 7);
bIsGoToFound = 1;
break;
}
}
if (bIsGoToFound == 1)
break;
var _dd = p.data;
var __s1 = buffer.pos;
var __s2 = p.pos;
var arr_move = memory.Alloc(10);
for (var i = 0; i < 10; i++)
arr_move[i] = _dd[__s2 + i];
for (var i = 0; i < 10; i++)
_dd[__s1 + i] = arr_move[i];
arr_move = null;
read_len = 256;
p.pos = buffer.pos + 10;
}
/* We have found the start of the binary data or the `/sfnts' token. */
/* Now rewind and extract the frame corresponding to this PostScript */
/* section. */
var ps_len = offset - base_offset;
error = stream.Seek(base_offset);
if (error != 0)
return error;
parser.postscript = new CPointer();
error = stream.ExtractFrame(ps_len, parser.postscript);
if (error != 0)
return error;
parser.data_offset = offset;
parser.postscript_len = ps_len;
parser.root.base = dublicate_pointer(parser.postscript);
parser.root.cursor = 0;
parser.root.limit = parser.postscript.pos + ps_len;
parser.num_dict = -1;
/* Finally, we check whether `StartData' or `/sfnts' was real -- */
/* it could be in a comment or string. We also get the arguments */
/* of `StartData' to find out whether the data is represented in */
/* binary or hex format. */
var arg1 = dublicate_pointer(parser.root.base);
arg1.pos += parser.root.cursor;
parser.root.funcs.skip_PS_token(p.root);
parser.root.funcs.skip_spaces(p.root);
var arg2 = dublicate_pointer(parser.root.base);
arg2.pos += parser.root.cursor;
parser.root.funcs.skip_PS_token(p.root);
parser.root.funcs.skip_spaces(p.root);
limit = parser.root.limit;
var cur = dublicate_pointer(parser.root.base);
cur.pos += parser.root.cursor;
while (cur.pos < limit)
{
if (parser.root.error != 0)
return parser.root.error;
if ((cur.data[cur.pos] == FT_Common.SYMBOL_CONST_S) && (_strncmp_data(cur, "StartData", 9) == 0))
{
if (_strncmp_data(arg1, "(Hex)", 5) == 0)
{
var _num_s = "";
var ii = 0;
while (true)
{
if (arg2.data[arg2.pos + ii] == FT_Common.SYMBOL_CONST_S0)
break;
_num_s += String.fromCharCode(arg2.data[arg2.pos + ii]);
}
parser.binary_length = parseInt(_num_s);
}
limit = parser.root.limit;
cur.pos = parser.root.base.pos + parser.root.cursor;
return error;
}
else if ((cur.data[cur.pos + 1] == FT_Common.SYMBOL_CONST_s) && (_strncmp_data(cur, "/sfnts", 6) == 0))
{
return FT_Common.FT_Err_Unknown_File_Format;
}
parser.root.funcs.skip_PS_token(p.root);
parser.root.funcs.skip_spaces(p.root);
arg1.pos = arg2.pos;
arg2.pos = cur.pos;
cur.pos = parser.root.base.pos + parser.root.cursor;
}
/* we haven't found the correct `StartData'; go back and continue */
/* searching */
stream.ReleaseFrame();
parser.postscript = null;
error = stream.Seek(offset);
if (error != 0)
break;
}
return error;
}
function cid_parser_done(parser)
{
/* always free the private dictionary */
if (parser.postscript != null)
{
parser.stream.ReleaseFrame();
parser.postscript = null;
}
parser.root.funcs.done(parser.root);
}
/******************************************************************************/
// cidload
/******************************************************************************/
function CID_Loader()
{
this.parser = new CID_Parser();
this.num_chars = 0;
this.clear = function()
{
this.parser.clear();
this.num_chars = 0;
}
}
function cid_get_offset(start, offsize)
{
var result = 0;
for (; offsize > 0; offsize--)
{
result <<= 8;
result |= start.data[start.pos++];
}
return result;
}
function cid_load_keyword(face, loader, keyword)
{
var error = 0;
var parser = loader.parser;
var object = null;
var cid = face.cid;
if (keyword.type == FT_Common.T1_FIELD_TYPE_CALLBACK)
{
keyword.reader(face, parser);
error = parser.error;
return error;
}
switch (keyword.location)
{
case FT_Common.T1_FIELD_LOCATION_CID_INFO:
object = cid;
break;
case FT_Common.T1_FIELD_LOCATION_FONT_INFO:
object = cid.font_info;
break;
case FT_Common.T1_FIELD_LOCATION_FONT_EXTRA:
object = face.font_extra;
break;
case FT_Common.T1_FIELD_LOCATION_BBOX:
object = cid.font_bbox;
break;
default:
{
if (parser.num_dict < 0 || parser.num_dict >= cid.num_dicts)
return FT_Error.FT_Err_Syntax_Error;
var dict = cid.font_dicts[parser.num_dict];
switch (keyword.location)
{
case FT_Common.T1_FIELD_LOCATION_PRIVATE:
object = dict.private_dict;
break;
default:
object = dict;
}
}
}
var dummy_object = new Array(1);
dummy_object[0] = object;
if (keyword.type == FT_Common.T1_FIELD_TYPE_INTEGER_ARRAY || keyword.type == FT_Common.T1_FIELD_TYPE_FIXED_ARRAY)
error = loader.parser.root.funcs.load_field_table(loader.parser.root, keyword, dummy_object, 0, 0);
else
error = loader.parser.root.funcs.load_field(loader.parser.root, keyword, dummy_object, 0, 0);
return error;
}
function parse_font_matrix(face, parser)
{
var temp = new Array(6);
if (parser.num_dict >= 0 && parser.num_dict < face.cid.num_dicts)
{
var dict = face.cid.font_dicts[parser.num_dict];
var matrix = dict.font_matrix;
var offset = dict.font_offset;
parser.root.funcs.to_fixed_array(parser.root, 6, temp, 3);
var temp_scale = Math.abs(temp[3]);
/* Set units per EM based on FontMatrix values. We set the value to */
/* `1000/temp_scale', because temp_scale was already multiplied by */
/* 1000 (in `t1_tofixed', from psobjs.c). */
face.units_per_EM = (FT_DivFix(0x10000, FT_DivFix(temp_scale, 1000)));
if (face.units_per_EM > 0xFFFF)
face.units_per_EM = 0xFFFF;
/* we need to scale the values by 1.0/temp[3] */
if (temp_scale != 0x10000)
{
temp[0] = FT_DivFix(temp[0], temp_scale);
temp[1] = FT_DivFix(temp[1], temp_scale);
temp[2] = FT_DivFix(temp[2], temp_scale);
temp[4] = FT_DivFix(temp[4], temp_scale);
temp[5] = FT_DivFix(temp[5], temp_scale);
temp[3] = 0x10000;
}
matrix.xx = temp[0];
matrix.yx = temp[1];
matrix.xy = temp[2];
matrix.yy = temp[3];
/* note that the font offsets are expressed in integer font units */
offset.x = temp[4] >> 16;
offset.y = temp[5] >> 16;
}
return 0;
}
function parse_fd_array(face, parser)
{
var cid = face.cid;
var error = 0;
var num_dicts = parser.root.funcs.to_int(parser.root);
if (cid.font_dicts == null)
{
cid.font_dicts = new Array(num_dicts);
for (var i = 0; i < num_dicts; i++)
{
cid.font_dicts[i] = new CID_FaceDictRec();
cid.font_dicts[i].private_dict.lenIV = 4;
}
cid.num_dicts = num_dicts;
}
return error;
}
function parse_expansion_factor(face, parser)
{
if (parser.num_dict >= 0 && parser.num_dict < face.cid.num_dicts)
{
var dict = face.cid.font_dicts[parser.num_dict];
dict.expansion_factor = parser.root.funcs.to_fixed(parser.root, 0);
dict.private_dict.expansion_factor = dict.expansion_factor;
}
return 0;
}
function cid_parse_dict(face, loader, base, size)
{
var parser = loader.parser;
parser.root.cursor = dublicate_pointer(base);
parser.root.limit = base.pos + size;
parser.root.error = 0;
var cur = dublicate_pointer(base);
var limit = cur.pos + size;
var newlimit = 0;
while (true)
{
parser.root.cursor = cur.pos;
parser.root.funcs.skip_spaces(parser.root);
if (parser.root.cursor.pos >= limit)
newlimit = limit - 1 - 17;
else
newlimit = parser.root.cursor.pos - 17;
/* look for `%ADOBeginFontDict' */
for (; cur.pos < newlimit; cur.pos++)
{
if (cur.data[cur.pos] == FT_Common.SYMBOL_CONST_MATH_3 && _strncmp_data(cur, "%ADOBeginFontDict", 17) == 0)
{
/* if /FDArray was found, then cid->num_dicts is > 0, and */
/* we can start increasing parser->num_dict */
if (face.cid.num_dicts > 0)
parser.num_dict++;
}
}
cur.pos = parser.root.cursor.pos;
/* no error can occur in cid_parser_skip_spaces */
if (cur.pos >= limit)
break;
parser.root.funcs.skip_PS_token(parser.root);
if (parser.root.cursor.pos >= limit || parser.root.error != 0)
break;
/* look for immediates */
if (cur.data[cur.pos] == FT_Common.SYMBOL_CONST_BS && cur.pos + 2 < limit)
{
cur.pos++;
var len = parser.root.cursor.pos - cur.pos;
if (len > 0 && len < 22)
{
/* now compare the immediate name to the keyword table */
var keyword = 0;
var keywords_count = cid_field_records.length;
while (true)
{
if (keyword >= keywords_count)
break;
var _key = cid_field_records[keyword];
if (cur.data[cur.pos] == _key.ident.charCodeAt(0) && len == _key.ident.length)
{
var n;
for (n = 1; n < len; n++)
if (cur.data[cur.pos + n] != _key.ident.charCodeAt(n))
break;
if (n >= len)
{
/* we found it - run the parsing callback */
parser.root.error = cid_load_keyword(face, loader, keyword);
if (parser.root.error)
return parser.root.error;
break;
}
}
keyword++;
}
}
}
cur.pos = parser.root.cursor.pos;
}
return parser.root.error;
}
function cid_read_subrs(face)
{
var cid = face.cid;
var memory = face.memory;
var stream = face.cid_stream;
var error = 0;
var n = 0;
var _num_dicts = cid.num_dicts;
face.subrs = new Array(_num_dicts);
var subrs = face.subrs;
for (n = 0; n < _num_dicts; n++)
subrs[n] = new CID_SubrsRec();
var subr = 0;
var max_offsets = 0;
var offsets = [];
var psaux = face.psaux;
for (n = 0; n < _num_dicts; n++, subr++)
{
var dict = cid.font_dicts[n];
var lenIV = dict.private_dict.lenIV;
var count, num_subrs = dict.num_subrs;
/* Check for possible overflow. */
if (num_subrs == 0xFFFFFFFF)
{
face.subrs = null;
offsets = null;
return FT_Common.FT_Err_Syntax_Error;
}
/* reallocate offsets array if needed */
if (num_subrs + 1 > max_offsets)
{
var new_max = (num_subrs + 4) & (~3);
if ( new_max <= max_offsets )
{
face.subrs = null;
offsets = null;
return FT_Common.FT_Err_Syntax_Error;
}
for (var i = max_offsets; i < new_max; i++)
offsets[i] = 0;
max_offsets = new_max;
}
/* read the subrmap's offsets */
error = stream.Seek(cid.data_offset + dict.subrmap_offset);
if (error == 0)
error = stream.EnterFrame((num_subrs + 1) * dict.sd_bytes);
if (error != 0)
{
face.subrs = null;
offsets = null;
return error;
}
var p = new CPointer;
p.data = stream.data;
p.pos = stream.cur;
for (count = 0; count <= num_subrs; count++)
offsets[count] = cid_get_offset(p, dict.sd_bytes);
stream.ExitFrame();
/* offsets must be ordered */
for (count = 1; count <= num_subrs; count++)
{
if (offsets[count - 1] > offsets[count])
{
face.subrs = null;
offsets = null;
return error;
}
}
/* now, compute the size of subrs charstrings, */
/* allocate, and read them */
var data_len = offsets[num_subrs] - offsets[0];
subrs[subr].code = new Array(num_subrs + 1);
subrs[subr].code[0] = memory.Alloc(data_len);
error = stream.Seek(cid.data_offset + offsets[0]);
if (error == 0)
error = stream.Read(subrs[subr].code[0], data_len);
if (error != 0)
{
face.subrs = null;
offsets = null;
return error;
}
/* set up pointers */
for (count = 1; count <= num_subrs; count++)
{
var len = offsets[count] - offsets[count - 1];
subrs[subr].code[count] = subrs[subr].code[count - 1] + len;
}
/* decrypt subroutines, but only if lenIV >= 0 */
if (lenIV >= 0)
{
for (count = 0; count < num_subrs; count++)
{
var len = offsets[count + 1] - offsets[count];
psaux.t1_decrypt(subrs[subr].code[count], len, 4330);
}
}
subrs[subr].num_subrs = num_subrs;
}
offsets = null;
return error;
}
function t1_init_loader(loader, face)
{
loader.clear();
}
function t1_done_loader(loader)
{
cid_parser_done(loader.parser);
}
function cid_hex_to_binary(data, data_len, offset, face)
{
var stream = face.stream;
var error = stream.Seek(offset);
if (error != 0)
return error;
var buffer = face.memoty.Alloc(256);
var val = null;
var d = dublicate_pointer(data);
var dlimit = d.pos + data_len;
var p = dublicate_pointer(buffer);
var plimit = p.pos;
var upper_nibble = 1;
var done = 0;
while (d.pos < dlimit)
{
if (p.pos >= plimit)
{
var oldpos = stream.pos;
var size = stream.size - oldpos;
if (size == 0)
return FT_Common.FT_Err_Syntax_Error;
error = stream.Read(buffer, (256 > size) ? size : 256);
if (error != 0)
return error;
p.pos = buffer.pos;
plimit = p.pos + stream.pos - oldpos;
}
var _p = p.data[p.pos];
if (_p >= FT_Common.SYMBOL_CONST_0 && _p <= FT_Common.SYMBOL_CONST_9)
val = _p - FT_Common.SYMBOL_CONST_0;
else if (_p >= FT_Common.SYMBOL_CONST_a && _p <= FT_Common.SYMBOL_CONST_f)
val = _p - FT_Common.SYMBOL_CONST_a;
else if (_p >= FT_Common.SYMBOL_CONST_A && _p <= FT_Common.SYMBOL_CONST_F)
val = _p - FT_Common.SYMBOL_CONST_A + 10;
else if (_p == FT_Common.SYMBOL_CONST_SPACE || _p == FT_Common.SYMBOL_CONST_ST ||
_p == FT_Common.SYMBOL_CONST_SR || _p == FT_Common.SYMBOL_CONST_SN ||
_p == FT_Common.SYMBOL_CONST_SF || _p == FT_Common.SYMBOL_CONST_S0)
{
p.pos++;
continue;
}
else if (_p == FT_Common.SYMBOL_CONST_MATH_2)
{
val = 0;
done = 1;
}
else
{
return FT_Common.FT_Err_Syntax_Error;
}
if (upper_nibble == 1)
d.data[d.pos] = (val << 4) & 0xFF;
else
{
d.data[d.pos] = (d.data[d.pos] + val) & 0xFF;
d.pos++;
}
upper_nibble = (1 - upper_nibble);
if (done == 1)
break;
p.pos++;
}
return 0;
}
function cid_face_open(face, face_index)
{
var loader = new CID_Loader();
var memory = face.memory;
t1_init_loader(loader, face);
var parser = loader.parser;
var error = cid_parser_new(parser, face.stream, memory, face.psaux);
if (error != 0)
{
t1_done_loader(loader);
return error;
}
error = cid_parse_dict(face, loader, parser.postscript, parser.postscript_len);
if (error != 0)
{
return error;
}
if (face_index < 0)
{
t1_done_loader(loader);
return error;
}
if (parser.binary_length != 0)
{
face.binary_data = memory.Alloc(parser.binary_length);
/* we must convert the data section from hexadecimal to binary */
error = cid_hex_to_binary(face.binary_data, parser.binary_length, parser.data_offset, face);
if (error != 0)
{
t1_done_loader(loader);
return error;
}
face.cid_stream = new FT_Stream(face.binary_data.data, parser.binary_length);
face.cid.data_offset = 0;
}
else
{
face.cid_stream = new FT_Stream(face.stream.data, face.stream.size);
face.cid.data_offset = loader.parser.data_offset;
}
error = cid_read_subrs(face);
t1_done_loader(loader);
return error;
}
/******************************************************************************/
// objs
/******************************************************************************/
function CID_SizeRec()
{
this.root = new FT_Size();
this.valid = 0;
}
function CID_GlyphSlotRec()
{
this.root = new FT_GlyphSlot();
this.hint = 0;
this.scaled = 0;
this.x_scale = 0;
this.y_scale = 0;
}
function cid_slot_done(_slot)
{
var slot = (slot.hint == undefined) ? _slot : _slot.root;
slot.internal.glyph_hints = null;
}
function cid_slot_init(_slot)
{
var slot = (slot.hint == undefined) ? _slot : _slot.root;
var face = slot.face;
var pshinter = face.pshinter;
if (pshinter != null)
{
var module = slot.face.driver.library.FT_Get_Module("pshinter");
if (module != null)
{
// пока нет хинтов - нету и этого if'а
slot.internal.glyph_hints = pshinter.get_t1_funcs(module);
}
}
return 0;
}
function cid_size_get_globals_funcs(size)
{
var face = size.root.face;
var pshinter = face.pshinter;
var module = size.face.driver.library.FT_Get_Module("pshinter");
return (module && pshinter && pshinter.get_globals_funcs) ? pshinter.get_globals_funcs(module) : null;
}
function cid_size_done(size)
{
if (size.root.internal != null)
{
var funcs = cid_size_get_globals_funcs(size);
if (funcs != null)
funcs.destroy(size.root.internal);
size.root.internal = 0;
}
}
function cid_size_init(size) /* CID_Size */
{
var error = 0;
var funcs = cid_size_get_globals_funcs(size);
if (funcs != null)
{
var face = size.root.face;
var dict = face.cid.font_dicts[face.face_index];
var priv = dict.private_dict;
var ret = funcs.create(size.root.face.memory, priv);
error = ret.err;
if (error == 0)
size.internal = ret.globals;
}
return error;
}
function cid_size_request(size, req)
{
FT_Request_Metrics(size.face, req);
var funcs = cid_size_get_globals_funcs(size);
if (funcs)
funcs.set_scale(size.internal, size.metrics.x_scale, size.metrics.y_scale, 0, 0);
return 0;
}
function cid_face_done(face) /* CID_Face */
{
if (face == null)
return;
var cid = face.cid;
var info = cid.font_info;
/* release subrs */
face.subrs = null;
/* release FontInfo strings */
info.version = "";
info.notice = "";
info.full_name = "";
info.family_name = "";
info.weight = "";
/* release font dictionaries */
cid.font_dicts = null;
cid.num_dicts = 0;
/* release other strings */
cid.cid_font_name = "";
cid.registry = "";
cid.ordering = "";
face.family_name = "";
face.style_name = "";
face.binary_data = null;
face.cid_stream = null;
}
function cid_face_init(stream, face, face_index, num_params, params)
{
face.num_faces = 1;
var psaux = face.psaux;
if (psaux == null)
{
psaux = face.driver.library.FT_Get_Module_Interface("psaux");
face.psaux = psaux;
}
var pshinter = face.pshinter;
if (pshinter == null)
{
pshinter = face.driver.library.FT_Get_Module_Interface("pshinter");
face.pshinter = pshinter;
}
/* open the tokenizer; this will also check the font format */
var error = stream.Seek(0);
if (error != 0)
return error;
error = cid_face_open(face, face_index);
if (error != 0)
return error;
/* if we just wanted to check the format, leave successfully now */
if (face_index < 0)
return error;
/* check the face index */
/* XXX: handle CID fonts with more than a single face */
if (face_index != 0)
return FT_Common.FT_Err_Invalid_Argument;
/* now load the font program into the face object */
/* initialize the face object fields */
/* set up root face fields */
var cid = face.cid;
var info = cid.font_info;
face.num_glyphs = cid.cid_count;
face.num_charmaps = 0;
face.face_index = face_index;
face.face_flags = FT_Common.FT_FACE_FLAG_SCALABLE | FT_Common.FT_FACE_FLAG_HORIZONTAL | FT_Common.FT_FACE_FLAG_HINTER;
if (info.is_fixed_pitch)
face.face_flags |= FT_Common.FT_FACE_FLAG_FIXED_WIDTH;
/* XXX: TODO: add kerning with .afm support */
/* get style name -- be careful, some broken fonts only */
/* have a /FontName dictionary entry! */
face.family_name = info.family_name;
/* assume "Regular" style if we don't know better */
face.style_name = "Regular";
if (face.family_name != null)
{
var full = info.full_name;
var family = face.family_name;
var full_ind = 0;
var family_ind = 0;
var full_count = 0;
var family_count = 0;
if (full != null)
{
while (full_ind < full_count)
{
if (full.charCodeAt(full_ind) == family.charCodeAt(family_ind))
{
family_ind++;
full_ind++;
}
else
{
if (full.charCodeAt(full_ind) == FT_Common.SYMBOL_CONST_SPACE || full.charCodeAt(full_ind) == FT_Common.SYMBOL_CONST_MATH_MINUS)
full_ind++;
else if (family.charCodeAt(family_ind) == FT_Common.SYMBOL_CONST_SPACE || family.charCodeAt(family_ind) == FT_Common.SYMBOL_CONST_MATH_MINUS)
family_ind++;
else
{
if (family_ind == family_count)
face.style_name = full;
break;
}
}
}
}
}
else
{
/* do we have a `/FontName'? */
if (cid.cid_font_name)
face.family_name = cid.cid_font_name;
}
/* compute style flags */
face.style_flags = 0;
if (info.italic_angle)
face.style_flags |= FT_Common.FT_STYLE_FLAG_ITALIC;
if (info.weight != null)
{
if (info.weight == "Bold" || info.weight == "Black")
face.style_flags |= FT_Common.FT_STYLE_FLAG_BOLD;
}
/* no embedded bitmap support */
face.num_fixed_sizes = 0;
face.available_sizes = 0;
face.bbox.xMin = cid.font_bbox.xMin >> 16;
face.bbox.yMin = cid.font_bbox.yMin >> 16;
/* no `U' suffix here to 0xFFFF! */
face.bbox.xMax = (cid.font_bbox.xMax + 0xFFFF) >> 16;
face.bbox.yMax = (cid.font_bbox.yMax + 0xFFFF) >> 16;
if (face.units_per_EM)
face.units_per_EM = 1000;
face.ascender = face.bbox.yMax;
face.descender = face.bbox.yMin;
face.height = parseInt((face.units_per_EM * 12) / 10);
if (face.height < face.ascender - face.descender)
face.height = (face.ascender - face.descender);
face.underline_position = info.underline_position;
face.underline_thickness = info.underline_thickness;
return error;
}
function cid_driver_init(driver)
{
return 0;
}
function cid_driver_done(driver)
{
}
/******************************************************************************/
// token
/******************************************************************************/
var cid_field_records = new Array(50);
// CID_FaceInfoRec
cid_field_records[0] = create_t1_field2("CIDFontName", FT_Common.T1_FIELD_LOCATION_CID_INFO, FT_Common.T1_FIELD_TYPE_KEY, function(obj, val, f) { obj.cid_font_name = val}, undefined);
cid_field_records[1] = create_t1_field2("CIDFontVersion", FT_Common.T1_FIELD_LOCATION_CID_INFO, FT_Common.T1_FIELD_TYPE_FIXED, function(obj, val, f) { obj.cid_version = val}, undefined);
cid_field_records[2] = create_t1_field2("CIDFontType", FT_Common.T1_FIELD_LOCATION_CID_INFO, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.cid_font_type = val}, undefined);
cid_field_records[3] = create_t1_field2("Registry", FT_Common.T1_FIELD_LOCATION_CID_INFO, FT_Common.T1_FIELD_TYPE_STRING, function(obj, val, f) { obj.registry = val}, undefined);
cid_field_records[4] = create_t1_field2("Ordering", FT_Common.T1_FIELD_LOCATION_CID_INFO, FT_Common.T1_FIELD_TYPE_STRING, function(obj, val, f) { obj.ordering = val}, undefined);
cid_field_records[5] = create_t1_field2("Supplement", FT_Common.T1_FIELD_LOCATION_CID_INFO, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.supplement = val}, undefined);
cid_field_records[6] = create_t1_field2("UIDBase", FT_Common.T1_FIELD_LOCATION_CID_INFO, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.uid_base = val}, undefined);
cid_field_records[7] = create_t1_field2("CIDMapOffset", FT_Common.T1_FIELD_LOCATION_CID_INFO, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.cidmap_offset = val}, undefined);
cid_field_records[8] = create_t1_field2("FDBytes", FT_Common.T1_FIELD_LOCATION_CID_INFO, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.fd_bytes = val}, undefined);
cid_field_records[9] = create_t1_field2("GDBytes", FT_Common.T1_FIELD_LOCATION_CID_INFO, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.gd_bytes = val}, undefined);
cid_field_records[10] = create_t1_field2("CIDCount", FT_Common.T1_FIELD_LOCATION_CID_INFO, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.cid_count = val}, undefined);
// PS_FontInfoRec
cid_field_records[11] = create_t1_field2("version", FT_Common.T1_FIELD_LOCATION_FONT_INFO, FT_Common.T1_FIELD_TYPE_STRING, function(obj, val, f) { obj.version = val}, undefined);
cid_field_records[12] = create_t1_field2("Notice", FT_Common.T1_FIELD_LOCATION_FONT_INFO, FT_Common.T1_FIELD_TYPE_STRING, function(obj, val, f) { obj.notice = val}, undefined);
cid_field_records[13] = create_t1_field2("FullName", FT_Common.T1_FIELD_LOCATION_FONT_INFO, FT_Common.T1_FIELD_TYPE_STRING, function(obj, val, f) { obj.full_name = val}, undefined);
cid_field_records[14] = create_t1_field2("FamilyName", FT_Common.T1_FIELD_LOCATION_FONT_INFO, FT_Common.T1_FIELD_TYPE_STRING, function(obj, val, f) { obj.family_name = val}, undefined);
cid_field_records[15] = create_t1_field2("Weight", FT_Common.T1_FIELD_LOCATION_FONT_INFO, FT_Common.T1_FIELD_TYPE_STRING, function(obj, val, f) { obj.weight = val}, undefined);
cid_field_records[16] = create_t1_field2("ItalicAngle", FT_Common.T1_FIELD_LOCATION_FONT_INFO, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.italic_angle = val}, undefined);
cid_field_records[17] = create_t1_field2("isFixedPitch", FT_Common.T1_FIELD_LOCATION_FONT_INFO, FT_Common.T1_FIELD_TYPE_BOOL, function(obj, val, f) { obj.is_fixed_pitch = val}, undefined);
cid_field_records[18] = create_t1_field2("UnderlinePosition", FT_Common.T1_FIELD_LOCATION_FONT_INFO, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.underline_position = val}, undefined);
cid_field_records[19] = create_t1_field2("UnderlineThickness", FT_Common.T1_FIELD_LOCATION_FONT_INFO, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.underline_thickness = val}, undefined);
// PS_FontExtraRec
cid_field_records[20] = create_t1_field2("FSType", FT_Common.T1_FIELD_LOCATION_FONT_EXTRA, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.fs_type = val}, undefined);
// CID_FaceDictRec
cid_field_records[21] = create_t1_field2("PaintType", FT_Common.T1_FIELD_LOCATION_FONT_DICT, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.paint_type = val & 0xFF }, undefined);
cid_field_records[22] = create_t1_field2("FontType", FT_Common.T1_FIELD_LOCATION_FONT_DICT, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.font_type = val & 0xFF}, undefined);
cid_field_records[23] = create_t1_field2("SubrMapOffset", FT_Common.T1_FIELD_LOCATION_FONT_DICT, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.subrmap_offset = val}, undefined);
cid_field_records[24] = create_t1_field2("SDBytes", FT_Common.T1_FIELD_LOCATION_FONT_DICT, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.sd_bytes = val}, undefined);
cid_field_records[25] = create_t1_field2("SubrCount", FT_Common.T1_FIELD_LOCATION_FONT_DICT, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.num_subrs = val}, undefined);
cid_field_records[26] = create_t1_field2("lenBuildCharArray", FT_Common.T1_FIELD_LOCATION_FONT_DICT, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.len_buildchar = val}, undefined);
cid_field_records[27] = create_t1_field2("ForceBoldThreshold", FT_Common.T1_FIELD_LOCATION_FONT_DICT, FT_Common.T1_FIELD_TYPE_FIXED, function(obj, val, f) { obj.forcebold_threshold = val}, undefined);
cid_field_records[28] = create_t1_field2("StrokeWidth", FT_Common.T1_FIELD_LOCATION_FONT_DICT, FT_Common.T1_FIELD_TYPE_FIXED, function(obj, val, f) { obj.stroke_width = val}, undefined);
// PS_PrivateRec
cid_field_records[29] = create_t1_field2("UniqueID", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.unique_id = val}, undefined);
cid_field_records[30] = create_t1_field2("lenIV", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.lenIV = val}, undefined);
cid_field_records[31] = create_t1_field2("LanguageGroup", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.language_group = val}, undefined);
cid_field_records[32] = create_t1_field2("password", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.password = val}, undefined);
cid_field_records[33] = create_t1_field2("BlueScale", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_FIXED_1000, function(obj, val, f) { obj.blue_scale = val}, undefined);
cid_field_records[34] = create_t1_field2("BlueShift", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.blue_shift = val}, undefined);
cid_field_records[35] = create_t1_field2("BlueFuzz", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_INTEGER, function(obj, val, f) { obj.blue_fuzz = val}, undefined);
cid_field_records[36] = create_t1_field3("BlueValues", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_INTEGER_ARRAY, 14, function(obj, val, f) { obj.blue_values[f.offset] = val}, function(obj, val, f) { obj.num_blue_values = val});
cid_field_records[37] = create_t1_field3("OtherBlues", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_INTEGER_ARRAY, 10, function(obj, val, f) { obj.other_blues[f.offset] = val}, function(obj, val, f) { obj.num_other_blues = val});
cid_field_records[38] = create_t1_field3("FamilyBlues", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_INTEGER_ARRAY, 14, function(obj, val, f) { obj.family_blues[f.offset] = val}, function(obj, val, f) { obj.num_family_blues = val});
cid_field_records[39] = create_t1_field3("FamilyOtherBlues", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_INTEGER_ARRAY, 10, function(obj, val, f) { obj.family_other_blues[f.offset] = val}, function(obj, val, f) { obj.num_family_other_blues = val});
cid_field_records[40] = create_t1_field3("StdHW", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_INTEGER_ARRAY, 1, function(obj, val, f) { obj.standard_width[0] = val}, undefined);
cid_field_records[41] = create_t1_field3("StdVW", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_INTEGER_ARRAY, 1, function(obj, val, f) { obj.standard_height[0] = val}, undefined);
cid_field_records[42] = create_t1_field3("MinFeature", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_INTEGER_ARRAY, 2, function(obj, val, f) { obj.min_feature[f.offset] = val}, undefined);
cid_field_records[43] = create_t1_field3("StemSnapH", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_INTEGER_ARRAY, 12, function(obj, val, f) { obj.snap_widths[f.offset] = val}, function(obj, val, f) { obj.num_snap_widths = val});
cid_field_records[44] = create_t1_field3("StemSnapV", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_INTEGER_ARRAY, 12, function(obj, val, f) { obj.snap_heights[f.offset] = val}, function(obj, val, f) { obj.num_snap_heights = val});
cid_field_records[45] = create_t1_field2("ForceBold", FT_Common.T1_FIELD_LOCATION_PRIVATE, FT_Common.T1_FIELD_TYPE_BOOL, function(obj, val, f) { obj.force_bold = val}, undefined);
// FT_BBox
cid_field_records[46] = create_t1_field2("FontBBox", FT_Common.T1_FIELD_LOCATION_BBOX, FT_Common.T1_FIELD_TYPE_BOOL, undefined, undefined);
// callbacks
cid_field_records[47] = create_t1_field("FDArray", FT_Common.T1_FIELD_LOCATION_BBOX, FT_Common.T1_FIELD_TYPE_CALLBACK, parse_fd_array, 0, -1, 0, 0, 0, undefined, undefined);
cid_field_records[48] = create_t1_field("FontMatrix", FT_Common.T1_FIELD_LOCATION_BBOX, FT_Common.T1_FIELD_TYPE_CALLBACK, parse_font_matrix, 0, -1, 0, 0, 0, undefined, undefined);
cid_field_records[49] = create_t1_field("ExpansionFactor", FT_Common.T1_FIELD_LOCATION_BBOX, FT_Common.T1_FIELD_TYPE_CALLBACK, parse_expansion_factor, 0, -1, 0, 0, 0, undefined, undefined);
/******************************************************************************/
// driver
/******************************************************************************/
function cid_get_postscript_name(face)
{
var result = face.cid.cid_font_name;
if (result && result[0] == '/')
result = result.substring(1);
return result;
}
var cid_service_ps_name = new FT_Service_PsFontNameRec(cid_get_postscript_name);
function cid_ps_get_font_info(face)
{
FT_Error = FT_Common.FT_Err_Ok;
return face.cid.font_info.CreateDublicate();
}
function cid_ps_get_font_extra(face)
{
FT_Error = FT_Common.FT_Err_Ok;
return face.cid.font_extra.CreateDublicate();
}
var cid_service_ps_info = new FT_Service_PsInfoRec(cid_ps_get_font_info,cid_ps_get_font_extra,null,null,null);
function cid_get_ros(face, registry, ordering, supplement)
{
FT_Error = FT_Common.FT_Err_Ok;
var cid = face.cid;
return { registry : cid.registry, ordering : cid.ordering, supplement : cid.supplement }
}
function cid_get_is_cid(face)
{
FT_Error = FT_Common.FT_Err_Ok;
return 1;
}
function cid_get_cid_from_glyph_index(face, glyph_index)
{
FT_Error = FT_Common.FT_Err_Ok;
return glyph_index;
}
var cid_service_cid_info = new FT_Service_CIDRec(cid_get_ros, cid_get_is_cid, cid_get_cid_from_glyph_index);
var cid_services = new Array(4);
cid_services[0] = new FT_ServiceDescRec(FT_SERVICE_ID_XF86_NAME,FT_XF86_FORMAT_CID);
cid_services[1] = new FT_ServiceDescRec(FT_SERVICE_ID_POSTSCRIPT_FONT_NAME,cid_service_ps_name);
cid_services[2] = new FT_ServiceDescRec(FT_SERVICE_ID_POSTSCRIPT_INFO,cid_service_ps_info);
cid_services[3] = new FT_ServiceDescRec(FT_SERVICE_ID_CID,cid_service_cid_info);
function cid_get_interface(module, cid_interface)
{
return ft_service_list_lookup(cid_services, cid_interface);
}
function CID_Driver_Class()
{
this.flags = 0x501;
this.name = "t1cid";
this.version = 0x10000;
this.requires = 0x20000;
this.module_interface = null;
this.init = cid_driver_init;
this.done = cid_driver_done;
this.get_interface = cid_get_interface;
this.face_object_size = 0;
this.size_object_size = 0;
this.slot_object_size = 0;
this.init_face = cid_face_init;
this.done_face = cid_face_done;
this.init_size = cid_size_init;
this.done_size = cid_size_done;
this.init_slot = cid_slot_init;
this.done_slot = cid_slot_done;
//#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
this.set_char_sizes = ft_stub_set_char_sizes;
this.set_pixel_sizes = ft_stub_set_pixel_sizes;
//#endif
this.load_glyph = cid_slot_load_glyph;
this.get_kerning = null;
this.attach_file = null;
this.get_advances = null;
this.request_size = cid_size_request;
this.select_size = null;
}
function CID_Driver()
{
this.clazz = null; // FT_Module_Class
this.library = null; // FT_Library
this.memory = null; // FT_Memory
this.generic = null; // FT_Generic
this.clazz = new CID_Driver_Class();
this.faces_list = [];
this.extensions = null;
this.glyph_loader = null;
this.open_face = function(stream, face_index)
{
FT_Error = 0;
var face = new CID_Face();
var internal = new FT_Face_Internal();
face.driver = this;
face.memory = this.memory;
face.stream = stream;
//#ifdef FT_CONFIG_OPTION_INCREMENTAL
face.internal = internal;
face.internal.incremental_interface = null;
//#endif
var err1 = this.clazz.init_face(stream, face, face_index);
if (err1 != 0)
{
face = null;
FT_Error = err1;
return null;
}
var err2 = find_unicode_charmap(face);
if (err2 != 0 && err2 != FT_Common.FT_Err_Invalid_CharMap_Handle)
{
face = null;
FT_Error = err2;
return null;
}
return face;
}
}
function create_cid_driver(library)
{
var driver = new CID_Driver();
driver.library = library;
driver.memory = library.Memory;
driver.clazz = new CID_Driver_Class();
return driver;
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
var FT_Error = 0;
function FT_Library()
{
this.Memory = null;
this.generic = new FT_Generic();
this.version_major = 2;
this.version_minor = 4;
this.version_patch = 8;
this.modules = [];
this.renderers = [];
this.cur_renderer = null;
this.auto_hinter = null;
this.raster_pool_size = 16384;
this.raster_pool = null;
this.m_bUseCIDs = true;
this.tt_hint_props = new LibraryHintingParams();
// #ifdef subpixel
//FT_LcdFilter lcd_filter;
//FT_Int lcd_extra; /* number of extra pixels */
//FT_Byte lcd_weights[7]; /* filter weights, if any */
//FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */
// #endif
//#ifdef FT_CONFIG_OPTION_PIC
//FT_PIC_Container pic_container;
//#endif
this.Init = function()
{
this.Memory = new FT_Memory();
//this.raster_pool = this.Memory.Alloc(this.raster_pool_size);
// теперь пул для каждого рендерера свой
// и он хранится непосредственно в рендерере.
// если не создавать постоянно рендереры - то смысл такой же. У нас так и есть.
this.FT_Add_Default_Modules();
}
this.FT_Add_Module = function(module)
{
var clazz = module.clazz;
if (clazz == null)
return FT_Common.FT_Err_Invalid_Argument;
var version_control = (this.version_major << 16 | this.version_minor);
if (clazz.requires > version_control)
return FT_Common.FT_Err_Invalid_Version;
var mod_count = this.modules.length;
for (var i = 0; i < mod_count; i++)
{
var _module = this.modules[i];
if (_module.clazz.name == clazz.name)
{
if (clazz.version < _module.clazz.version)
return FT_Common.FT_Err_Lower_Module_Version;
this.modules.splice(i,1);
break;
}
}
var error = FT_Common.FT_Err_Ok;
if ((clazz.flags & FT_Common.FT_MODULE_RENDERER) != 0)
{
error = this.ft_add_renderer(module);
if (FT_Common.FT_Err_Ok != error)
{
//delete module;
return error;
}
}
if ((clazz.flags & FT_Common.FT_MODULE_HINTER) != 0)
{
this.auto_hinter = module;
}
if ((clazz.flags & 1) != 0)
{
if (0 == (clazz.flags & FT_Common.FT_MODULE_DRIVER_NO_OUTLINES))
{
module.glyph_loader = new FT_GlyphLoader();
}
}
if (null != clazz.init)
clazz.init(module);
this.modules[mod_count] = module;
return error;
}
this.FT_Add_Default_Modules = function()
{
// drivers
var driver_tt = create_tt_driver(this);
var driver_cff = create_cff_driver(this);
var driver_t1 = create_t1_driver(this);
//var driver_cid = create_cid_driver(this);
this.FT_Add_Module(driver_tt);
this.FT_Add_Module(driver_cff);
this.FT_Add_Module(driver_t1);
//this.FT_Add_Module(driver_cid);
// modules
var mod_ps_names = create_psnames_module(this);
var mod_psaux = create_psaux_module(this);
var mod_sfnt = create_sfnt_module(this);
this.FT_Add_Module(mod_ps_names);
this.FT_Add_Module(mod_psaux);
this.FT_Add_Module(mod_sfnt);
// autohinter
this.auto_hinter = null;
// renderers
var mod_rend1 = create_renderer_smooth_module(this);
this.FT_Add_Module(mod_rend1);
}
this.ft_add_renderer = function(module)
{
var error = FT_Common.FT_Err_Ok;
var clazz = module.clazz;
module.glyph_format = clazz.glyph_format;
if ((clazz.glyph_format == FT_Common.FT_GLYPH_FORMAT_OUTLINE) && (clazz.raster_class.raster_new))
{
module.raster = new TRaster();
error = clazz.raster_class.raster_new(this.Memory, module.raster);
if (error != FT_Common.FT_Err_Ok)
return error;
module.raster_render = clazz.raster_class.raster_render;
module.render = clazz.render_glyph;
}
this.renderers[this.renderers.length] = module;
this.ft_set_current_renderer();
return error;
}
this.ft_set_current_renderer = function()
{
this.cur_renderer = null;
var count_r = this.renderers.length;
for (var i = 0; i < count_r; i++)
{
if (this.renderers[i].glyph_format == FT_Common.FT_GLYPH_FORMAT_OUTLINE)
{
this.cur_renderer = this.renderers[i];
return;
}
}
}
this.FT_Open_Face = function(args, face_index)
{
var face = null;
var external_stream = (args.stream && (args.flags & 0x02) != 0) ? true : false;
if (external_stream === true)
{
var stream = args.stream;
// пробегаем по всем драйверам - и ищем первый, который сможет открыть
var dr_len = this.modules.length;
for (var i = 0; i < dr_len; i++)
{
if (0 == (this.modules[i].clazz.flags & FT_Common.FT_MODULE_FONT_DRIVER))
continue;
var driver = this.modules[i];
face = driver.open_face(stream, face_index);
if (0 != FT_Error)
{
//#ifdef FT_CONFIG_OPTION_MAC_FONTS
if (driver.clazz.name == "truetype" && ((FT_Error & 0xFF) == FT_Common.FT_Err_Table_Missing))
{
face = this.open_face_PS_from_sfnt_stream(stream, face_index);
if (FT_Error != 0)
return null;
}
//#endif
}
else
{
break;
}
if ((FT_Error & 0xFF) != FT_Common.FT_Err_Unknown_File_Format)
{
if (((FT_Error & 0xFF) == FT_Common.FT_Err_Invalid_Stream_Operation) ||
((FT_Error & 0xFF) == FT_Common.FT_Err_Cannot_Open_Stream))
{
//#ifdef FT_CONFIG_OPTION_MAC_FONTS
face = this.load_mac_face(stream, face_index);
if (FT_Error == 0)
return face;
FT_Error = FT_Common.FT_Err_Unknown_File_Format;
face = null;
return face;
//#endif
}
}
}
if (null == face)
return face;
face.face_flags |= (1 << 10);
face.driver.faces_list[face.driver.faces_list.length] = face;
if (face_index >= 0)
{
var slot = FT_New_GlyphSlot(face);
slot = null;
if (FT_Error != 0)
{
face = null;
return null;
}
/* finally, allocate a size object for the face */
{
var size = FT_New_Size(face);
if (FT_Error != 0)
{
face = null;
return null;
}
face.size = size;
}
}
/* some checks */
if ((face.face_flags & 1) != 0)
{
if (face.height < 0)
face.height = -face.height;
if ((face.face_flags & (1 << 5)) == 0)
face.max_advance_height = face.height;
}
if ((face.face_flags & (1 << 1)) != 0)
{
var _num = face.num_fixed_sizes;
for (var i = 0; i < _num; i++)
{
var bsize = face.available_sizes[i];
if (bsize.height < 0)
bsize.height = -bsize.height;
if (bsize.x_ppem < 0)
bsize.x_ppem = -bsize.x_ppem;
if (bsize.y_ppem < 0)
bsize.y_ppem = -bsize.y_ppem;
}
}
/* initialize internal face data */
{
var internal = face.internal;
internal.transform_matrix.xx = 0x10000;
internal.transform_matrix.xy = 0;
internal.transform_matrix.yx = 0;
internal.transform_matrix.yy = 0x10000;
internal.transform_delta.x = 0;
internal.transform_delta.y = 0;
}
FT_Error = FT_Common.FT_Err_Ok;
return face;
}
// пока открываем только из уже созданного стрима
FT_Error = FT_Common.FT_Err_Invalid_Argument;
return null;
}
this.open_face_PS_from_sfnt_stream = function(stream, face_index)
{
}
this.load_mac_face = function(stream, face_index)
{
}
this.FT_Get_Module_Interface = function(name)
{
var module = this.FT_Get_Module(name);
return (null != module) ? module.clazz.module_interface : null;
}
this.FT_Get_Module = function(name)
{
var count = this.modules.length;
for (var i = 0; i < count; i++)
{
if (this.modules[i].clazz.name == name)
return this.modules[i];
}
return null;
}
}
// API
function FT_Select_Size(face, strike_index)
{
if (!face || (face.face_flags & FT_Common.FT_FACE_FLAG_FIXED_SIZES) == 0)
return FT_Common.FT_Err_Invalid_Face_Handle;
if (strike_index < 0 || strike_index >= face.num_fixed_sizes)
return FT_Common.FT_Err_Invalid_Argument;
var clazz = face.driver.clazz;
if (clazz.select_size)
{
return clazz.select_size(face.size, strike_index);
}
FT_Select_Metrics(face, strike_index);
return FT_Common.FT_Err_Ok;
}
function FT_Select_Metrics(face, strike_index)
{
var metrics = face.size.metrics;
var bsize = face.available_sizes[strike_index];
metrics.x_ppem = (FT_Common.IntToUInt(bsize.x_ppem + 32) >>> 6) & 0xFFFF;
metrics.y_ppem = (FT_Common.IntToUInt(bsize.y_ppem + 32) >>> 6) & 0xFFFF;
if ((face.face_flags & FT_Common.FT_FACE_FLAG_SCALABLE) != 0)
{
metrics.x_scale = FT_DivFix(bsize.x_ppem, face.units_per_EM);
metrics.y_scale = FT_DivFix(bsize.y_ppem, face.units_per_EM);
ft_recompute_scaled_metrics(face, metrics);
}
else
{
metrics.x_scale = 1 << 16;
metrics.y_scale = 1 << 16;
metrics.ascender = bsize.y_ppem;
metrics.descender = 0;
metrics.height = bsize.height << 6;
metrics.max_advance = bsize.x_ppem;
}
}
function ft_recompute_scaled_metrics(face, metrics)
{
metrics.ascender = FT_PIX_CEIL(FT_MulFix(face.ascender, metrics.y_scale));
metrics.descender = FT_PIX_FLOOR(FT_MulFix(face.descender, metrics.y_scale));
metrics.height = FT_PIX_ROUND(FT_MulFix(face.height, metrics.y_scale));
metrics.max_advance = FT_PIX_ROUND(FT_MulFix(face.max_advance_width, metrics.x_scale));
}
function FT_Request_Size(face, req)
{
var strike_index = 0;
if (!face)
return FT_Common.FT_Err_Invalid_Face_Handle;
if (!req || req.width < 0 || req.height < 0 || req.type >= FT_Common.FT_SIZE_REQUEST_TYPE_MAX)
return FT_Common.FT_Err_Invalid_Argument;
var clazz = face.driver.clazz;
if (clazz.request_size)
{
return clazz.request_size(face.size, req);
}
if (((face.face_flags & FT_Common.FT_FACE_FLAG_SCALABLE) == 0) && ((face.face_flags & FT_Common.FT_FACE_FLAG_FIXED_SIZES) != 0))
{
FT_Error = FT_Common.FT_Err_Ok;
strike_index = FT_Match_Size(face, req, 0);
var error = FT_Error;
FT_Error = FT_Common.FT_Err_Ok;
if (error != FT_Common.FT_Err_Ok)
return error;
return FT_Select_Size(face, strike_index);
}
FT_Request_Metrics(face, req);
return FT_Common.FT_Err_Ok;
}
function FT_Request_Metrics(face, req)
{
var metrics = face.size.metrics;
if ((face.face_flags & FT_Common.FT_FACE_FLAG_SCALABLE) != 0)
{
var w = 0, h = 0, scaled_w = 0, scaled_h = 0;
switch (req.type)
{
case FT_Common.FT_SIZE_REQUEST_TYPE_NOMINAL:
w = h = face.units_per_EM;
break;
case FT_Common.FT_SIZE_REQUEST_TYPE_REAL_DIM:
w = h = face.ascender - face.descender;
break;
case FT_Common.FT_SIZE_REQUEST_TYPE_BBOX:
w = face.bbox.xMax - face.bbox.xMin;
h = face.bbox.yMax - face.bbox.yMin;
break;
case FT_Common.FT_SIZE_REQUEST_TYPE_CELL:
w = face.max_advance_width;
h = face.ascender - face.descender;
break;
case FT_Common.FT_SIZE_REQUEST_TYPE_SCALES:
metrics.x_scale = req.width;
metrics.y_scale = req.height;
if (metrics.x_scale == 0)
metrics.x_scale = metrics.y_scale;
else if (metrics.y_scale == 0)
metrics.y_scale = metrics.x_scale;
scaled_w = FT_MulFix(face.units_per_EM, metrics.x_scale);
scaled_h = FT_MulFix(face.units_per_EM, metrics.y_scale);
metrics.x_ppem = (FT_Common.IntToUInt(scaled_w + 32) >>> 6) & 0xFFFF;
metrics.y_ppem = (FT_Common.IntToUInt(scaled_h + 32) >>> 6) & 0xFFFF;
ft_recompute_scaled_metrics( face, metrics );
return;
case FT_Common.FT_SIZE_REQUEST_TYPE_MAX:
break;
}
/* to be on the safe side */
if (w < 0)
w = -w;
if (h < 0)
h = -h;
scaled_w = FT_REQUEST_WIDTH(req);
scaled_h = FT_REQUEST_HEIGHT(req);
if (req.width != 0)
{
metrics.x_scale = FT_DivFix(scaled_w, w);
if (req.height != 0)
{
metrics.y_scale = FT_DivFix(scaled_h, h);
if (req.type == FT_Common.FT_SIZE_REQUEST_TYPE_CELL)
{
if (metrics.y_scale > metrics.x_scale)
metrics.y_scale = metrics.x_scale;
else
metrics.x_scale = metrics.y_scale;
}
}
else
{
metrics.y_scale = metrics.x_scale;
scaled_h = FT_MulDiv(scaled_w, h, w);
}
}
else
{
metrics.x_scale = metrics.y_scale = FT_DivFix(scaled_h, h);
scaled_w = FT_MulDiv(scaled_h, w, h);
}
if (req.type != FT_Common.FT_SIZE_REQUEST_TYPE_NOMINAL)
{
scaled_w = FT_MulFix(face.units_per_EM, metrics.x_scale);
scaled_h = FT_MulFix(face.units_per_EM, metrics.y_scale);
}
metrics.x_ppem = (FT_Common.IntToUInt(scaled_w + 32) >>> 6) & 0xFFFF;
metrics.y_ppem = (FT_Common.IntToUInt(scaled_h + 32) >>> 6) & 0xFFFF;
ft_recompute_scaled_metrics(face, metrics);
}
else
{
metrics.x_ppem = 0;
metrics.y_ppem = 0;
metrics.ascender = 0;
metrics.descender = 0;
metrics.height = 0;
metrics.max_advance = 0;
metrics.x_scale = 1 << 16;
metrics.y_scale = 1 << 16;
}
}
function FT_REQUEST_WIDTH(req)
{
return (req.horiResolution != 0) ? parseInt((req.width * req.horiResolution + 36) / 72) : req.width;
}
function FT_REQUEST_HEIGHT(req)
{
return (req.vertResolution != 0) ? parseInt((req.height * req.vertResolution + 36) / 72) : req.height;
}
function FT_Match_Size(face, req, ignore_width)
{
if ((face.face_flags & FT_Common.FT_FACE_FLAG_FIXED_SIZES) == 0)
{
FT_Error = FT_Common.FT_Err_Invalid_Face_Handle;
return 0;
}
if (req.type != FT_Common.FT_SIZE_REQUEST_TYPE_NOMINAL)
{
FT_Error = FT_Common.FT_Err_Unimplemented_Feature;
return 0;
}
var w = FT_REQUEST_WIDTH(req);
var h = FT_REQUEST_HEIGHT(req);
if (req.width != 0 && req.height == 0)
h = w;
else if (req.width == 0 && req.height != 0)
w = h;
w = FT_PIX_ROUND(w);
h = FT_PIX_ROUND(h);
var num_fs = face.num_fixed_sizes;
for (var i = 0; i < num_fs; i++)
{
var bsize = face.available_sizes[i];
if (h != FT_PIX_ROUND(bsize.y_ppem))
continue;
if (w == FT_PIX_ROUND(bsize.x_ppem) || (ignore_width != 0))
{
FT_Error = 0;
return i;
}
}
FT_Error = FT_Common.FT_Err_Invalid_Pixel_Size;
return 0;
}
function FT_Set_Char_Size(face, char_width, char_height, horz_resolution, vert_resolution)
{
var req = new FT_Size_RequestRec();
if (0 == char_width)
char_width = char_height;
else if (0 == char_height)
char_height = char_width;
if (0 == horz_resolution)
horz_resolution = vert_resolution;
else if (0 == vert_resolution)
vert_resolution = horz_resolution;
if (char_width < 64)
char_width = 64;
if (char_height < 64)
char_height = 64;
if (0 == horz_resolution)
horz_resolution = vert_resolution = 72;
req.type = FT_Common.FT_SIZE_REQUEST_TYPE_NOMINAL;
req.width = char_width;
req.height = char_height;
req.horiResolution = horz_resolution;
req.vertResolution = vert_resolution;
return FT_Request_Size(face, req);
}
function FT_Set_Pixel_Sizes(face, pixel_width, pixel_height)
{
var req = new FT_Size_RequestRec();
if (pixel_width == 0)
pixel_width = pixel_height;
else if (pixel_height == 0)
pixel_height = pixel_width;
if (pixel_width < 1)
pixel_width = 1;
if (pixel_height < 1)
pixel_height = 1;
/* use `>=' to avoid potential compiler warning on 16bit platforms */
if (pixel_width >= 0xFFFF)
pixel_width = 0xFFFF;
if (pixel_height >= 0xFFFF)
pixel_height = 0xFFFF;
req.type = FT_Common.FT_SIZE_REQUEST_TYPE_NOMINAL;
req.width = pixel_width << 6;
req.height = pixel_height << 6;
req.horiResolution = 0;
req.vertResolution = 0;
return FT_Request_Size(face, req);
}
function FT_Get_First_Char(face)
{
var result = {gindex:0,char_code:0};
if (face && face.charmap && face.num_glyphs != 0)
{
result.gindex = FT_Get_Char_Index(face, 0);
if (result.gindex == 0 || result.gindex >= face.num_glyphs)
result = FT_Get_Next_Char(face, 0);
}
return result;
}
function FT_Get_Next_Char(face, charcode)
{
var result = {gindex:0,char_code:0};
if (face && face.charmap && face.num_glyphs != 0)
{
var code = charcode;
var cmap = face.charmap;
var _cmap = __FT_CMapRec(cmap);
do
{
var _clazz = _cmap.clazz.clazz;
if (undefined == _clazz)
_clazz = _cmap.clazz;
result = _clazz.char_next(cmap, code);
code = result.char_code;
} while (result.gindex >= face.num_glyphs);
result.char_code = (result.gindex == 0) ? 0 : code;
}
return result;
}
function FT_Get_Char_Index(face, charcode)
{
var result = 0;
if (face && face.charmap)
{
var _clazz = __FT_CMapRec(face.charmap).clazz;
if (undefined != _clazz.clazz)
_clazz = _clazz.clazz;
result = _clazz.char_index(face.charmap, charcode);
}
return result;
}
function FT_Get_Charmap_Index(charmap)
{
if (!charmap || !charmap.face)
return -1;
var i = 0;
for (; i < charmap.face.num_charmaps; i++)
if (charmap.face.charmaps[i] == charmap)
break;
//#ifdef FT_MAX_CHARMAP_CACHEABLE
if (i > 15)
return -i;
//#endif
return i;
}
function FT_Set_Charmap(face, cmap)
{
if (!face)
return FT_Common.FT_Err_Invalid_Face_Handle;
var len = face.num_charmaps;
if (0 == len)
return FT_Common.FT_Err_Invalid_CharMap_Handle;
if (FT_Get_CMap_Format(cmap) == 14)
return FT_Common.FT_Err_Invalid_Argument;
for (var i = 0; i < len; i++)
{
if (face.charmaps[i] == cmap)
{
//#ifdef FT_MAX_CHARMAP_CACHEABLE
if (i > 15)
continue;
//#endif
face.charmap = face.charmaps[i];
return 0;
}
}
return FT_Common.FT_Err_Invalid_Argument;
}
function FT_Get_CMap_Format(cmap)
{
var charmap = __FT_CharmapRec(cmap);
if (!charmap || !charmap.face)
return -1;
var service = FT_FACE_FIND_SERVICE(charmap.face, "tt-cmaps");
if (service == null)
return -1;
var cmap_info = new TT_CMapInfo();
service.get_cmap_info(cmap, cmap_info);
if (FT_Error != 0)
return -1;
return cmap_info.format;
}
function FT_Glyph_Get_CBox(glyph, bbox_mode, acbox)
{
acbox.xMin = acbox.yMin = acbox.xMax = acbox.yMax = 0;
if (!glyph || !glyph.clazz)
return;
var clazz = glyph.clazz;
if (!clazz.glyph_bbox)
return;
clazz.glyph_bbox(glyph, acbox);
if (bbox_mode == FT_Common.FT_GLYPH_BBOX_GRIDFIT || bbox_mode == FT_Common.FT_GLYPH_BBOX_PIXELS)
{
acbox.xMin = FT_PIX_FLOOR(acbox.xMin);
acbox.yMin = FT_PIX_FLOOR(acbox.yMin);
acbox.xMax = FT_PIX_CEIL(acbox.xMax);
acbox.yMax = FT_PIX_CEIL(acbox.yMax);
}
if (bbox_mode == FT_Common.FT_GLYPH_BBOX_TRUNCATE || bbox_mode == FT_Common.FT_GLYPH_BBOX_PIXELS)
{
acbox.xMin >>= 6;
acbox.yMin >>= 6;
acbox.xMax >>= 6;
acbox.yMax >>= 6;
}
}
function FT_Get_Glyph(slot)
{
FT_Error = 0;
var clazz = null;
if (!slot)
return FT_Common.FT_Err_Invalid_Slot_Handle;
if (slot.format == FT_Common.FT_GLYPH_FORMAT_BITMAP)
clazz = ft_bitmap_glyph_class;
else if (slot.format == FT_Common.FT_GLYPH_FORMAT_OUTLINE)
clazz = ft_outline_glyph_class;
else
{
var render = FT_Lookup_Renderer(slot.library, slot.format);
if (render)
clazz = render.glyph_class;
}
if (!clazz)
{
FT_Error = FT_Common.FT_Err_Invalid_Glyph_Format;
return null;
}
var glyph = ft_new_glyph(slot.library, clazz);
if (FT_Error != 0)
return null;
glyph.advance.x = slot.advance.x << 10;
glyph.advance.y = slot.advance.y << 10;
FT_Error = clazz.glyph_init(glyph, slot);
if (FT_Error != 0)
{
FT_Done_Glyph(glyph);
glyph = null;
}
else
return glyph;
return null;
}
function FT_Done_Glyph(glyph)
{
return 0;
}
function FT_Get_Name_Index(face, glyph_name)
{
if (face && ((face.face_flags & FT_Common.FT_FACE_FLAG_GLYPH_NAMES) != 0))
{
var service = face.internal.services.service_GLYPH_DICT;
if (null != service)
service = FT_FACE_FIND_SERVICE(face, "glyph-dict");
if (service && service.name_index)
return service.name_index(face, glyph_name);
}
return 0;
}
function FT_Get_Glyph_Name(face, glyph_index, buffer, buffer_max)
{
if (face && (glyph_index <= face.num_glyphs) && ((face.face_flags & FT_Common.FT_FACE_FLAG_GLYPH_NAMES) != 0))
{
var service = face.internal.services.service_GLYPH_DICT;
if (null != service)
service = FT_FACE_FIND_SERVICE(face, "glyph-dict");
if (service && service.get_name)
return service.get_name(face, glyph_index, buffer, buffer_max);
}
return 0;
}
function FT_Get_X11_Font_Format(face)
{
if (face)
return FT_FACE_FIND_SERVICE(face, "xf86-driver-name");
return null;
}
function FT_Lookup_Renderer(library, format)
{
var r = library.renderers;
var c = r.length;
for (var i = 0; i < c; i++)
{
if (r[i].glyph_format == format)
return r[i];
}
return null;
}
function FT_Set_Renderer(library, renderer)
{
if (!library)
return FT_Common.FT_Err_Invalid_Library_Handle;
if (!renderer)
return FT_Common.FT_Err_Invalid_Argument;
if (renderer.glyph_format == FT_Common.FT_GLYPH_FORMAT_OUTLINE)
library.cur_renderer = renderer;
return 0;
}
function ft_lookup_glyph_renderer(slot)
{
var library = slot.library;
var res = library.cur_renderer;
if (!res || (res.glyph_format != slot.format))
res = FT_Lookup_Renderer(library, slot.format);
return res;
}
function ft_set_current_renderer(library)
{
library.cur_renderer = FT_Lookup_Renderer(library, FT_Common.FT_GLYPH_FORMAT_OUTLINE);
}
function FT_Load_Glyph(face, glyph_index, load_flags)
{
if (!face || !face.size || !face.glyph)
return FT_Common.FT_Err_Invalid_Face_Handle;
var slot = face.glyph;
ft_glyphslot_clear(slot);
var driver = face.driver;
var library = driver.library;
var hinter = library.auto_hinter;
var autohint = false;
/* resolve load flags dependencies */
if (load_flags & FT_Common.FT_LOAD_NO_RECURSE)
load_flags |= (FT_Common.FT_LOAD_NO_SCALE | FT_Common.FT_LOAD_IGNORE_TRANSFORM);
if (load_flags & FT_Common.FT_LOAD_NO_SCALE)
{
load_flags |= (FT_Common.FT_LOAD_NO_HINTING | FT_Common.FT_LOAD_NO_BITMAP);
load_flags &= ~FT_Common.FT_LOAD_RENDER;
}
// if (hinter && ...){}
// TODO:
if (true === autohint)
{
// TODO:
}
else
{
var error = driver.clazz.load_glyph(slot, face.size, glyph_index, load_flags);
if (error != FT_Common.FT_Err_Ok)
return error;
if (slot.format == FT_Common.FT_GLYPH_FORMAT_OUTLINE)
{
/* check that the loaded outline is correct */
error = FT_Outline_Check(slot.outline);
if (error != FT_Common.FT_Err_Ok)
return error;
//#ifdef GRID_FIT_METRICS
if (0 == (load_flags & FT_Common.FT_LOAD_NO_HINTING))
ft_glyphslot_grid_fit_metrics( slot, ((load_flags & FT_Common.FT_LOAD_VERTICAL_LAYOUT) != 0) ? true : false);
//#endif
}
}
/* compute the advance */
if (0 != (load_flags & FT_Common.FT_LOAD_VERTICAL_LAYOUT))
{
slot.advance.x = 0;
slot.advance.y = slot.metrics.vertAdvance;
}
else
{
slot.advance.x = slot.metrics.horiAdvance;
slot.advance.y = 0;
}
/* compute the linear advance in 16.16 pixels */
if ((load_flags & FT_Common.FT_LOAD_LINEAR_DESIGN) == 0 && (0 != (face.face_flags & FT_Common.FT_FACE_FLAG_SCALABLE)))
{
var metrics = face.size.metrics;
/* it's tricky! */
slot.linearHoriAdvance = FT_MulDiv(slot.linearHoriAdvance, metrics.x_scale, 64);
slot.linearVertAdvance = FT_MulDiv(slot.linearVertAdvance, metrics.y_scale, 64);
}
if ((load_flags & FT_Common.FT_LOAD_IGNORE_TRANSFORM) == 0)
{
var internal = face.internal;
/* now, transform the glyph image if needed */
if (internal.transform_flags != 0)
{
/* get renderer */
var renderer = ft_lookup_glyph_renderer(slot);
if (renderer != null)
error = renderer.clazz.transform_glyph(renderer, slot, internal.transform_matrix, internal.transform_delta);
else if (slot.format == FT_Common.FT_GLYPH_FORMAT_OUTLINE)
{
/* apply `standard' transformation if no renderer is available */
if ((internal.transform_flags & 1) != 0)
FT_Outline_Transform(slot.outline, internal.transform_matrix);
if ((internal.transform_flags & 2) != 0)
FT_Outline_Translate(slot.outline, internal.transform_delta.x, internal.transform_delta.y);
}
/* transform advance */
FT_Vector_Transform(slot.advance, internal.transform_matrix);
}
}
/* do we need to render the image now? */
if ((error == 0) && (slot.format != FT_Common.FT_GLYPH_FORMAT_BITMAP) && (slot.format != FT_Common.FT_GLYPH_FORMAT_COMPOSITE) && ((load_flags & FT_Common.FT_LOAD_RENDER) != 0))
{
var mode = FT_LOAD_TARGET_MODE(load_flags);
if (mode == FT_Common.FT_RENDER_MODE_NORMAL && (load_flags & FT_Common.FT_LOAD_MONOCHROME))
mode = FT_Common.FT_RENDER_MODE_MONO;
error = FT_Render_Glyph(slot, mode);
}
return error;
}
function FT_Load_Char(face, char_code, load_flags)
{
var glyph_index = 0;
if ( !face )
return FT_Common.FT_Err_Invalid_Face_Handle;
glyph_index = char_code;
if (face.charmap)
glyph_index = FT_Get_Char_Index(face, char_code);
return FT_Load_Glyph(face, glyph_index, load_flags);
}
function FT_Set_Transform(face, matrix, delta)
{
if (!face)
return;
var internal = face.internal;
internal.transform_flags = 0;
var m = internal.transform_matrix;
if (!matrix)
{
m.xx = 0x10000;
m.xy = 0;
m.yx = 0;
m.yy = 0x10000;
}
else
{
m.xx = matrix.xx;
m.xy = matrix.xy;
m.yx = matrix.yx;
m.yy = matrix.yy;
}
/* set transform_flags bit flag 0 if `matrix' isn't the identity */
if ((m.xy | m.yx) != 0 || m.xx != 0x10000 || m.yy != 0x10000)
internal.transform_flags |= 1;
var d = internal.transform_delta;
if (!delta)
{
d.x = 0;
d.y = 0;
}
else
{
d.x = delta.x;
d.y = delta.y;
}
/* set transform_flags bit flag 1 if `delta' isn't the null vector */
if ((d.x | d.y) != 0)
internal.transform_flags |= 2;
}
function FT_Render_Glyph(slot, render_mode)
{
if (!slot || !slot.face)
return FT_Common.FT_Err_Invalid_Argument;
var library = slot.library;
return FT_Render_Glyph_Internal(library, slot, render_mode);
}
function FT_Render_Glyph_Internal(library, slot, render_mode)
{
var error = FT_Common.FT_Err_Ok;
var renderer = null;
var update = false;
/* if it is already a bitmap, no need to do anything */
switch (slot.format)
{
case FT_Common.FT_GLYPH_FORMAT_BITMAP: /* already a bitmap, don't do anything */
break;
default:
{
/* small shortcut for the very common case */
if (slot.format == FT_Common.FT_GLYPH_FORMAT_OUTLINE)
{
renderer = library.cur_renderer;
}
else
{
renderer = FT_Lookup_Renderer(library, slot.format);
}
error = FT_Common.FT_Err_Unimplemented_Feature;
while (renderer != null)
{
error = renderer.render(renderer, slot, render_mode, null);
if ((error == 0) || ((error & 0xFF) != FT_Common.FT_Err_Cannot_Render_Glyph))
break;
renderer = FT_Lookup_Renderer(library, slot.format);
update = true;
}
if (error == 0 && update && renderer)
FT_Set_Renderer(library, renderer);
}
}
return error;
}
function FT_Get_Kerning(face, left_glyph, right_glyph, kern_mode, akerning)
{
var error = FT_Common.FT_Err_Ok;
if (!face)
return FT_Common.FT_Err_Invalid_Face_Handle;
if (!akerning)
return FT_Common.FT_Err_Invalid_Argument;
var driver = face.driver;
akerning.x = 0;
akerning.y = 0;
if (driver.clazz.get_kerning)
{
error = driver.clazz.get_kerning(face, left_glyph, right_glyph, akerning);
if (error == FT_Common.FT_Err_Ok)
{
if (kern_mode != FT_Common.FT_KERNING_UNSCALED)
{
akerning.x = FT_MulFix(akerning.x, face.size.metrics.x_scale);
akerning.y = FT_MulFix(akerning.y, face.size.metrics.y_scale);
if (kern_mode != FT_Common.FT_KERNING_UNFITTED)
{
if (face.size.metrics.x_ppem < 25)
akerning.x = FT_MulDiv(akerning.x, face.size.metrics.x_ppem, 25);
if (face.size.metrics.y_ppem < 25)
akerning.y = FT_MulDiv(akerning.y, face.size.metrics.y_ppem, 25);
akerning.x = FT_PIX_ROUND(akerning.x);
akerning.y = FT_PIX_ROUND(akerning.y);
}
}
}
}
return error;
}
function FT_New_GlyphSlot(face)
{
if (!face || !face.driver)
return FT_Common.FT_Err_Invalid_Argument;
var slot = null;
var _slot = null;
if (face.driver.clazz.name == "type1")
{
_slot = new T1_GlyphSlotRec();
slot = _slot.root;
}
else
{
_slot = new FT_GlyphSlot();
slot = _slot;
}
slot.face = face;
FT_Error = ft_glyphslot_init(slot);
if (FT_Error != 0)
{
ft_glyphslot_done(slot);
return null;
}
slot.next = face.glyph;
face.glyph = slot;
return slot;
}
function FT_GlyphLoader_New(memory)
{
var loader = new FT_GlyphLoader();
loader.memory = memory;
return loader;
}
function ft_glyphslot_done(slot)
{
return 0;
}
function FT_New_Size(face)
{
if (!face)
return FT_Common.FT_Err_Invalid_Face_Handle;
if (!face.driver)
return FT_Common.FT_Err_Invalid_Driver_Handle;
var size = null;
var clazz = face.driver.clazz;
FT_Error = 0;
if (clazz.init_size)
{
size = clazz.init_size();
}
size.face = face;
if (FT_Error == 0)
{
face.sizes_list[face.sizes_list.length] = size;
return size;
}
return null;
}
function FT_CMap_New(clazz, init_data, charmap)
{
FT_Error = 0;
if (clazz == null || charmap == null || charmap.face == null)
{
FT_Error = FT_Common.FT_Err_Invalid_Argument;
return null;
}
var _clazz = clazz.clazz;
var face = charmap.face;
var cmap = null;
if (undefined != clazz.format)
{
switch (clazz.format)
{
case 4:
cmap = new TT_CMap4Rec();
break;
case 12:
cmap = new TT_CMap12Rec();
break;
case 13:
cmap = new TT_CMap13Rec();
break;
case 14:
cmap = new TT_CMap14Rec();
break;
default:
cmap = new TT_CMapRec();
break;
}
}
else
{
switch (clazz.size)
{
case 101:
case 102:
cmap = new CFF_CMapStdRec();
break;
default:
cmap = new TT_CMapRec();
}
}
var cmap_ = __FT_CMapRec(cmap);
if (undefined == _clazz)
_clazz = clazz;
if (null != cmap)
{
var charmap_= cmap_.charmap;
charmap_.face = charmap.face;
charmap_.encoding = charmap.encoding;
charmap_.platform_id = charmap.platform_id;
charmap_.encoding_id = charmap.encoding_id;
cmap_.clazz = clazz;
if (clazz.init != 0)
{
var error = _clazz.init(cmap, init_data);
if (error != 0)
{
FT_Error = error;
cmap = null;
cmap_ = null;
return null;
}
}
if (null == face.charmaps)
face.charmaps = new Array(1);
face.charmaps[face.num_charmaps++] = cmap;
}
return cmap;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
function CRasterMemory()
{
this.width = 0;
this.height = 0;
this.pitch = 0;
this.m_oBuffer = null;
this.CheckSize = function(w, h)
{
if (this.width < (w + 1) || this.height < (h + 1))
{
this.width = Math.max(this.width, w + 1);
this.pitch = 4 * this.width;
this.height = Math.max(this.height, h + 1);
this.m_oBuffer = null;
this.m_oBuffer = g_memory.ctx.createImageData(this.width, this.height);
}
}
}
var raster_memory = new CRasterMemory();
// outline ---
function _FT_Outline_Funcs_Gray()
{
this.move_to = function(to, worker)
{
/* record current cell, if any */
var err = gray_record_cell(worker);
if (err == FT_Common.ErrorLongJump)
return FT_Common.ErrorLongJump;
/* start to a new position */
var x = to.x << 2;
var y = to.y << 2;
err = gray_start_cell(worker, x >> 8, y >> 8);
worker.x = x;
worker.y = y;
return err;
}
this.line_to = function(to, worker)
{
return gray_render_line(worker, to.x << 2, to.y << 2);
}
this.conic_to = function(control, to, worker)
{
return gray_render_conic(worker, control, to);
}
this.cubic_to = function(control1, control2, to, worker)
{
return gray_render_cubic(worker, control1, control2, to);
}
this.shift = 0;
this.delta = 0;
}
var ft_outline_funcs_gray = new _FT_Outline_Funcs_Gray();
function FT_Outline_Decompose(outline, func_interface, user)
{
if (!outline || !func_interface)
return FT_Common.FT_Err_Invalid_Argument;
var v_last = new FT_Vector();
var v_control = new FT_Vector();
var v_start = new FT_Vector();
var point;
var limit;
var tags = 0;
var first = 0;
var tag = 0;
var shift = func_interface.shift;
var delta = func_interface.delta;
var error = 0;
var count = outline.n_contours;
var _c = outline.contours;
var _p = outline.points;
var _t = outline.tags;
for (var n = 0; n < count; n++)
{
var last = _c[n];
if (last < 0)
return FT_Common.FT_Err_Invalid_Outline;
limit = last;
v_start.x = (_p[first].x << shift) - delta;
v_start.y = (_p[first].y << shift) - delta;
v_last.x = (_p[last].x << shift) - delta;
v_last.y = (_p[last].y << shift) - delta;
v_control.x = v_start.x;
v_control.y = v_start.y;
point = first;
tags = first;
tag = _t[tags] & 3;
/* A contour cannot start with a cubic control point! */
if (tag == FT_Common.FT_CURVE_TAG_CUBIC)
return FT_Common.FT_Err_Invalid_Outline;
/* check first point to determine origin */
if (tag == FT_Common.FT_CURVE_TAG_CONIC)
{
/* first point is conic control. Yes, this happens. */
if ((_t[last] & 3) == FT_Common.FT_CURVE_TAG_ON)
{
/* start at last point if it is on the curve */
v_start.x = v_last.x;
v_start.y = v_last.y;
limit--;
}
else
{
/* if both first and last points are conic, */
/* start at their middle and record its position */
/* for closure */
v_start.x = parseInt((v_start.x + v_last.x) / 2);
v_start.y = parseInt((v_start.y + v_last.y) / 2);
v_last.x = v_start.x;
v_last.y = v_start.y;
}
point--;
tags--;
}
error = func_interface.move_to(v_start, user);
if (error != 0)
return error;
var isClose = 0;
while (point < limit)
{
point++;
tags++;
tag = _t[tags] & 3;
switch ( tag )
{
case FT_Common.FT_CURVE_TAG_ON: /* emit a single line_to */
{
var vec = new FT_Vector();
vec.x = (_p[point].x << shift) - delta;
vec.y = (_p[point].y << shift) - delta;
error = func_interface.line_to(vec, user);
if (0 != error)
return error;
continue;
}
case FT_Common.FT_CURVE_TAG_CONIC: /* consume conic arcs */
v_control.x = (_p[point].x << shift) - delta;
v_control.y = (_p[point].y << shift) - delta;
var isCont = 0;
while (true)
{
if (point < limit)
{
var vec = new FT_Vector();
var v_middle = new FT_Vector();
point++;
tags++;
tag = _t[tags] & 3;
vec.x = (_p[point].x << shift) - delta;
vec.y = (_p[point].y << shift) - delta;
if (tag == FT_Common.FT_CURVE_TAG_ON)
{
error = func_interface.conic_to(v_control, vec, user);
if (0 != error)
return error;
isCont = 1;
break;
}
if (tag != FT_Common.FT_CURVE_TAG_CONIC)
return FT_Common.FT_Err_Invalid_Outline;
v_middle.x = parseInt((v_control.x + vec.x) / 2);
v_middle.y = parseInt((v_control.y + vec.y) / 2);
error = func_interface.conic_to(v_control, v_middle, user);
if (0 != error)
return error;
v_control.x = vec.x;
v_control.y = vec.y;
continue;
}
break;
}
if (1 == isCont/* && (point < limit)*/)
continue;
error = func_interface.conic_to(v_control, v_start, user);
isClose = 1;
break;
default: /* FT_CURVE_TAG_CUBIC */
{
var vec1 = new FT_Vector();
var vec2 = new FT_Vector();
if ((point + 1 > limit) || (_t[tags+1]&3) != FT_Common.FT_CURVE_TAG_CUBIC)
return FT_Common.FT_Err_Invalid_Outline;
point += 2;
tags += 2;
vec1.x = (_p[point-2].x << shift) - delta;
vec1.y = (_p[point-2].y << shift) - delta;
vec2.x = (_p[point-1].x << shift) - delta;
vec2.y = (_p[point-1].y << shift) - delta;
if (point <= limit)
{
var vec = new FT_Vector();
vec.x = (_p[point].x << shift) - delta;
vec.y = (_p[point].y << shift) - delta;
error = func_interface.cubic_to(vec1, vec2, vec, user);
if (0 != error)
return error;
continue;
}
error = func_interface.cubic_to(vec1, vec2, v_start, user);
isClose = 1;
break;
}
}
if (isClose == 1)
break;
}
if (error != 0)
return error;
/* close the contour with a line segment */
if (0 == isClose)
error = func_interface.line_to(v_start, user);
if (error != 0)
return error;
isClose = 0;
first = last + 1;
}
return 0;
}
function FT_Outline_Get_Orientation(outline)
{
if (outline == null || outline.n_points <= 0)
return FT_Common.FT_ORIENTATION_TRUETYPE;
/* We use the nonzero winding rule to find the orientation. */
/* Since glyph outlines behave much more `regular' than arbitrary */
/* cubic or quadratic curves, this test deals with the polygon */
/* only which is spanned up by the control points. */
var points = outline.points;
var v_cur;
var first = 0;
var area = 0;
for (var c = 0; c < outline.n_contours; c++)
{
var last = outline.contours[c];
var v_prev = points[last];
for (var n = first; n <= last; n++)
{
v_cur = points[n];
area += (v_cur.y - v_prev.y) * (v_cur.x + v_prev.x);
v_prev = v_cur;
}
first = last + 1;
}
if (area > 0)
return FT_Common.FT_ORIENTATION_POSTSCRIPT;
else if ( area < 0 )
return FT_Common.FT_ORIENTATION_TRUETYPE;
return FT_Common.FT_ORIENTATION_NONE;
}
function FT_Outline_Get_Orientation_Cur(outline, base)
{
if (outline == null || outline.n_points <= 0)
return FT_Common.FT_ORIENTATION_TRUETYPE;
/* We use the nonzero winding rule to find the orientation. */
/* Since glyph outlines behave much more `regular' than arbitrary */
/* cubic or quadratic curves, this test deals with the polygon */
/* only which is spanned up by the control points. */
var points = base.points;
var contours = base.contours;
var _p_off = outline.points;
var _c_off = outline.contours;
var v_prev = new FT_Vector();
var v_cur = new FT_Vector();
var first = 0;
var area = 0;
for (var c = 0; c < outline.n_contours; c++)
{
var last = contours[_c_off + c];
v_prev.x = points[_p_off + last].x;
v_prev.y = points[_p_off + last].y;
for (var n = first; n <= last; n++)
{
v_cur.x = points[_p_off + n].x;
v_cur.y = points[_p_off + n].y;
area += (v_cur.y - v_prev.y) * (v_cur.x + v_prev.x);
v_prev.x = v_cur.x;
v_prev.y = v_cur.y;
}
first = last + 1;
}
if (area > 0)
return FT_Common.FT_ORIENTATION_POSTSCRIPT;
else if ( area < 0 )
return FT_Common.FT_ORIENTATION_TRUETYPE;
return FT_Common.FT_ORIENTATION_NONE;
}
function ft_trig_prenorm(vec)
{
var x = vec.x;
var y = vec.y;
var z = ((x >= 0) ? x : - x) | ((y >= 0) ? y : -y);
var shift = 0;
/* determine msb bit index in `shift' */
if (z >= (1 << 16))
{
z >>= 16;
shift += 16;
}
if (z >= (1 << 8))
{
z >>= 8;
shift += 8;
}
if (z >= (1 << 4))
{
z >>= 4;
shift += 4;
}
if (z >= (1 << 2))
{
z >>= 2;
shift += 2;
}
if (z >= (1 << 1))
{
z >>= 1;
shift += 1;
}
if (shift <= 27)
{
shift = 27 - shift;
vec.x = x << shift;
vec.y = y << shift;
}
else
{
shift -= 27;
vec.x = x >> shift;
vec.y = y >> shift;
shift = -shift;
}
return shift;
}
var ft_trig_arctan_table = [2949120, 1740967, 919879, 466945, 234379, 117304, 58666, 29335, 14668, 7334,
3667, 1833, 917, 458, 229, 115, 57, 29, 14, 7, 4, 2, 1];
function ft_trig_pseudo_polarize(vec)
{
var x = vec.x;
var y = vec.y;
/* Get the vector into the right half plane */
var theta = 0;
if (x < 0)
{
x = -x;
y = -y;
theta = 2 * FT_Common.FT_ANGLE_PI2;
}
if (y > 0)
theta = - theta;
var arctanptr = 0;
var xtemp = 0;
/* Pseudorotations, with right shifts */
i = 0;
do
{
if ( y > 0 )
{
xtemp = x + (y >> i);
y = y - (x >> i);
x = xtemp;
theta += ft_trig_arctan_table[arctanptr++];
}
else
{
xtemp = x - (y >> i);
y = y + (x >> i);
x = xtemp;
theta -= ft_trig_arctan_table[arctanptr++];
}
} while (++i < FT_Common.FT_TRIG_MAX_ITERS);
/* round theta */
if (theta >= 0)
theta = ((theta + 16) & ~31);
else
theta = -((-theta + 16) & ~31);
vec.x = x;
vec.y = theta;
}
function ft_trig_downscale(val)
{
var s = val;
val = (val >= 0) ? val : -val;
var v1 = FT_Common.IntToUInt(val >> 16);
var v2 = FT_Common.IntToUInt(val & 0xFFFF);
var k1 = 0x9B74; /* constant */
var k2 = 0xEDA8; /* constant */
var hi = k1 * v1;
var lo1 = k1 * v2 + k2 * v1; /* can't overflow */
var lo2 = ( k2 * v2 ) / 65536;
lo2 = lo2 >> 0;
var lo3 = ( lo1 >= lo2 ) ? lo1 : lo2;
lo1 += lo2;
lo1 = FT_Common.IntToUInt(lo1);
hi += lo1 >> 16;
if (lo1 < lo3)
hi += 0x10000;
val = hi;
val = FT_Common.UintToInt(val);
return (s >= 0) ? val : -val;
}
function FT_Vector_Length(vec)
{
var v = new FT_Vector();
v.x = vec.x;
v.y = vec.y;
/* handle trivial cases */
if (v.x == 0)
{
return (v.y >= 0) ? v.y : -v.y;
}
else if (v.y == 0)
{
return (v.x >= 0) ? v.x : -v.x;
}
/* general case */
var shift = ft_trig_prenorm(v);
ft_trig_pseudo_polarize(v);
v.x = ft_trig_downscale(v.x);
if (shift > 0)
return (v.x + (1 << (shift - 1))) >> shift;
return v.x << -shift;
}
function FT_Outline_EmboldenXY(outline, xstrength, ystrength)
{
if (outline == null)
return FT_Common.FT_Err_Invalid_Argument;
xstrength /= 2;
ystrength /= 2;
if (xstrength == 0 && ystrength == 0)
return 0;
var orientation = FT_Outline_Get_Orientation(outline);
if (orientation == FT_Common.FT_ORIENTATION_NONE)
{
if (outline.n_contours != 0)
return FT_Common.FT_Err_Invalid_Argument;
else
return 0;
}
var points = outline.points;
var contours = outline.contours;
var v_first = new FT_Vector();
var v_prev = new FT_Vector();
var v_cur = new FT_Vector();
var v_next = new FT_Vector();
var first = 0;
var last = 0;
for (var c = 0; c < outline.n_contours; c++)
{
var _in = new FT_Vector();
var out = new FT_Vector();
var shift = new FT_Vector();
last = contours[c];
v_first.x = points[first].x;
v_first.y = points[first].y;
v_prev.x = points[last].x;
v_prev.y = points[last].y;
v_cur.x = v_first.x;
v_cur.y = v_first.y;
/* compute the incoming vector and its length */
_in.x = v_cur.x - v_prev.x;
_in.y = v_cur.y - v_prev.y;
var l_in = FT_Vector_Length(_in);
for (var n = first; n <= last; n++)
{
if (n < last)
v_next = points[n + 1];
else
v_next = v_first;
/* compute the outgoing vector and its length */
out.x = v_next.x - v_cur.x;
out.y = v_next.y - v_cur.y;
var l_out = FT_Vector_Length(out);
var d = l_in * l_out + _in.x * out.x + _in.y * out.y;
/* shift only if turn is less then ~160 degrees */
if (16 * d > l_in * l_out)
{
/* shift components are aligned along bisector */
/* and directed according to the outline orientation. */
shift.x = l_out * _in.y + l_in * out.y;
shift.y = l_out * _in.x + l_in * out.x;
if (orientation == FT_Common.FT_ORIENTATION_TRUETYPE)
shift.x = -shift.x;
else
shift.y = -shift.y;
/* threshold strength to better handle collapsing segments */
var l = Math.min(l_in, l_out);
var q = out.x * _in.y - out.y * _in.x;
if (orientation == FT_Common.FT_ORIENTATION_TRUETYPE)
q = -q;
if (FT_MulDiv(xstrength, q, l) < d)
shift.x = FT_MulDiv(shift.x, xstrength, d);
else
shift.x = FT_MulDiv(shift.x, l, q);
if (FT_MulDiv(ystrength, q, l) < d)
shift.y = FT_MulDiv(shift.y, ystrength, d);
else
shift.y = FT_MulDiv(shift.y, l, q);
}
else
shift.x = shift.y = 0;
points[n].x = v_cur.x + xstrength + shift.x;
points[n].y = v_cur.y + ystrength + shift.y;
_in = out;
l_in = l_out;
v_cur.x = v_next.x;
v_cur.y = v_next.y;
}
first = last + 1;
}
return 0;
}
function FT_Outline_EmboldenXY_cur(outline, base, xstrength, ystrength)
{
if (outline == null)
return FT_Common.FT_Err_Invalid_Argument;
xstrength /= 2;
ystrength /= 2;
if (xstrength == 0 && ystrength == 0)
return 0;
var orientation = FT_Outline_Get_Orientation_Cur(outline, base);
if (orientation == FT_Common.FT_ORIENTATION_NONE)
{
if (outline.n_contours != 0)
return FT_Common.FT_Err_Invalid_Argument;
else
return 0;
}
var points = base.points;
var contours = base.contours;
var _p_off = outline.points;
var _c_off = outline.contours;
var v_first = new FT_Vector();
var v_prev = new FT_Vector();
var v_cur = new FT_Vector();
var v_next = new FT_Vector();
var first = 0;
var last = 0;
for (var c = 0; c < outline.n_contours; c++)
{
var _in = new FT_Vector();
var out = new FT_Vector();
var shift = new FT_Vector();
last = contours[_c_off + c];
v_first.x = points[_p_off + first].x;
v_first.y = points[_p_off + first].y;
v_prev.x = points[_p_off + last].x;
v_prev.y = points[_p_off + last].y;
v_cur.x = v_first.x;
v_cur.y = v_first.y;
/* compute the incoming vector and its length */
_in.x = v_cur.x - v_prev.x;
_in.y = v_cur.y - v_prev.y;
var l_in = FT_Vector_Length(_in);
for (var n = first; n <= last; n++)
{
if (n < last)
{
v_next.x = points[_p_off + n + 1].x;
v_next.y = points[_p_off + n + 1].y;
}
else
{
v_next.x = v_first.x;
v_next.y = v_first.y;
}
/* compute the outgoing vector and its length */
out.x = v_next.x - v_cur.x;
out.y = v_next.y - v_cur.y;
var l_out = FT_Vector_Length(out);
var d = l_in * l_out + _in.x * out.x + _in.y * out.y;
/* shift only if turn is less then ~160 degrees */
if (16 * d > l_in * l_out)
{
/* shift components are aligned along bisector */
/* and directed according to the outline orientation. */
shift.x = l_out * _in.y + l_in * out.y;
shift.y = l_out * _in.x + l_in * out.x;
if (orientation == FT_Common.FT_ORIENTATION_TRUETYPE)
shift.x = -shift.x;
else
shift.y = -shift.y;
/* threshold strength to better handle collapsing segments */
var l = Math.min(l_in, l_out);
var q = out.x * _in.y - out.y * _in.x;
if (orientation == FT_Common.FT_ORIENTATION_TRUETYPE)
q = -q;
if (FT_MulDiv(xstrength, q, l) < d)
shift.x = FT_MulDiv(shift.x, xstrength, d);
else
shift.x = FT_MulDiv(shift.x, l, q);
if (FT_MulDiv(ystrength, q, l) < d)
shift.y = FT_MulDiv(shift.y, ystrength, d);
else
shift.y = FT_MulDiv(shift.y, l, q);
}
else
shift.x = shift.y = 0;
points[_p_off + n].x = v_cur.x + xstrength + shift.x;
points[_p_off + n].y = v_cur.y + ystrength + shift.y;
_in = out;
l_in = l_out;
v_cur.x = v_next.x;
v_cur.y = v_next.y;
}
first = last + 1;
}
return 0;
}
function FT_Outline_Embolden(outline, strength)
{
return FT_Outline_EmboldenXY(outline, strength, strength);
}
//------------
function FT_Outline_Transform(outline, matrix)
{
if ( !outline || !matrix )
return;
var vec = outline.points;
var len = outline.n_points;
for (var i=0; i < len; i++)
FT_Vector_Transform(vec[i], matrix);
}
function FT_Vector_Transform(vector, matrix)
{
if ( !vector || !matrix )
return;
var xz = FT_MulFix(vector.x, matrix.xx) + FT_MulFix(vector.y, matrix.xy);
var yz = FT_MulFix(vector.x, matrix.yx) + FT_MulFix(vector.y, matrix.yy);
vector.x = xz;
vector.y = yz;
}
function FT_Outline_Translate(outline, xOffset, yOffset)
{
if ( !outline )
return;
var vec = outline.points;
var c = outline.n_points;
for (var n=0;n<c;n++)
{
vec[n].x += xOffset;
vec[n].y += yOffset;
}
}
function FT_Outline_Get_CBox(outline, acbox)
{
var xMin, yMin, xMax, yMax;
if (outline != null && acbox != null)
{
if (outline.n_points == 0)
{
xMin = 0;
yMin = 0;
xMax = 0;
yMax = 0;
}
else
{
var p = outline.points;
var vec = p[0];
var count = outline.n_points;
xMin = xMax = vec.x;
yMin = yMax = vec.y;
for (var i = 1; i < count; i++)
{
var x = p[i].x;
if ( x < xMin ) xMin = x;
if ( x > xMax ) xMax = x;
var y = p[i].y;
if ( y < yMin ) yMin = y;
if ( y > yMax ) yMax = y;
}
}
acbox.xMin = xMin;
acbox.xMax = xMax;
acbox.yMin = yMin;
acbox.yMax = yMax;
}
}
function FT_Glyph_Class()
{
this.glyph_size = 0;
this.glyph_format = 0;
this.glyph_init = null;
this.glyph_done = null;
this.glyph_copy = null;
this.glyph_transform = null;
this.glyph_bbox = null;
this.glyph_prepare = null;
}
// для быстроты работы не пользуется эта структура.
// все ради всех браузеров, кроме ie9. в них типизированные массивы
// быстрее обычных (а тут скорость доступа - самое главное)
function TCell()
{
this.x = 0;
this.cover = 0;
this.area = 0;
this.next = 0;
}
function TRaster()
{
this.worker = new TWorker();
this.memory = null;
this.cell_x = CreateIntArray(1024);
this.cell_cover = CreateIntArray(1024);
this.cell_area = CreateIntArray(1024);
this.cell_next = CreateIntArray(1024);
this.buffer_size = 0;
this.band_size = 0;
}
// - smooth -----------------------------------------------------------
// ------------ rasterizer --------------------------------------------
// пул памяти для растеризатора делаем Array int'ов. Почему не массив структур?
// 1) не выделять память под саму структуру (хотя кто знает как работает js)
// 2) самое главное - это возможность замены на типизированный массив!!!
// сам растеризатор ничего не знает о происхождении массива. За создание
// его отвечает функция CreateIntArray
function CreateIntArray(size)
{
var arr = null;
if (typeof(Int32Array) != 'undefined' && !window.opera)
arr = new Int32Array(size);
else
arr = new Array(size);
for (var i=0;i<size;i++)
arr[i] = 0;
return arr;
}
function CreateUIntArray(size)
{
var arr = null;
if (typeof(Uint32Array) != 'undefined' && !window.opera)
arr = new Uint32Array(size);
else
arr = new Array(size);
for (var i=0;i<size;i++)
arr[i] = 0;
return arr;
}
function CreateCharArray(size)
{
var arr = null;
if (typeof(Int8Array) != 'undefined' && !window.opera)
arr = new Int8Array(size);
else
arr = new Array(size);
for (var i=0;i<size;i++)
arr[i] = 0;
return arr;
}
function CreateNullArray(size)
{
var arr = new Array(size);
for (var i=0;i<size;i++)
arr[i] = null;
return arr;
}
function TWorker()
{
this.ex = 0;
this.ey = 0;
this.min_ex = 0;
this.max_ex = 0;
this.min_ey = 0;
this.max_ey = 0;
this.count_ex = 0;
this.count_ey = 0;
this.area = 0;
this.cover = 0;
this.invalid = 0;
this.max_cells = 0;
this.num_cells = 0;
this.cx = 0;
this.cy = 0;
this.x = 0;
this.y = 0;
this.last_ey = 0;
this.bez_stack_x = CreateIntArray(97);
this.bez_stack_y = CreateIntArray(97);
this.lev_stack = CreateIntArray(32);
this.outline = null;
this.target = null;
this.clip_box = new FT_BBox();
this.gray_spans = new Array(32);
for (var i=0;i<32;i++)
this.gray_spans[i] = new FT_Span();
this.num_gray_spans = 0;
this.render_span = null;
this.render_span_data = null;
this.span_y = 0;
this.band_size = 0;
this.band_shoot = 0;
this.cell_x = null;
this.cell_cover = null;
this.cell_area = null;
this.cell_next = null;
this.buffer_size = 1024;
this.ycells = CreateIntArray(this.buffer_size);
this.ycount = 0;
this.raster_memory = raster_memory;
}
function gray_init_cells(worker, raster)
{
worker.cell_x = raster.cell_x;
worker.cell_cover = raster.cell_cover;
worker.cell_area = raster.cell_area;
worker.cell_next = raster.cell_next;
worker.buffer_size = 1024;
worker.max_cells = 0;
worker.num_cells = 0;
worker.area = 0;
worker.cover = 0;
worker.invalid = 1;
}
function gray_compute_cbox(worker)
{
var outline = worker.outline;
var p = outline.points;
var c = outline.n_points;
if ( c <= 0 )
{
worker.min_ex = worker.max_ex = 0;
worker.min_ey = worker.max_ey = 0;
return;
}
worker.min_ex = worker.max_ex = p[0].x;
worker.min_ey = worker.max_ey = p[0].y;
for (var i = 1; i < c; i++)
{
var x = p[i].x;
var y = p[i].y;
if ( x < worker.min_ex ) worker.min_ex = x;
if ( x > worker.max_ex ) worker.max_ex = x;
if ( y < worker.min_ey ) worker.min_ey = y;
if ( y > worker.max_ey ) worker.max_ey = y;
}
/* truncate the bounding box to integer pixels */
worker.min_ex = worker.min_ex >> 6;
worker.min_ey = worker.min_ey >> 6;
worker.max_ex = ( worker.max_ex + 63 ) >> 6;
worker.max_ey = ( worker.max_ey + 63 ) >> 6;
}
function TBand()
{
this.min = 0;
this.max = 0;
}
function gray_find_cell(ras)
{
var x = ras.ex;
if ( x > ras.count_ex )
x = ras.count_ex;
var pcell = ras.ey;
var cell = ras.ycells[pcell];
var bis_y = 1;
for (;;)
{
if (cell == -1 || ras.cell_x[cell] > x)
break;
if (ras.cell_x[cell] == x)
return cell;
bis_y = 0;
pcell = cell;
cell = ras.cell_next[cell];
}
if (ras.num_cells >= ras.max_cells)
return -1;
var oldcell = cell;
cell = ras.num_cells++;
ras.cell_x[cell] = x;
ras.cell_area[cell] = 0;
ras.cell_cover[cell] = 0;
ras.cell_next[cell] = oldcell;
if (1 == bis_y)
ras.ycells[pcell] = cell;
else
ras.cell_next[pcell] = cell;
return cell;
}
function gray_record_cell(ras)
{
if (0 == ras.invalid && ((ras.area | ras.cover) != 0))
{
var cell = gray_find_cell(ras);
if (-1 == cell)
return FT_Common.ErrorLongJump;
ras.cell_area[cell] += ras.area;
ras.cell_cover[cell] += ras.cover;
}
return 0;
}
function gray_set_cell(ras, ex, ey)
{
ey -= ras.min_ey;
if ( ex > ras.max_ex )
ex = ras.max_ex;
ex -= ras.min_ex;
if ( ex < 0 )
ex = -1;
/* are we moving to a different cell ? */
if ( ex != ras.ex || ey != ras.ey )
{
/* record the current one if it is valid */
if (0 == ras.invalid)
{
var err = gray_record_cell(ras);
if (err == FT_Common.ErrorLongJump)
return FT_Common.ErrorLongJump;
}
ras.area = 0;
ras.cover = 0;
}
ras.ex = ex;
ras.ey = ey;
var _ey = ey >= 0 ? ey : ey + FT_Common.a_i;
var _cy = ras.count_ey >= 0 ? ras.count_ey : ras.count_ey + FT_Common.a_i;
ras.invalid = (_ey >= _cy || ex >= ras.count_ex) ? 1 : 0;
return 0;
}
function gray_start_cell(ras, ex, ey)
{
if (ex > ras.max_ex)
ex = ras.max_ex;
if (ex < ras.min_ex)
ex = (ras.min_ex - 1);
ras.area = 0;
ras.cover = 0;
ras.ex = ex - ras.min_ex;
ras.ey = ey - ras.min_ey;
ras.last_ey = ey << 8;
ras.invalid = 0;
return gray_set_cell(ras, ex, ey);
}
function gray_render_line(ras, to_x, to_y)
{
var ey1, ey2, fy1, fy2, mod;
var dx, dy, x, x2;
var p, first;
var delta, rem, lift, incr;
ey1 = (ras.last_ey >> 8);
ey2 = (to_y >> 8); /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */
fy1 = (ras.y - ras.last_ey);
fy2 = (to_y - (ey2 << 8));
dx = to_x - ras.x;
dy = to_y - ras.y;
var min = ey1;
var max = ey2;
if (ey1 > ey2)
{
min = ey2;
max = ey1;
}
if (min >= ras.max_ey || max < ras.min_ey)
{
ras.x = to_x;
ras.y = to_y;
ras.last_ey = ey2 << 8;
return 0;
}
var err = 0;
/* everything is on a single scanline */
if (ey1 == ey2)
{
err = gray_render_scanline(ras, ey1, ras.x, fy1, to_x, fy2);
if (err == FT_Common.ErrorLongJump)
return FT_Common.ErrorLongJump;
ras.x = to_x;
ras.y = to_y;
ras.last_ey = ey2 << 8;
return 0;
}
/* vertical line - avoid calling gray_render_scanline */
incr = 1;
if (dx == 0)
{
var ex = ras.x >> 8;
var two_fx = ((ras.x - (ex << 8)) << 1);
var area;
first = 256;
if (dy < 0)
{
first = 0;
incr = -1;
}
delta = (first - fy1);
ras.area += (two_fx * delta);
ras.cover += delta;
ey1 += incr;
err = gray_set_cell(ras, ex, ey1);
if (err == FT_Common.ErrorLongJump)
return FT_Common.ErrorLongJump;
delta = (first + first - 256);
area = two_fx * delta;
while (ey1 != ey2)
{
ras.area += area;
ras.cover += delta;
ey1 += incr;
err = gray_set_cell(ras, ex, ey1);
if (err == FT_Common.ErrorLongJump)
return FT_Common.ErrorLongJump;
}
delta = (fy2 - 256 + first);
ras.area += (two_fx * delta);
ras.cover += delta;
ras.x = to_x;
ras.y = to_y;
ras.last_ey = ey2 << 8;
return 0;
}
/* ok, we have to render several scanlines */
p = (256 - fy1) * dx;
first = 256;
incr = 1;
if (dy < 0)
{
p = fy1 * dx;
first = 0;
incr = -1;
dy = -dy;
}
delta = parseInt(p / dy);
mod = (p % dy);
if (mod < 0)
{
delta--;
mod += dy;
}
x = ras.x + delta;
err = gray_render_scanline(ras, ey1, ras.x, fy1, x, first);
if (err == FT_Common.ErrorLongJump)
return FT_Common.ErrorLongJump;
ey1 += incr;
err = gray_set_cell(ras, x >> 8, ey1);
if (err == FT_Common.ErrorLongJump)
return FT_Common.ErrorLongJump;
if (ey1 != ey2)
{
p = 256 * dx;
lift = parseInt(p / dy);
rem = (p % dy);
if (rem < 0)
{
lift--;
rem += dy;
}
mod -= dy;
while (ey1 != ey2)
{
delta = lift;
mod += rem;
if (mod >= 0)
{
mod -= dy;
delta++;
}
x2 = x + delta;
err = gray_render_scanline(ras, ey1, x, 256 - first, x2, first);
if (err == FT_Common.ErrorLongJump)
return FT_Common.ErrorLongJump;
x = x2;
ey1 += incr;
err = gray_set_cell(ras, x >> 8, ey1);
if (err == FT_Common.ErrorLongJump)
return FT_Common.ErrorLongJump;
}
}
err = gray_render_scanline(ras, ey1, x, 256 - first, to_x, fy2);
if (err == FT_Common.ErrorLongJump)
return FT_Common.ErrorLongJump;
ras.x = to_x;
ras.y = to_y;
ras.last_ey = (ey2 << 8);
return 0;
}
function gray_split_conic(bx,by,base)
{
var a,b;
bx[base+4] = bx[base+2];
b = bx[base+1];
a=bx[base+3] = parseInt((bx[base+2]+b)/2);
b=bx[base+1] = parseInt((bx[base]+b)/2);
bx[base+2] = parseInt((a+b)/2);
by[base+4] = by[base+2];
b = by[base+1];
a=by[base+3] = parseInt((by[base+2]+b)/2);
b=by[base+1] = parseInt((by[base]+b)/2);
by[base+2] = parseInt((a+b)/2);
}
function gray_render_conic(ras, control, to)
{
var dx, dy;
var min, max, y;
var top, level;
var arc = 0;
var arcx = ras.bez_stack_x;
var arcy = ras.bez_stack_y;
arcx[arc] = (to.x << 2);
arcy[arc] = (to.y << 2);
arcx[arc+1] = (control.x << 2);
arcy[arc+1] = (control.y << 2);
arcx[arc+2] = ras.x;
arcy[arc+2] = ras.y;
top = 0;
dx = Math.abs(arcx[arc+2] + arcx[arc] - 2*arcx[arc+1]);
dy = Math.abs(arcy[arc+2] + arcy[arc] - 2*arcy[arc+1]);
if (dx < dy)
dx = dy;
if (dx < 64)
{
return gray_render_line(ras, arcx[arc], arcy[arc]);
}
/* short-cut the arc that crosses the current band */
min = max = arcy[arc];
y = arcy[arc+1];
if (y < min) min = y;
if (y > max) max = y;
y = arcy[arc+2];
if (y < min) min = y;
if (y > max) max = y;
if (((min >> 8) >= ras.max_ey) || ((max >> 8) < ras.min_ey))
{
return gray_render_line(ras, arcx[arc], arcy[arc]);
}
level = 0;
do
{
dx >>= 2;
level++;
} while (dx > 64);
var levels = ras.lev_stack;
levels[0] = level;
var err = 0;
do
{
level = levels[top];
if (level > 0)
{
gray_split_conic(arcx, arcy, arc);
arc += 2;
top++;
levels[top] = levels[top - 1] = level - 1;
continue;
}
err = gray_render_line(ras, arcx[arc], arcy[arc]);
if (err == FT_Common.ErrorLongJump)
return FT_Common.ErrorLongJump;
top--;
arc -= 2;
}
while (top >= 0);
return 0;
}
function gray_split_cubic(bx,by,base)
{
var a,b,c,d;
bx[base+6] = bx[base+3];
c = bx[base+1];
d = bx[base+2];
bx[base+1] = a = parseInt((bx[base]+c)/2);
bx[base+5] = b = parseInt((bx[base+3]+d)/2);
c = parseInt((c+d)/2);
bx[base+2] = a = parseInt((a+c)/2);
bx[base+4] = b = parseInt((b+c)/2);
bx[base+3] = parseInt((a+b)/2);
by[base+6] = by[base+3];
c = by[base+1];
d = by[base+2];
by[base+1] = a = parseInt((by[base]+c)/2);
by[base+5] = b = parseInt((by[base+3]+d)/2);
c = parseInt((c+d)/2);
by[base+2] = a = parseInt((a+c)/2);
by[base+4] = b = parseInt((b+c)/2);
by[base+3] = parseInt((a+b)/2);
}
function gray_render_cubic(ras, control1, control2, to)
{
var min, max, y;
var arcx = ras.bez_stack_x;
var arcy = ras.bez_stack_y;
arcx[0] = to.x << 2;
arcy[0] = to.y << 2;
arcx[1] = control2.x << 2;
arcy[1] = control2.y << 2;
arcx[2] = control1.x << 2;
arcy[2] = control1.y << 2;
arcx[3] = ras.x;
arcy[3] = ras.y;
var arc = 0;
/* Short-cut the arc that crosses the current band. */
min = max = arcy[0];
y = arcy[arc+1];
if (y<min)
min = y;
if (y>max)
max = y;
y = arcy[arc+2];
if (y<min)
min = y;
if (y>max)
max = y;
y = arcy[arc+3];
if (y<min)
min = y;
if (y>max)
max = y;
var err = 0;
if ((min >> 8) >= ras.max_ey || (max >> 8) < ras.min_ey)
{
return gray_render_line(ras, arcx[arc], arcy[arc]);
}
for (;;)
{
var dx, dy, dx_, dy_;
var dx1, dy1, dx2, dy2;
var L, s, s_limit;
dx = arcx[arc+3] - arcx[arc];
dy = arcy[arc+3] - arcy[arc];
dx_ = Math.abs(dx);
dy_ = Math.abs(dy);
L = ((dx_ > dy_) ? (236 * dx_ + 97 * dy_) : (97 * dx_ + 236 * dy_)) >>> 8;
if ( L > 32767 )
{
gray_split_cubic(arcx,arcy,arc);
arc += 3;
continue;
}
s_limit = L * 42;
dx1 = arcx[arc+1] - arcx[arc];
dy1 = arcy[arc+1] - arcy[arc];
s = Math.abs(dy*dx1 - dx*dy1);
if (s>s_limit)
{
gray_split_cubic(arcx,arcy,arc);
arc += 3;
continue;
}
dx2 = arcx[arc+2] - arcx[arc];
dy2 = arcy[arc+2] - arcy[arc];
s = Math.abs(dy*dx2 - dx*dy2);
if (s>s_limit)
{
gray_split_cubic(arcx,arcy,arc);
arc += 3;
continue;
}
if (((dy*dy1 + dx*dx1) < 0) || ((dy*dy2 + dx*dx2) < 0) ||
((dy*(arcy[arc+3]-arcy[arc+1]) + dx*(arcx[arc+3]-arcx[arc+1])) < 0) ||
((dy*(arcy[arc+3]-arcy[arc+2]) + dx*(arcx[arc+3]-arcx[arc+2])) < 0))
{
gray_split_cubic(arcx,arcy,arc);
arc += 3;
continue;
}
/* No reason to split. */
err = gray_render_line(ras, arcx[arc], arcy[arc]);
if (err == FT_Common.ErrorLongJump)
return FT_Common.ErrorLongJump;
if (arc == 0)
return 0;
arc -= 3;
}
return 0;
}
function gray_render_scanline(ras, ey, x1, y1, x2, y2)
{
var ex1, ex2, fx1, fx2, delta, mod, lift, rem;
var p, first, dx;
var incr;
dx = x2 - x1;
ex1 = (x1 >> 8);
ex2 = (x2 >> 8);
fx1 = x1 - (ex1 << 8);
fx2 = x2 - (ex2 << 8);
/* trivial case. Happens often */
if (y1 == y2)
{
return gray_set_cell(ras, ex2, ey);
}
/* everything is located in a single cell. That is easy! */
if (ex1 == ex2)
{
delta = y2 - y1;
ras.area += ((fx1+fx2)*delta);
ras.cover += delta;
return 0;
}
/* ok, we'll have to render a run of adjacent cells on the same scanline */
p = (256 - fx1)*(y2-y1);
first = 256;
incr = 1;
if (dx < 0)
{
p = fx1*(y2-y1);
first = 0;
incr = -1;
dx = -dx;
}
delta = parseInt(p/dx);
mod = p%dx;
if (mod < 0)
{
delta--;
mod += dx;
}
ras.area += ((fx1+first)*delta);
ras.cover += delta;
ex1 += incr;
var err = gray_set_cell(ras, ex1, ey);
if (err == FT_Common.ErrorLongJump)
return err;
y1 += delta;
if (ex1 != ex2)
{
p = 256 * (y2 - y1 + delta);
lift = parseInt(p/dx);
rem = (p%dx);
if (rem < 0)
{
lift--;
rem += dx;
}
mod -= dx;
while (ex1 != ex2)
{
delta = lift;
mod += rem;
if (mod >= 0)
{
mod -= dx;
delta++;
}
ras.area += (256*delta);
ras.cover += delta;
y1 += delta;
ex1 += incr;
err = gray_set_cell(ras, ex1, ey);
if (err == FT_Common.ErrorLongJump)
return err;
}
}
delta = y2 - y1;
ras.area += ((fx2 + 256 - first)*delta);
ras.cover += delta;
return 0;
}
function _gray_render_span(y, count, spans, span_start, worker)
{
var map = worker.target;
var pixels = map.buffer.data;
var p = -y * map.pitch;
if (map.pitch >= 0)
p += ((map.rows-1)*map.pitch);
var s = span_start;
for (;count > 0;count--,s++)
{
var coverage = spans[s].coverage;
if (coverage != 0)
{
var len = spans[s].len;
var q = spans[s].x + p;
for (;len>0;len--)
pixels[q++] = coverage;
}
}
}
function gray_render_span(y, count, spans, span_start, worker)
{
var map = worker.raster_memory;
var pixels = map.m_oBuffer.data;
var p = -y * map.pitch;
if (worker.target.pitch >= 0)
p += ((worker.target.rows-1)*map.pitch);
p+=3;
var s = span_start;
for (;count > 0;count--,s++)
{
var coverage = spans[s].coverage;
if (coverage != 0)
{
var len = spans[s].len;
var q = (spans[s].x * 4) + p;
for (;len>0;len--,q+=4)
pixels[q] = coverage;
}
}
}
function gray_hline(ras, x, y, area, acount)
{
var spans = ras.gray_spans;
var span_i = 0;
var span;
var count;
var coverage = (area >> 9);
/* use range 0..256 */
if (coverage < 0)
coverage = -coverage;
if ((ras.outline.flags & FT_Common.FT_OUTLINE_EVEN_ODD_FILL) != 0)
{
coverage &= 511;
if (coverage > 256)
coverage = 512 - coverage;
else if (coverage == 256)
coverage = 255;
}
else
{
if ( coverage >= 256 )
coverage = 255;
}
y += ras.min_ey;
x += ras.min_ex;
if (x >= 32767)
x = 32767;
/* FT_Span.y is an integer, so limit our coordinates appropriately */
if (y >= 2147483647)
y = 2147483647;
if (coverage != 0)
{
/* see whether we can add this span to the current list */
count = ras.num_gray_spans;
span_i = count - 1;
span = spans[span_i];
if ((count > 0) && (ras.span_y == y) && ((span.x + span.len) == x) && (span.coverage == coverage))
{
span.len = (span.len + acount) & 0xFFFF;
return;
}
if (ras.span_y != y || count >= 32)
{
if (ras.render_span && count > 0)
ras.render_span(ras.span_y,count,ras.gray_spans,0,ras.render_span_data);
ras.num_gray_spans = 0;
ras.span_y = y;
count = 0;
span_i = 0;
span = spans[0];
}
else
{
span_i++;
span = spans[span_i];
}
/* add a gray span to the current list */
span.x = x;
span.len = acount & 0xFFFF;
span.coverage = coverage & 0xFF;
ras.num_gray_spans++;
}
}
function gray_sweep(ras, target)
{
if (ras.num_cells == 0)
return;
ras.num_gray_spans = 0;
var _next = ras.cell_next;
var _cover = ras.cell_cover;
var _area = ras.cell_area;
var _x = ras.cell_x;
for (var yindex = 0; yindex < ras.ycount; yindex++)
{
var cell = ras.ycells[yindex];
var cover = 0;
var x = 0;
for (; cell != -1; cell = _next[cell])
{
if (_x[cell] > x && cover != 0)
gray_hline(ras, x, yindex, cover * 512, _x[cell] - x);
cover += _cover[cell];
var area = cover * 512 - _area[cell];
if (area != 0 && _x[cell] >= 0)
gray_hline(ras, _x[cell], yindex, area, 1);
x = _x[cell] + 1;
}
if ( cover != 0 )
gray_hline(ras, x, yindex, cover * 512, ras.count_ex - x);
}
if (ras.render_span && ras.num_gray_spans > 0)
ras.render_span(ras.span_y, ras.num_gray_spans, ras.gray_spans, 0, ras.render_span_data);
}
function __grays_raster_render(raster, params)
{
var outline = params.source;
var target_map = params.target;
if (raster == null)
return FT_Common.FT_Err_Invalid_Argument;
if (outline == null)
return FT_Common.FT_Err_Invalid_Outline;
/* return immediately if the outline is empty */
if (outline.n_points == 0 || outline.n_contours <= 0)
return 0;
if (outline.contours == null || outline.points == null)
return FT_Common.FT_Err_Invalid_Outline;
if (outline.n_points != outline.contours[outline.n_contours - 1] + 1)
return FT_Common.FT_Err_Invalid_Outline;
var worker = raster.worker;
/* if direct mode is not set, we must have a target bitmap */
if (0 == (params.flags & FT_Common.FT_RASTER_FLAG_DIRECT))
{
if (target_map == null)
return FT_Common.FT_Err_Invalid_Argument;
/* nothing to do */
if (0 == target_map.width || 0 == target_map.rows)
return 0;
if (null == target_map.buffer && null == worker.raster_memory)
return FT_Common.FT_Err_Invalid_Argument;
}
/* this version does not support monochrome rendering */
if (0 == (params.flags & FT_Common.FT_RASTER_FLAG_AA))
return FT_Common.FT_Err_Invalid_Argument;
/* compute clipping box */
if (0 == (params.flags & FT_Common.FT_RASTER_FLAG_DIRECT))
{
/* compute clip box from target pixmap */
worker.clip_box.xMin = 0;
worker.clip_box.yMin = 0;
worker.clip_box.xMax = target_map.width;
worker.clip_box.yMax = target_map.rows;
}
else if (params.flags & FT_Common.FT_RASTER_FLAG_CLIP)
{
worker.clip_box.xMin = params.clip_box.xMin;
worker.clip_box.yMin = params.clip_box.yMin;
worker.clip_box.xMax = params.clip_box.xMax;
worker.clip_box.yMax = params.clip_box.yMax;
}
else
{
worker.clip_box.xMin = -32768;
worker.clip_box.yMin = -32768;
worker.clip_box.xMax = 32767;
worker.clip_box.yMax = 32767;
}
gray_init_cells(worker, raster);
worker.outline = outline;
worker.num_cells = 0;
worker.invalid = 1;
worker.band_size = raster.band_size;
worker.num_gray_spans = 0;
if (0 != (params.flags & FT_Common.FT_RASTER_FLAG_DIRECT))
{
worker.render_span = params.gray_spans;
worker.render_span_data = params.user;
}
else
{
worker.target = target_map;
worker.render_span = gray_render_span;
worker.render_span_data = worker;
}
if (worker.raster_memory != null)
worker.raster_memory.CheckSize(target_map.width, target_map.rows);
return __gray_convert_glyph(worker);
}
function __gray_convert_glyph(ras)
{
var bands = m_bands;
var band = 0;
var n = 0;
var num_bands = 0;
var min = 0;
var max = 0;
var max_y = 0;
var clip = null;
gray_compute_cbox(ras);
/* clip to target bitmap, exit if nothing to do */
clip = ras.clip_box;
if (ras.max_ex <= clip.xMin || ras.min_ex >= clip.xMax ||
ras.max_ey <= clip.yMin || ras.min_ey >= clip.yMax )
return 0;
if (ras.min_ex < clip.xMin) ras.min_ex = clip.xMin;
if (ras.min_ey < clip.yMin) ras.min_ey = clip.yMin;
if (ras.max_ex > clip.xMax ) ras.max_ex = clip.xMax;
if (ras.max_ey > clip.yMax ) ras.max_ey = clip.yMax;
ras.count_ex = ras.max_ex - ras.min_ex;
ras.count_ey = ras.max_ey - ras.min_ey;
/* set up vertical bands */
num_bands = parseInt((ras.max_ey - ras.min_ey) / ras.band_size);
if (num_bands == 0)
num_bands = 1;
if (num_bands >= 39)
num_bands = 39;
ras.band_shoot = 0;
min = ras.min_ey;
max_y = ras.max_ey;
for (n = 0; n < num_bands; n++, min = max)
{
max = min + ras.band_size;
if ((n == num_bands - 1) || (max > max_y))
max = max_y;
bands[0].min = min;
bands[0].max = max;
band = 0;
while (band >= 0)
{
var isReduceBands = 0;
var bottom, top, middle;
var error = 0;
var _band = bands[band];
var cells_max;
ras.ycount = _band.max - _band.min;
if (ras.ycount >= ras.buffer_size)
isReduceBands = 1;
if (0 == isReduceBands)
{
ras.max_cells = ras.buffer_size;
if (ras.max_cells < 2)
{
// такого быть не может из-за лишнего килобайтика)
isReduceBands = 1;
}
if (0 == isReduceBands)
{
for (var yindex = 0; yindex < ras.ycount; yindex++)
ras.ycells[yindex] = -1;
ras.num_cells = 0;
ras.invalid = 1;
ras.min_ey = _band.min;
ras.max_ey = _band.max;
ras.count_ey = _band.max - _band.min;
error = __gray_convert_glyph_inner(ras);
if (0 == error)
{
gray_sweep(ras, ras.target);
band--;
continue;
}
else if (error != FT_Common.FT_Err_Raster_Overflow)
return 1;
}
}
/* render pool overflow; we will reduce the render band by half */
bottom = _band.min;
top = _band.max;
middle = bottom + ((top - bottom) >> 1);
/* This is too complex for a single scanline; there must */
/* be some problems. */
if (middle == bottom)
return 1;
if (bottom-top >= ras.band_size)
ras.band_shoot++;
bands[band+1].min = bottom;
bands[band+1].max = middle;
bands[band].min = middle;
bands[band].max = top;
band++;
}
}
if (ras.band_shoot > 8 && ras.band_size > 16)
ras.band_size = parseInt(ras.band_size / 2);
return 0;
}
function __gray_convert_glyph_inner(ras)
{
var error1 = FT_Outline_Decompose(ras.outline, ft_outline_funcs_gray, ras);
if (FT_Common.ErrorLongJump == error1)
return FT_Common.FT_Err_Raster_Overflow;
var error2 = gray_record_cell(ras);
if (FT_Common.ErrorLongJump == error2)
return FT_Common.FT_Err_Raster_Overflow;
return error1;
}
var m_bands = new Array(40);
for (var i = 0; i < 40; i++)
m_bands[i] = new TBand();
function FT_Grays_Raster()
{
// --------
this.glyph_format = FT_Common.FT_GLYPH_FORMAT_OUTLINE;
this.raster_new = function(memory, raster)
{
raster.memory = memory;
return 0;
}
this.raster_reset = function(raster, pool_base, pool_size)
{
raster.buffer_size = 1024;
raster.band_size = 117; // сделал как в си-шной либе, чтобы было удобно дебажиться.
// а вообще - нужно так: (мы памяти выделяем больше на 1kb (под указатели ycells))
//raster.band_size = 128;
}
this.raster_set_mode = null;
this.raster_render = __grays_raster_render;
this.raster_done = function()
{
}
}
// --------------------------------------------------------------------
function FT_Smooth_Renderer_Class()
{
this.flags = FT_Common.FT_MODULE_RENDERER;
this.name = "smooth";
this.version = 0x10000;
this.requires = 0x20000;
this.module_interface = null;
this.init = ft_smooth_init;
this.done = null;
this.get_interface = null;
this.glyph_format = FT_Common.FT_GLYPH_FORMAT_OUTLINE;
this.render_glyph = ft_smooth_render;
this.transform_glyph = ft_smooth_transform;
this.get_glyph_cbox = ft_smooth_get_cbox;
this.set_mode = ft_smooth_set_mode;
this.raster_class = new FT_Grays_Raster();
}
function FT_Smooth_Renderer()
{
this.clazz = new FT_Smooth_Renderer_Class();
this.library = null;
this.memory = null;
this.generic = null;
this.glyph_format = 0;
this.glyph_class = new FT_Glyph_Class();
this.raster = null;
this.raster_render = null;
this.render = null;
}
function create_renderer_smooth_module(library)
{
var ren1_mod = new FT_Smooth_Renderer();
ren1_mod.clazz = new FT_Smooth_Renderer_Class();
ren1_mod.clazz.render_glyph = ft_smooth_render;
ren1_mod.library = library;
ren1_mod.memory = library.Memory;
ren1_mod.generic = null;
return ren1_mod;
}
function create_renderer_smooth_lcd_module(library)
{
var ren1_mod = new FT_Smooth_Renderer();
ren1_mod.clazz = new FT_Smooth_Renderer_Class();
ren1_mod.clazz.render_glyph = ft_smooth_render_lcd;
ren1_mod.library = library;
ren1_mod.memory = library.Memory;
ren1_mod.generic = null;
return ren1_mod;
}
function create_renderer_smooth_lcd_v_module(library)
{
var ren1_mod = new FT_Smooth_Renderer();
ren1_mod.clazz = new FT_Smooth_Renderer_Class();
ren1_mod.clazz.render_glyph = ft_smooth_render_lcd_v;
ren1_mod.library = library;
ren1_mod.memory = library.Memory;
ren1_mod.generic = null;
return ren1_mod;
}
function ft_smooth_init(render)
{
render.clazz.raster_class.raster_reset(render.raster, render.library.raster_pool, render.library.raster_pool_size);
return 0;
}
function ft_smooth_set_mode(render, mode_tag, data)
{
return render.clazz.raster_class.raster_set_mode(render.raster, mode_tag, data);
}
function ft_smooth_transform(render, slot, matrix, delta)
{
if (slot.format != render.glyph_format)
return FT_Common.FT_Err_Invalid_Argument;
if (matrix)
FT_Outline_Transform(slot.outline, matrix);
if (delta)
FT_Outline_Translate(slot.outline, delta.x, delta.y);
return 0;
}
function ft_smooth_get_cbox(render, slot, cbox)
{
cbox.xMin = 0;
cbox.yMin = 0;
cbox.xMax = 0;
cbox.yMax = 0;
if (slot.format == render.glyph_format)
FT_Outline_Get_CBox(slot.outline, cbox);
}
function ft_smooth_render(render, slot, mode, origin)
{
if (mode == FT_Common.FT_RENDER_MODE_LIGHT)
mode = FT_Common.FT_RENDER_MODE_NORMAL;
return ft_smooth_render_generic(render, slot, mode, origin, FT_Common.FT_RENDER_MODE_NORMAL);
}
function ft_smooth_render_lcd(render, slot, mode, origin)
{
var error = ft_smooth_render_generic(render, slot, mode, origin, FT_Common.FT_RENDER_MODE_LCD);
if (error == 0)
slot.bitmap.pixel_mode = FT_Common.FT_PIXEL_MODE_LCD;
return error;
}
function ft_smooth_render_lcd_v(render, slot, mode, origin)
{
var error = ft_smooth_render_generic(render, slot, mode, origin, FT_Common.FT_RENDER_MODE_LCD_V);
if (error == 0)
slot.bitmap.pixel_mode = FT_Common.FT_PIXEL_MODE_LCD_V;
return error;
}
function ft_smooth_render_generic(render, slot, mode, origin, required_mode)
{
var error = 0;
var outline = null;
var cbox = new FT_BBox();
var width, height, pitch;
//#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
var height_org, width_org;
//#endif
var hmul = (mode == FT_Common.FT_RENDER_MODE_LCD) ? 1 : 0;
var vmul = (mode == FT_Common.FT_RENDER_MODE_LCD_V) ? 1 : 0;
var x_shift, y_shift, x_left, y_top;
var params = new FT_Raster_Params();
/* check glyph image format */
if (slot.format != render.glyph_format)
return FT_Common.FT_Err_Invalid_Argument;
/* check mode */
if (mode != required_mode)
return FT_Common.FT_Err_Cannot_Render_Glyph;
outline = slot.outline;
/* translate the outline to the new origin if needed */
if (origin != null)
FT_Outline_Translate(outline, origin.x, origin.y);
/* compute the control box, and grid fit it */
FT_Outline_Get_CBox(outline, cbox);
cbox.xMin = (cbox.xMin & ~63);
cbox.yMin = (cbox.yMin & ~63);
cbox.xMax = ((cbox.xMax+63) & ~63);
cbox.yMax = ((cbox.yMax+63) & ~63);
if (cbox.xMin < 0 && cbox.xMax > 2147483647 + cbox.xMin)
{
if (outline && origin)
FT_Outline_Translate(outline, -origin.x, -origin.y);
return FT_Common.FT_Err_Raster_Overflow;
}
else
width = ((cbox.xMax - cbox.xMin) >>> 6);
if ( cbox.yMin < 0 && cbox.yMax > 2147483647 + cbox.yMin )
{
if ( outline && origin )
FT_Outline_Translate( outline, -origin.x, -origin.y );
return FT_Common.FT_Err_Raster_Overflow;
}
else
height = ((cbox.yMax - cbox.yMin) >>> 6);
var bitmap = slot.bitmap;
var memory = render.memory;
//#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
width_org = width;
height_org = height;
//#endif
/* release old bitmap buffer */
if (slot.internal.flags & FT_Common.FT_GLYPH_OWN_BITMAP)
{
delete bitmap.buffer;
slot.internal.flags &= ~FT_Common.FT_GLYPH_OWN_BITMAP;
}
/* allocate new one */
pitch = width;
if (hmul == 1)
{
width = width * 3;
pitch = (width + 3) & ~3;
}
if (vmul == 1)
height *= 3;
x_shift = cbox.xMin;
y_shift = cbox.yMin;
x_left = cbox.xMin >> 6;
y_top = cbox.yMax >> 6;
//#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
/*
if (slot.library.lcd_filter_func)
{
var extra = slot.library.lcd_extra;
if (hmul == 1)
{
x_shift -= 64 * (extra >>> 1);
width += 3 * extra;
pitch = (width + 3) & ~3;
x_left -= (extra >>> 1);
}
if (vmul == 1)
{
y_shift -= 64 * (extra >>> 1);
height += 3 * extra;
y_top += (extra >>> 1);
}
}
*/
//#endif
if (width > 0x7FFF || height > 0x7FFF)
{
if (outline && origin)
FT_Outline_Translate(outline, -origin.x, -origin.y);
return FT_Common.FT_Err_Raster_Overflow;
}
bitmap.pixel_mode = FT_Common.FT_PIXEL_MODE_GRAY;
bitmap.num_grays = 256;
bitmap.width = width;
bitmap.rows = height;
bitmap.pitch = pitch;
if (bitmap.width > 1000 || bitmap.height > 1000)
return 130;
/* translate outline to render it into the bitmap */
FT_Outline_Translate(outline, -x_shift, -y_shift);
var memory = slot.library.Memory;
//bitmap.buffer = memory.Alloc(pitch * height);
slot.internal.flags |= FT_Common.FT_GLYPH_OWN_BITMAP;
/* set up parameters */
params.target = bitmap;
params.source = outline;
params.flags = FT_Common.FT_RASTER_FLAG_AA;
//#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
/*
var points = outline.points;
var count = outline.n_points;
if (hmul == 1)
for (var i = 0; i < count; i++)
points[i].x = points[i].x * 3;
if (vmul == 1)
for (var i = 0; i < count; i++)
points[i].y = points[i].y * 3;
error = render.raster_render(render.raster, params);
if (hmul == 1)
for (var i = 0; i < count; i++)
points[i].x = parseInt(points[i].x / 3);
if (vmul == 1)
for (var i = 0; i < count; i++)
points[i].y = parseInt(points[i].y / 3);
if (slot.library.lcd_filter_func)
slot.library.lcd_filter_func(bitmap, mode, slot.library);
*/
//#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
error = render.raster_render(render.raster, params);
if (hmul == 1)
{
var pixels = bitmap.buffer.data;
var line = 0;
for (var hh = height_org; hh > 0; hh--, line += pitch)
{
var end = line + width;
for (var xx = width_org; xx > 0; xx--)
{
var pixel = pixels[line+xx-1];
pixels[end-3] = pixel;
pixels[end-2] = pixel;
pixels[end-1] = pixel;
end -= 3;
}
}
}
if (vmul == 1)
{
var pixels = bitmap.buffer.data;
var read = (height - height_org) * pitch;
var write = 0;
var ii = 0;
for (var hh = height_org; hh > 0; hh--)
{
for (ii=0;ii<pitch;ii++)
pixels[write+ii] = pixels[read+ii];
write += pitch;
for (ii=0;ii<pitch;ii++)
pixels[write+ii] = pixels[read+ii];
write += pitch;
for (ii=0;ii<pitch;ii++)
pixels[write+ii] = pixels[read+ii];
write += pitch;
read += pitch;
}
}
//#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
FT_Outline_Translate(outline, x_shift, y_shift);
if (x_left > 0x7FFFFFFF || y_top > 0x7FFFFFFF)
return FT_Common.FT_Err_Invalid_Pixel_Size;
if (error == 0)
{
slot.format = FT_Common.FT_GLYPH_FORMAT_BITMAP;
slot.bitmap_left = x_left;
slot.bitmap_top = y_top;
}
if ( outline && origin )
FT_Outline_Translate(outline, -origin.x, -origin.y);
return error;
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
/******************************************************************************/
// SERVICES
/******************************************************************************/
/******************************************************************************/
// bdf
/******************************************************************************/
var FT_SERVICE_ID_BDF = "bdf";
function FT_Service_BDFRec(get_charset_id_,get_property_)
{
this.get_charset_id = get_charset_id_;
this.get_property = get_property_;
}
/******************************************************************************/
// cid
/******************************************************************************/
var FT_SERVICE_ID_CID = "CID";
function FT_Service_CIDRec(get_ros_, get_is_cid_, get_cid_from_glyph_index_)
{
this.get_ros = get_ros_;
this.get_is_cid = get_is_cid_;
this.get_cid_from_glyph_index = get_cid_from_glyph_index_;
}
/******************************************************************************/
// glyph-dict
/******************************************************************************/
var FT_SERVICE_ID_GLYPH_DICT = "glyph-dict";
function FT_Service_GlyphDictRec(get_name_, name_index_)
{
this.get_name = get_name_;
this.name_index = name_index_;
}
/******************************************************************************/
// gxval
/******************************************************************************/
var FT_SERVICE_ID_GX_VALIDATE = "truetypegx-validate";
var FT_SERVICE_ID_CLASSICKERN_VALIDATE = "classickern-validate";
function FT_Service_GXvalidateRec(validate_)
{
this.validate = validate_;
}
function FT_Service_CKERNvalidateRec(validate_)
{
this.validate = validate_;
}
/******************************************************************************/
// kerning
/******************************************************************************/
var FT_SERVICE_ID_KERNING = "kerning";
function FT_Service_KerningRec(get_track_)
{
this.get_track = get_track_;
}
/******************************************************************************/
// multi-masters
/******************************************************************************/
var FT_SERVICE_ID_MULTI_MASTERS = "multi-masters";
function FT_Service_MultiMastersRec(get_mm_, set_mm_design_, set_mm_blend_, get_mm_var_, set_var_design_)
{
this.get_mm = get_mm_;
this.set_mm_design = set_mm_design_;
this.set_mm_blend = set_mm_blend_;
this.get_mm_var = get_mm_var_;
this.set_var_design = set_var_design_;
}
/******************************************************************************/
// opentype-validate
/******************************************************************************/
var FT_SERVICE_ID_OPENTYPE_VALIDATE = "opentype-validate";
function FT_Service_OTvalidateRec(validate_)
{
this.validate = validate_;
}
/******************************************************************************/
// pfr-metrics
/******************************************************************************/
var FT_SERVICE_ID_PFR_METRICS = "pfr-metrics";
function FT_Service_PfrMetricsRec(get_metrics_,get_kerning_,get_advance_)
{
this.get_metrics = get_metrics_;
this.get_kerning = get_kerning_;
this.get_advance = get_advance_;
}
/******************************************************************************/
// postscript-font-name
/******************************************************************************/
var FT_SERVICE_ID_POSTSCRIPT_FONT_NAME = "postscript-font-name";
function FT_Service_PsFontNameRec(get_ps_font_name_)
{
this.get_ps_font_name = get_ps_font_name_;
}
/******************************************************************************/
// postscript-cmaps
/******************************************************************************/
var FT_SERVICE_ID_POSTSCRIPT_CMAPS = "postscript-cmaps";
function PS_UniMap()
{
this.unicode;
this.glyph_index;
}
function PS_UnicodesRec()
{
this.cmap;
this.num_maps;
this.maps;
}
function FT_Service_PsCMapsRec(unicode_value_, unicodes_init_,unicodes_char_index_, unicodes_char_next_, macintosh_name_,
adobe_std_strings_, adobe_std_encoding_, adobe_expert_encoding_)
{
this.unicode_value = unicode_value_;
this.unicodes_init = unicodes_init_;
this.unicodes_char_index = unicodes_char_index_;
this.unicodes_char_next = unicodes_char_next_;
this.macintosh_name = macintosh_name_;
this.adobe_std_strings = adobe_std_strings_;
this.adobe_std_encoding = adobe_std_strings_;
this.adobe_expert_encoding = adobe_expert_encoding_;
}
/******************************************************************************/
// postscript-info
/******************************************************************************/
var FT_SERVICE_ID_POSTSCRIPT_INFO = "postscript-info";
function FT_Service_PsInfoRec(get_font_info_, ps_get_font_extra_, has_glyph_names_,get_font_private_, get_font_value_)
{
this.ps_get_font_info = get_font_info_;
this.ps_get_font_extra = ps_get_font_extra_;
this.ps_has_glyph_names = has_glyph_names_;
this.ps_get_font_private = get_font_private_;
this.ps_get_font_value = get_font_value_;
}
/******************************************************************************/
// sfnt-table
/******************************************************************************/
var FT_SERVICE_ID_SFNT_TABLE = "sfnt-table";
function FT_Service_SFNT_TableRec(load_, get_, info_)
{
this.load_table = load_;
this.get_table = get_;
this.table_info = info_;
}
/******************************************************************************/
// tt-cmaps
/******************************************************************************/
var FT_SERVICE_ID_TT_CMAP = "tt-cmaps";
function TT_CMapInfo()
{
this.language;
this.format;
}
function FT_Service_TTCMapsRec(get_cmap_info_)
{
this.get_cmap_info = get_cmap_info_;
}
/******************************************************************************/
// truetype-engine
/******************************************************************************/
var FT_SERVICE_ID_TRUETYPE_ENGINE = "truetype-engine";
function FT_Service_TrueTypeEngineRec(engine_type_)
{
this.engine_type = engine_type_;
}
/******************************************************************************/
// tt-glyf
/******************************************************************************/
var FT_SERVICE_ID_TT_GLYF = "tt-glyf";
function FT_Service_TTGlyfRec(get_location_)
{
this.get_location = get_location_;
}
/******************************************************************************/
// winfonts
/******************************************************************************/
var FT_SERVICE_ID_WINFNT = "winfonts";
function FT_Service_WinFntRec(get_header_)
{
this.get_header = get_header_;
}
/******************************************************************************/
// xf86
/******************************************************************************/
var FT_SERVICE_ID_XF86_NAME = "xf86-driver-name";
var FT_XF86_FORMAT_TRUETYPE = "TrueType";
var FT_XF86_FORMAT_TYPE_1 = "Type 1";
var FT_XF86_FORMAT_BDF = "BDF";
var FT_XF86_FORMAT_PCF = "PCF";
var FT_XF86_FORMAT_TYPE_42 = "Type 42";
var FT_XF86_FORMAT_CID = "CID Type 1";
var FT_XF86_FORMAT_CFF = "CFF";
var FT_XF86_FORMAT_PFR = "PFR";
var FT_XF86_FORMAT_WINFNT = "Windows FNT";
/******************************************************************************/
function FT_ServiceDescRec(id,data)
{
this.serv_id = id;
this.serv_data = data;
}
function ft_service_list_lookup(service_descriptors,service_id)
{
var c = service_descriptors.length;
for (var i=0;i<c;i++)
{
if (service_descriptors[i].serv_id == service_id)
return service_descriptors[i].serv_data;
}
return null;
}
function FT_FACE_FIND_SERVICE(face, id)
{
var module = face.driver;
if (module.clazz.get_interface)
return module.clazz.get_interface(module, id);
return null;
}
function FT_FACE_FIND_GLOBAL_SERVICE(face, name)
{
return ft_module_get_service(face.driver, name);
}
function ft_module_get_service(module, name)
{
var result = null;
if (module != null)
{
if (null != module.clazz.get_interface)
result = module.clazz.get_interface(module, name);
if (null == result)
{
var modules = module.library.modules;
var count = modules.length;
for (var i = 0;i<count;i++)
{
if (modules[i].clazz.get_interface)
{
result = modules[i].clazz.get_interface(modules[i], name);
if (null != result)
break;
}
}
}
}
return result;
}
function FT_ServiceCache()
{
this.service_POSTSCRIPT_FONT_NAME = null;
this.service_MULTI_MASTERS = null;
this.service_GLYPH_DICT = null;
this.service_PFR_METRICS = null;
this.service_WINFNT = null;
}
\ No newline at end of file
Как пользоваться:
1) открыть index.html
2) скопировать все из странички
3) вставить в функцию GetConfigMap (main.cpp)
4) запустить generator (из папки Debug/Release, чтобы файл font_engine.js положился туда, куда надо)
\ No newline at end of file
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
CONFIG -= debug_and_release debug_and_release_target
SOURCES += main.cpp
linux-g++ | linux-g++-64 | linux-g++-32 {
DEFINES += \
LINUX \
_LINUX \
_LINUX_QT
}
mac {
DEFINES += \
LINUX \
_LINUX \
_LINUX_QT \
_MAC \
MAC \
QT_MAC \
_MAC_ \
__MAC__
}
win32 {
DEFINES += \
WIN32
}
<!doctype html>
<html>
<head>
<title>FontEngine</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=IE8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<script type="text/javascript" src="../Freetype/config.js"></script>
<script type="text/javascript" src="../Freetype/base.js"></script>
<script type="text/javascript" src="../Freetype/services.js"></script>
<script type="text/javascript" src="../Freetype/modules/psaux.js"></script>
<script type="text/javascript" src="../Freetype/modules/psnames.js"></script>
<script type="text/javascript" src="../Freetype/modules/render.js"></script>
<script type="text/javascript" src="../Freetype/modules/sfnt.js"></script>
<script type="text/javascript" src="../Freetype/drivers/truetype.js"></script>
<script type="text/javascript" src="../Freetype/drivers/cff.js"></script>
<script type="text/javascript" src="../Freetype/drivers/cid.js"></script>
<script type="text/javascript" src="../Freetype/drivers/t1.js"></script>
<script type="text/javascript" src="../Freetype/drivers/ttinterp.js"></script>
<script type="text/javascript" src="../Freetype/freetype.js"></script>
</head>
<body>
<div id="log" style="font-family:Courier New"/>
<script>
function _correct(_src)
{
var res = _src;
res = res.replace(/&/g,'&amp;');
res = res.replace(/</g,'&lt;');
res = res.replace(/>/g,'&gt;');
res = res.replace(/'/g,'&apos;');
res = res.replace(/"/g,'&quot;');
return res;
}
var _log = "";
var _br = "<br/>";
var __obj = {};
var __arr = [];
for (var i in FT_Common)
{
if (true === FT_Common[i])
{
__arr.push("" + i);
__obj["" + i] = "true";
}
else if (false === FT_Common[i])
{
__arr.push("" + i);
__obj["" + i] = "false";
}
else
{
var tof = typeof FT_Common[i];
if (tof == "number")
{
__arr.push("" + i);
__obj["" + i] = "" + FT_Common[i];
}
}
}
function compareStrings(a, b)
{
if (a == b)
return 0;
if (a.indexOf(b) != -1)
return -1;
if (b.indexOf(a) != -1)
return 1;
return (a < b) ? -1 : (a > b) ? 1 : 0;
}
__arr.sort(compareStrings);
for (var i = 0; i < __arr.length; i++)
{
_log += _correct("_vec1.push_back(L\"FT_Common." + __arr[i] + "\"); ");
_log += _correct("_vec2.push_back(L\"" + __obj[__arr[i]] + "\");");
_log += _br;
}
/*
for (var i in FT_Common)
{
if (true === FT_Common[i])
{
_log += _correct("_vec1.push_back(L\"FT_Common." + i + "\"); ");
_log += _correct("_vec2.push_back(L\"true\");");
_log += _br;
}
else if (false === FT_Common[i])
{
_log += _correct("_vec1.push_back(L\"FT_Common." + i + "\"); ");
_log += _correct("_vec2.push_back(L\"false\");");
_log += _br;
}
else
{
var tof = typeof FT_Common[i];
if (tof == "number")
{
_log += _correct("_vec1.push_back(L\"FT_Common." + i + "\"); ");
_log += _correct("_vec2.push_back(L\"" + FT_Common[i] + "\");");
_log += _br;
}
}
}
*/
document.getElementById("log").innerHTML = _log;
</script>
</body>
</html>
\ No newline at end of file
#include <iostream>
#include <vector>
#include <map>
#include "../../../../../ServerComponents/DesktopEditor/common/File.h"
using namespace std;
void GetConfigMap(std::vector<std::wstring>& _vec1, std::vector<std::wstring>& _vec2)
{
_vec1.push_back(L"FT_Common.AFM_MAX_ARGUMENTS"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.AFM_STREAM_STATUS_EOC"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.AFM_STREAM_STATUS_EOF"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.AFM_STREAM_STATUS_EOL"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.AFM_STREAM_STATUS_NORMAL"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ASCENDER"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.AFM_TOKEN_AXISLABEL"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.AFM_TOKEN_AXISTYPE"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.AFM_TOKEN_BLENDAXISTYPES"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.AFM_TOKEN_BLENDDESIGNMAP"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.AFM_TOKEN_BLENDDESIGNPOSITIONS"); _vec2.push_back(L"6");
_vec1.push_back(L"FT_Common.AFM_TOKEN_B"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.AFM_TOKEN_CAPHEIGHT"); _vec2.push_back(L"10");
_vec1.push_back(L"FT_Common.AFM_TOKEN_CC"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.AFM_TOKEN_CHARACTERSET"); _vec2.push_back(L"12");
_vec1.push_back(L"FT_Common.AFM_TOKEN_CHARACTERS"); _vec2.push_back(L"13");
_vec1.push_back(L"FT_Common.AFM_TOKEN_CHARWIDTH"); _vec2.push_back(L"11");
_vec1.push_back(L"FT_Common.AFM_TOKEN_CH"); _vec2.push_back(L"9");
_vec1.push_back(L"FT_Common.AFM_TOKEN_C"); _vec2.push_back(L"7");
_vec1.push_back(L"FT_Common.AFM_TOKEN_DESCENDER"); _vec2.push_back(L"14");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ENCODINGSCHEME"); _vec2.push_back(L"15");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ENDAXIS"); _vec2.push_back(L"16");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ENDCHARMETRICS"); _vec2.push_back(L"17");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ENDCOMPOSITES"); _vec2.push_back(L"18");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ENDDIRECTION"); _vec2.push_back(L"19");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ENDFONTMETRICS"); _vec2.push_back(L"20");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ENDKERNDATA"); _vec2.push_back(L"21");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ENDKERNPAIRS"); _vec2.push_back(L"22");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ENDTRACKKERN"); _vec2.push_back(L"23");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ESCCHAR"); _vec2.push_back(L"24");
_vec1.push_back(L"FT_Common.AFM_TOKEN_FAMILYNAME"); _vec2.push_back(L"25");
_vec1.push_back(L"FT_Common.AFM_TOKEN_FONTBBOX"); _vec2.push_back(L"26");
_vec1.push_back(L"FT_Common.AFM_TOKEN_FONTNAME"); _vec2.push_back(L"27");
_vec1.push_back(L"FT_Common.AFM_TOKEN_FULLNAME"); _vec2.push_back(L"28");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ISBASEFONT"); _vec2.push_back(L"29");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ISCIDFONT"); _vec2.push_back(L"30");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ISFIXEDPITCH"); _vec2.push_back(L"31");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ISFIXEDV"); _vec2.push_back(L"32");
_vec1.push_back(L"FT_Common.AFM_TOKEN_ITALICANGLE"); _vec2.push_back(L"33");
_vec1.push_back(L"FT_Common.AFM_TOKEN_KPH"); _vec2.push_back(L"35");
_vec1.push_back(L"FT_Common.AFM_TOKEN_KPX"); _vec2.push_back(L"36");
_vec1.push_back(L"FT_Common.AFM_TOKEN_KPY"); _vec2.push_back(L"37");
_vec1.push_back(L"FT_Common.AFM_TOKEN_KP"); _vec2.push_back(L"34");
_vec1.push_back(L"FT_Common.AFM_TOKEN_L"); _vec2.push_back(L"38");
_vec1.push_back(L"FT_Common.AFM_TOKEN_MAPPINGSCHEME"); _vec2.push_back(L"39");
_vec1.push_back(L"FT_Common.AFM_TOKEN_METRICSSETS"); _vec2.push_back(L"40");
_vec1.push_back(L"FT_Common.AFM_TOKEN_NOTICE"); _vec2.push_back(L"42");
_vec1.push_back(L"FT_Common.AFM_TOKEN_N"); _vec2.push_back(L"41");
_vec1.push_back(L"FT_Common.AFM_TOKEN_PCC"); _vec2.push_back(L"43");
_vec1.push_back(L"FT_Common.AFM_TOKEN_STARTAXIS"); _vec2.push_back(L"44");
_vec1.push_back(L"FT_Common.AFM_TOKEN_STARTCHARMETRICS"); _vec2.push_back(L"45");
_vec1.push_back(L"FT_Common.AFM_TOKEN_STARTCOMPOSITES"); _vec2.push_back(L"46");
_vec1.push_back(L"FT_Common.AFM_TOKEN_STARTDIRECTION"); _vec2.push_back(L"47");
_vec1.push_back(L"FT_Common.AFM_TOKEN_STARTFONTMETRICS"); _vec2.push_back(L"48");
_vec1.push_back(L"FT_Common.AFM_TOKEN_STARTKERNDATA"); _vec2.push_back(L"49");
_vec1.push_back(L"FT_Common.AFM_TOKEN_STARTKERNPAIRS0"); _vec2.push_back(L"51");
_vec1.push_back(L"FT_Common.AFM_TOKEN_STARTKERNPAIRS1"); _vec2.push_back(L"52");
_vec1.push_back(L"FT_Common.AFM_TOKEN_STARTKERNPAIRS"); _vec2.push_back(L"50");
_vec1.push_back(L"FT_Common.AFM_TOKEN_STARTTRACKKERN"); _vec2.push_back(L"53");
_vec1.push_back(L"FT_Common.AFM_TOKEN_STDHW"); _vec2.push_back(L"54");
_vec1.push_back(L"FT_Common.AFM_TOKEN_STDVW"); _vec2.push_back(L"55");
_vec1.push_back(L"FT_Common.AFM_TOKEN_TRACKKERN"); _vec2.push_back(L"56");
_vec1.push_back(L"FT_Common.AFM_TOKEN_UNDERLINEPOSITION"); _vec2.push_back(L"57");
_vec1.push_back(L"FT_Common.AFM_TOKEN_UNDERLINETHICKNESS"); _vec2.push_back(L"58");
_vec1.push_back(L"FT_Common.AFM_TOKEN_UNKNOWN"); _vec2.push_back(L"75");
_vec1.push_back(L"FT_Common.AFM_TOKEN_VERSION"); _vec2.push_back(L"61");
_vec1.push_back(L"FT_Common.AFM_TOKEN_VVECTOR"); _vec2.push_back(L"60");
_vec1.push_back(L"FT_Common.AFM_TOKEN_VV"); _vec2.push_back(L"59");
_vec1.push_back(L"FT_Common.AFM_TOKEN_W0X"); _vec2.push_back(L"64");
_vec1.push_back(L"FT_Common.AFM_TOKEN_W0Y"); _vec2.push_back(L"65");
_vec1.push_back(L"FT_Common.AFM_TOKEN_W0"); _vec2.push_back(L"63");
_vec1.push_back(L"FT_Common.AFM_TOKEN_W1X"); _vec2.push_back(L"67");
_vec1.push_back(L"FT_Common.AFM_TOKEN_W1Y"); _vec2.push_back(L"68");
_vec1.push_back(L"FT_Common.AFM_TOKEN_W1"); _vec2.push_back(L"66");
_vec1.push_back(L"FT_Common.AFM_TOKEN_WEIGHTVECTOR"); _vec2.push_back(L"72");
_vec1.push_back(L"FT_Common.AFM_TOKEN_WEIGHT"); _vec2.push_back(L"71");
_vec1.push_back(L"FT_Common.AFM_TOKEN_WX"); _vec2.push_back(L"69");
_vec1.push_back(L"FT_Common.AFM_TOKEN_WY"); _vec2.push_back(L"70");
_vec1.push_back(L"FT_Common.AFM_TOKEN_W"); _vec2.push_back(L"62");
_vec1.push_back(L"FT_Common.AFM_TOKEN_XHEIGHT"); _vec2.push_back(L"73");
_vec1.push_back(L"FT_Common.AFM_VALUE_TYPE_BOOL"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.AFM_VALUE_TYPE_FIXED"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.AFM_VALUE_TYPE_INDEX"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.AFM_VALUE_TYPE_INTEGER"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.AFM_VALUE_TYPE_NAME"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.AFM_VALUE_TYPE_STRING"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.ARGS_ARE_WORDS"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.ARGS_ARE_XY_VALUES"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.BDF_PROPERTY_TYPE_ATOM"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.BDF_PROPERTY_TYPE_CARDINAL"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.BDF_PROPERTY_TYPE_INTEGER"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.BDF_PROPERTY_TYPE_NONE"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.CFFCODE_PRIVATE"); _vec2.push_back(L"8192");
_vec1.push_back(L"FT_Common.CFFCODE_TOPDICT"); _vec2.push_back(L"4096");
_vec1.push_back(L"FT_Common.CFF_CODE_PRIVATE"); _vec2.push_back(L"8192");
_vec1.push_back(L"FT_Common.CFF_CODE_TOPDICT"); _vec2.push_back(L"4096");
_vec1.push_back(L"FT_Common.CFF_COUNT_CHECK_WIDTH"); _vec2.push_back(L"128");
_vec1.push_back(L"FT_Common.CFF_COUNT_CLEAR_STACK"); _vec2.push_back(L"32");
_vec1.push_back(L"FT_Common.CFF_COUNT_EXACT"); _vec2.push_back(L"64");
_vec1.push_back(L"FT_Common.CFF_MAX_CID_FONTS"); _vec2.push_back(L"256");
_vec1.push_back(L"FT_Common.CFF_MAX_OPERANDS"); _vec2.push_back(L"48");
_vec1.push_back(L"FT_Common.CFF_MAX_STACK_DEPTH"); _vec2.push_back(L"96");
_vec1.push_back(L"FT_Common.CFF_MAX_SUBRS_CALLS"); _vec2.push_back(L"32");
_vec1.push_back(L"FT_Common.CFF_MAX_TRANS_ELEMENTS"); _vec2.push_back(L"32");
_vec1.push_back(L"FT_Common.ErrorLongJump"); _vec2.push_back(L"-100");
_vec1.push_back(L"FT_Common.FT_ANGLE_PI2"); _vec2.push_back(L"5898240");
_vec1.push_back(L"FT_Common.FT_ANGLE_PI"); _vec2.push_back(L"11796480");
_vec1.push_back(L"FT_Common.FT_CMAP_0"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_CMAP_12"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.FT_CMAP_13"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.FT_CMAP_14"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.FT_CMAP_1"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_CMAP_4"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_CURVE_TAG_CONIC"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_CURVE_TAG_CUBIC"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_CURVE_TAG_HAS_SCANMODE"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.FT_CURVE_TAG_ON"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_CURVE_TAG_TOUCH_BOTH"); _vec2.push_back(L"24");
_vec1.push_back(L"FT_Common.FT_CURVE_TAG_TOUCH_X"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.FT_CURVE_TAG_TOUCH_Y"); _vec2.push_back(L"16");
_vec1.push_back(L"FT_Common.FT_ENCODING_ADOBE_CUSTOM"); _vec2.push_back(L"1094992451");
_vec1.push_back(L"FT_Common.FT_ENCODING_ADOBE_EXPERT"); _vec2.push_back(L"1094992453");
_vec1.push_back(L"FT_Common.FT_ENCODING_ADOBE_LATIN_1"); _vec2.push_back(L"1818326065");
_vec1.push_back(L"FT_Common.FT_ENCODING_ADOBE_STANDARD"); _vec2.push_back(L"1094995778");
_vec1.push_back(L"FT_Common.FT_ENCODING_APPLE_ROMAN"); _vec2.push_back(L"1634889070");
_vec1.push_back(L"FT_Common.FT_ENCODING_BIG5"); _vec2.push_back(L"1651074869");
_vec1.push_back(L"FT_Common.FT_ENCODING_GB2312"); _vec2.push_back(L"1734484000");
_vec1.push_back(L"FT_Common.FT_ENCODING_JOHAB"); _vec2.push_back(L"1785686113");
_vec1.push_back(L"FT_Common.FT_ENCODING_MS_BIG5"); _vec2.push_back(L"1651074869");
_vec1.push_back(L"FT_Common.FT_ENCODING_MS_GB2312"); _vec2.push_back(L"1734484000");
_vec1.push_back(L"FT_Common.FT_ENCODING_MS_JOHAB"); _vec2.push_back(L"1785686113");
_vec1.push_back(L"FT_Common.FT_ENCODING_MS_SJIS"); _vec2.push_back(L"1936353651");
_vec1.push_back(L"FT_Common.FT_ENCODING_MS_SYMBOL"); _vec2.push_back(L"1937337698");
_vec1.push_back(L"FT_Common.FT_ENCODING_MS_WANSUNG"); _vec2.push_back(L"2002873971");
_vec1.push_back(L"FT_Common.FT_ENCODING_NONE"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_ENCODING_OLD_LATIN_2"); _vec2.push_back(L"1818326066");
_vec1.push_back(L"FT_Common.FT_ENCODING_SJIS"); _vec2.push_back(L"1936353651");
_vec1.push_back(L"FT_Common.FT_ENCODING_UNICODE"); _vec2.push_back(L"1970170211");
_vec1.push_back(L"FT_Common.FT_ENCODING_WANSUNG"); _vec2.push_back(L"2002873971");
_vec1.push_back(L"FT_Common.FT_Err_Array_Too_Large"); _vec2.push_back(L"10");
_vec1.push_back(L"FT_Common.FT_Err_Bad_Argument"); _vec2.push_back(L"132");
_vec1.push_back(L"FT_Common.FT_Err_Bbx_Too_Big"); _vec2.push_back(L"184");
_vec1.push_back(L"FT_Common.FT_Err_CMap_Table_Missing"); _vec2.push_back(L"146");
_vec1.push_back(L"FT_Common.FT_Err_Cannot_Open_Resource"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_Err_Cannot_Open_Stream"); _vec2.push_back(L"81");
_vec1.push_back(L"FT_Common.FT_Err_Cannot_Render_Glyph"); _vec2.push_back(L"19");
_vec1.push_back(L"FT_Common.FT_Err_Code_Overflow"); _vec2.push_back(L"131");
_vec1.push_back(L"FT_Common.FT_Err_Corrupted_Font_Glyphs"); _vec2.push_back(L"186");
_vec1.push_back(L"FT_Common.FT_Err_Corrupted_Font_Header"); _vec2.push_back(L"185");
_vec1.push_back(L"FT_Common.FT_Err_Could_Not_Find_Context"); _vec2.push_back(L"153");
_vec1.push_back(L"FT_Common.FT_Err_Debug_OpCode"); _vec2.push_back(L"135");
_vec1.push_back(L"FT_Common.FT_Err_Divide_By_Zero"); _vec2.push_back(L"133");
_vec1.push_back(L"FT_Common.FT_Err_ENDF_In_Exec_Stream"); _vec2.push_back(L"136");
_vec1.push_back(L"FT_Common.FT_Err_Execution_Too_Long"); _vec2.push_back(L"139");
_vec1.push_back(L"FT_Common.FT_Err_Hmtx_Table_Missing"); _vec2.push_back(L"147");
_vec1.push_back(L"FT_Common.FT_Err_Horiz_Header_Missing"); _vec2.push_back(L"143");
_vec1.push_back(L"FT_Common.FT_Err_Ignore"); _vec2.push_back(L"162");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Argument"); _vec2.push_back(L"6");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Cache_Handle"); _vec2.push_back(L"39");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_CharMap_Format"); _vec2.push_back(L"150");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_CharMap_Handle"); _vec2.push_back(L"38");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Character_Code"); _vec2.push_back(L"17");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_CodeRange"); _vec2.push_back(L"138");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Composite"); _vec2.push_back(L"21");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Driver_Handle"); _vec2.push_back(L"34");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Face_Handle"); _vec2.push_back(L"35");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_File_Format"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Frame_Operation"); _vec2.push_back(L"86");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Frame_Read"); _vec2.push_back(L"88");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Glyph_Format"); _vec2.push_back(L"18");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Glyph_Index"); _vec2.push_back(L"16");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Handle"); _vec2.push_back(L"32");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Horiz_Metrics"); _vec2.push_back(L"149");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Library_Handle"); _vec2.push_back(L"33");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Offset"); _vec2.push_back(L"9");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Opcode"); _vec2.push_back(L"128");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Outline"); _vec2.push_back(L"20");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_PPem"); _vec2.push_back(L"151");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Pixel_Size"); _vec2.push_back(L"23");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Post_Table_Format"); _vec2.push_back(L"154");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Post_Table"); _vec2.push_back(L"155");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Reference"); _vec2.push_back(L"134");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Size_Handle"); _vec2.push_back(L"36");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Slot_Handle"); _vec2.push_back(L"37");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Stream_Handle"); _vec2.push_back(L"40");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Stream_Operation"); _vec2.push_back(L"85");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Stream_Read"); _vec2.push_back(L"84");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Stream_Seek"); _vec2.push_back(L"82");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Stream_Skip"); _vec2.push_back(L"83");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Table"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Version"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.FT_Err_Invalid_Vert_Metrics"); _vec2.push_back(L"152");
_vec1.push_back(L"FT_Common.FT_Err_Locations_Missing"); _vec2.push_back(L"144");
_vec1.push_back(L"FT_Common.FT_Err_Lower_Module_Version"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.FT_Err_Missing_Bbx_Field"); _vec2.push_back(L"183");
_vec1.push_back(L"FT_Common.FT_Err_Missing_Chars_Field"); _vec2.push_back(L"180");
_vec1.push_back(L"FT_Common.FT_Err_Missing_Encoding_Field"); _vec2.push_back(L"182");
_vec1.push_back(L"FT_Common.FT_Err_Missing_Font_Field"); _vec2.push_back(L"177");
_vec1.push_back(L"FT_Common.FT_Err_Missing_Fontboundingbox_Field"); _vec2.push_back(L"179");
_vec1.push_back(L"FT_Common.FT_Err_Missing_Size_Field"); _vec2.push_back(L"178");
_vec1.push_back(L"FT_Common.FT_Err_Missing_Startchar_Field"); _vec2.push_back(L"181");
_vec1.push_back(L"FT_Common.FT_Err_Missing_Startfont_Field"); _vec2.push_back(L"176");
_vec1.push_back(L"FT_Common.FT_Err_Name_Table_Missing"); _vec2.push_back(L"145");
_vec1.push_back(L"FT_Common.FT_Err_Nested_DEFS"); _vec2.push_back(L"137");
_vec1.push_back(L"FT_Common.FT_Err_Nested_Frame_Access"); _vec2.push_back(L"87");
_vec1.push_back(L"FT_Common.FT_Err_No_Unicode_Glyph_Name"); _vec2.push_back(L"163");
_vec1.push_back(L"FT_Common.FT_Err_Ok"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_Err_Out_Of_Memory"); _vec2.push_back(L"64");
_vec1.push_back(L"FT_Common.FT_Err_Post_Table_Missing"); _vec2.push_back(L"148");
_vec1.push_back(L"FT_Common.FT_Err_Raster_Corrupted"); _vec2.push_back(L"97");
_vec1.push_back(L"FT_Common.FT_Err_Raster_Negative_Height"); _vec2.push_back(L"99");
_vec1.push_back(L"FT_Common.FT_Err_Raster_Overflow"); _vec2.push_back(L"98");
_vec1.push_back(L"FT_Common.FT_Err_Raster_Uninitialized"); _vec2.push_back(L"96");
_vec1.push_back(L"FT_Common.FT_Err_Stack_Overflow"); _vec2.push_back(L"130");
_vec1.push_back(L"FT_Common.FT_Err_Stack_Underflow"); _vec2.push_back(L"161");
_vec1.push_back(L"FT_Common.FT_Err_Syntax_Error"); _vec2.push_back(L"160");
_vec1.push_back(L"FT_Common.FT_Err_Table_Missing"); _vec2.push_back(L"142");
_vec1.push_back(L"FT_Common.FT_Err_Too_Few_Arguments"); _vec2.push_back(L"129");
_vec1.push_back(L"FT_Common.FT_Err_Too_Many_Caches"); _vec2.push_back(L"112");
_vec1.push_back(L"FT_Common.FT_Err_Too_Many_Drivers"); _vec2.push_back(L"48");
_vec1.push_back(L"FT_Common.FT_Err_Too_Many_Extensions"); _vec2.push_back(L"49");
_vec1.push_back(L"FT_Common.FT_Err_Too_Many_Function_Defs"); _vec2.push_back(L"140");
_vec1.push_back(L"FT_Common.FT_Err_Too_Many_Hints"); _vec2.push_back(L"22");
_vec1.push_back(L"FT_Common.FT_Err_Too_Many_Instruction_Defs"); _vec2.push_back(L"141");
_vec1.push_back(L"FT_Common.FT_Err_Unimplemented_Feature"); _vec2.push_back(L"7");
_vec1.push_back(L"FT_Common.FT_Err_Unknown_File_Format"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_Err_Unlisted_Object"); _vec2.push_back(L"65");
_vec1.push_back(L"FT_Common.FT_FACE_FLAG_CID_KEYED"); _vec2.push_back(L"4096");
_vec1.push_back(L"FT_Common.FT_FACE_FLAG_EXTERNAL_STREAM"); _vec2.push_back(L"1024");
_vec1.push_back(L"FT_Common.FT_FACE_FLAG_FAST_GLYPHS"); _vec2.push_back(L"128");
_vec1.push_back(L"FT_Common.FT_FACE_FLAG_FIXED_SIZES"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_FACE_FLAG_FIXED_WIDTH"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.FT_FACE_FLAG_GLYPH_NAMES"); _vec2.push_back(L"512");
_vec1.push_back(L"FT_Common.FT_FACE_FLAG_HINTER"); _vec2.push_back(L"2048");
_vec1.push_back(L"FT_Common.FT_FACE_FLAG_HORIZONTAL"); _vec2.push_back(L"16");
_vec1.push_back(L"FT_Common.FT_FACE_FLAG_KERNING"); _vec2.push_back(L"64");
_vec1.push_back(L"FT_Common.FT_FACE_FLAG_MULTIPLE_MASTERS"); _vec2.push_back(L"256");
_vec1.push_back(L"FT_Common.FT_FACE_FLAG_SCALABLE"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_FACE_FLAG_SFNT"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.FT_FACE_FLAG_TRICKY"); _vec2.push_back(L"8192");
_vec1.push_back(L"FT_Common.FT_FACE_FLAG_VERTICAL"); _vec2.push_back(L"32");
_vec1.push_back(L"FT_Common.FT_GLYPH_BBOX_GRIDFIT"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_GLYPH_BBOX_PIXELS"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.FT_GLYPH_BBOX_SUBPIXELS"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_GLYPH_BBOX_TRUNCATE"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_GLYPH_BBOX_UNSCALED"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_GLYPH_FORMAT_BITMAP"); _vec2.push_back(L"1651078259");
_vec1.push_back(L"FT_Common.FT_GLYPH_FORMAT_COMPOSITE"); _vec2.push_back(L"1668246896");
_vec1.push_back(L"FT_Common.FT_GLYPH_FORMAT_NONE"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_GLYPH_FORMAT_OUTLINE"); _vec2.push_back(L"1869968492");
_vec1.push_back(L"FT_Common.FT_GLYPH_FORMAT_PLOTTER"); _vec2.push_back(L"1886154612");
_vec1.push_back(L"FT_Common.FT_GLYPH_OWN_BITMAP"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_KERNING_DEFAULT"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_KERNING_UNFITTED"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_KERNING_UNSCALED"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_LOAD_ADVANCE_ONLY"); _vec2.push_back(L"256");
_vec1.push_back(L"FT_Common.FT_LOAD_CROP_BITMAP"); _vec2.push_back(L"64");
_vec1.push_back(L"FT_Common.FT_LOAD_DEFAULT"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_LOAD_FORCE_AUTOHINT"); _vec2.push_back(L"32");
_vec1.push_back(L"FT_Common.FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH"); _vec2.push_back(L"512");
_vec1.push_back(L"FT_Common.FT_LOAD_IGNORE_TRANSFORM"); _vec2.push_back(L"2048");
_vec1.push_back(L"FT_Common.FT_LOAD_LINEAR_DESIGN"); _vec2.push_back(L"8192");
_vec1.push_back(L"FT_Common.FT_LOAD_MONOCHROME"); _vec2.push_back(L"4096");
_vec1.push_back(L"FT_Common.FT_LOAD_NO_AUTOHINT"); _vec2.push_back(L"32768");
_vec1.push_back(L"FT_Common.FT_LOAD_NO_BITMAP"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.FT_LOAD_NO_HINTING"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_LOAD_NO_RECURSE"); _vec2.push_back(L"1024");
_vec1.push_back(L"FT_Common.FT_LOAD_NO_SCALE"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_LOAD_PEDANTIC"); _vec2.push_back(L"128");
_vec1.push_back(L"FT_Common.FT_LOAD_RENDER"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.FT_LOAD_SBITS_ONLY"); _vec2.push_back(L"16384");
_vec1.push_back(L"FT_Common.FT_LOAD_VERTICAL_LAYOUT"); _vec2.push_back(L"16");
_vec1.push_back(L"FT_Common.FT_MAX_CHARMAP_CACHEABLE"); _vec2.push_back(L"15");
_vec1.push_back(L"FT_Common.FT_MODULE_DRIVER_HAS_HINTER"); _vec2.push_back(L"1024");
_vec1.push_back(L"FT_Common.FT_MODULE_DRIVER_NO_OUTLINES"); _vec2.push_back(L"512");
_vec1.push_back(L"FT_Common.FT_MODULE_DRIVER_SCALABLE"); _vec2.push_back(L"256");
_vec1.push_back(L"FT_Common.FT_MODULE_FONT_DRIVER"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_MODULE_HINTER"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.FT_MODULE_RENDERER"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_MODULE_STYLER"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.FT_Mod_Err"); _vec2.push_back(L"256");
_vec1.push_back(L"FT_Common.FT_ORIENTATION_FILL_LEFT"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_ORIENTATION_FILL_RIGHT"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_ORIENTATION_NONE"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_ORIENTATION_POSTSCRIPT"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_ORIENTATION_TRUETYPE"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_OUTLINE_EVEN_ODD_FILL"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_OUTLINE_HIGH_PRECISION"); _vec2.push_back(L"256");
_vec1.push_back(L"FT_Common.FT_OUTLINE_IGNORE_DROPOUTS"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.FT_OUTLINE_INCLUDE_STUBS"); _vec2.push_back(L"32");
_vec1.push_back(L"FT_Common.FT_OUTLINE_NONE"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_OUTLINE_OWNER"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_OUTLINE_REVERSE_FILL"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.FT_OUTLINE_SINGLE_PASS"); _vec2.push_back(L"512");
_vec1.push_back(L"FT_Common.FT_OUTLINE_SMART_DROPOUTS"); _vec2.push_back(L"16");
_vec1.push_back(L"FT_Common.FT_PARAM_TAG_UNPATENTED_HINTING"); _vec2.push_back(L"1970172001");
_vec1.push_back(L"FT_Common.FT_PIXEL_MODE_GRAY2"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.FT_PIXEL_MODE_GRAY4"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.FT_PIXEL_MODE_GRAY"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_PIXEL_MODE_LCD_V"); _vec2.push_back(L"6");
_vec1.push_back(L"FT_Common.FT_PIXEL_MODE_LCD"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.FT_PIXEL_MODE_MAX"); _vec2.push_back(L"7");
_vec1.push_back(L"FT_Common.FT_PIXEL_MODE_MONO"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_PIXEL_MODE_NONE"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_RASTER_FLAG_AA"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_RASTER_FLAG_CLIP"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.FT_RASTER_FLAG_DEFAULT"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_RASTER_FLAG_DIRECT"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_RENDER_MODE_LCD_V"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.FT_RENDER_MODE_LCD"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.FT_RENDER_MODE_LIGHT"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_RENDER_MODE_MAX"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.FT_RENDER_MODE_MONO"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_RENDER_MODE_NORMAL"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_SIZE_REQUEST_TYPE_BBOX"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_SIZE_REQUEST_TYPE_CELL"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.FT_SIZE_REQUEST_TYPE_MAX"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.FT_SIZE_REQUEST_TYPE_NOMINAL"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.FT_SIZE_REQUEST_TYPE_REAL_DIM"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_SIZE_REQUEST_TYPE_SCALES"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.FT_STYLE_FLAG_BOLD"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_STYLE_FLAG_ITALIC"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_SUBGLYPH_FLAG_2X2"); _vec2.push_back(L"128");
_vec1.push_back(L"FT_Common.FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.FT_SUBGLYPH_FLAG_SCALE"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.FT_SUBGLYPH_FLAG_USE_MY_METRICS"); _vec2.push_back(L"512");
_vec1.push_back(L"FT_Common.FT_SUBGLYPH_FLAG_XY_SCALE"); _vec2.push_back(L"64");
_vec1.push_back(L"FT_Common.FT_TRIG_MAX_ITERS"); _vec2.push_back(L"23");
_vec1.push_back(L"FT_Common.FT_TRIG_SCALE"); _vec2.push_back(L"2608131496");
_vec1.push_back(L"FT_Common.GX_TC_RESERVED_TUPLE_FLAGS"); _vec2.push_back(L"28672");
_vec1.push_back(L"FT_Common.GX_TC_TUPLES_SHARE_POINT_NUMBERS"); _vec2.push_back(L"32768");
_vec1.push_back(L"FT_Common.GX_TC_TUPLE_COUNT_MASK"); _vec2.push_back(L"4095");
_vec1.push_back(L"FT_Common.GX_TI_EMBEDDED_TUPLE_COORD"); _vec2.push_back(L"32768");
_vec1.push_back(L"FT_Common.GX_TI_INTERMEDIATE_TUPLE"); _vec2.push_back(L"16384");
_vec1.push_back(L"FT_Common.GX_TI_PRIVATE_POINT_NUMBERS"); _vec2.push_back(L"8192");
_vec1.push_back(L"FT_Common.GX_TI_RESERVED_TUPLE_FLAG"); _vec2.push_back(L"4096");
_vec1.push_back(L"FT_Common.GX_TI_TUPLE_INDEX_MASK"); _vec2.push_back(L"4095");
_vec1.push_back(L"FT_Common.MAX_RUNNABLE_OPCODES"); _vec2.push_back(L"1000000");
_vec1.push_back(L"FT_Common.MORE_COMPONENTS"); _vec2.push_back(L"32");
_vec1.push_back(L"FT_Common.N_AFM_TOKENS"); _vec2.push_back(L"74");
_vec1.push_back(L"FT_Common.OVERLAP_COMPOUND"); _vec2.push_back(L"1024");
_vec1.push_back(L"FT_Common.PS_DICT_BLUE_FUZZ"); _vec2.push_back(L"17");
_vec1.push_back(L"FT_Common.PS_DICT_BLUE_SCALE"); _vec2.push_back(L"24");
_vec1.push_back(L"FT_Common.PS_DICT_BLUE_SHIFT"); _vec2.push_back(L"25");
_vec1.push_back(L"FT_Common.PS_DICT_BLUE_VALUE"); _vec2.push_back(L"16");
_vec1.push_back(L"FT_Common.PS_DICT_CHAR_STRING_KEY"); _vec2.push_back(L"7");
_vec1.push_back(L"FT_Common.PS_DICT_CHAR_STRING"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.PS_DICT_ENCODING_ENTRY"); _vec2.push_back(L"10");
_vec1.push_back(L"FT_Common.PS_DICT_ENCODING_TYPE"); _vec2.push_back(L"9");
_vec1.push_back(L"FT_Common.PS_DICT_FAMILY_BLUE"); _vec2.push_back(L"21");
_vec1.push_back(L"FT_Common.PS_DICT_FAMILY_NAME"); _vec2.push_back(L"39");
_vec1.push_back(L"FT_Common.PS_DICT_FAMILY_OTHER_BLUE"); _vec2.push_back(L"23");
_vec1.push_back(L"FT_Common.PS_DICT_FONT_BBOX"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.PS_DICT_FONT_MATRIX"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.PS_DICT_FONT_NAME"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.PS_DICT_FONT_TYPE"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.PS_DICT_FORCE_BOLD"); _vec2.push_back(L"30");
_vec1.push_back(L"FT_Common.PS_DICT_FS_TYPE"); _vec2.push_back(L"44");
_vec1.push_back(L"FT_Common.PS_DICT_FULL_NAME"); _vec2.push_back(L"38");
_vec1.push_back(L"FT_Common.PS_DICT_IS_FIXED_PITCH"); _vec2.push_back(L"41");
_vec1.push_back(L"FT_Common.PS_DICT_ITALIC_ANGLE"); _vec2.push_back(L"45");
_vec1.push_back(L"FT_Common.PS_DICT_LANGUAGE_GROUP"); _vec2.push_back(L"35");
_vec1.push_back(L"FT_Common.PS_DICT_LEN_IV"); _vec2.push_back(L"33");
_vec1.push_back(L"FT_Common.PS_DICT_MAX"); _vec2.push_back(L"45");
_vec1.push_back(L"FT_Common.PS_DICT_MIN_FEATURE"); _vec2.push_back(L"32");
_vec1.push_back(L"FT_Common.PS_DICT_NOTICE"); _vec2.push_back(L"37");
_vec1.push_back(L"FT_Common.PS_DICT_NUM_BLUE_VALUES"); _vec2.push_back(L"15");
_vec1.push_back(L"FT_Common.PS_DICT_NUM_CHAR_STRINGS"); _vec2.push_back(L"6");
_vec1.push_back(L"FT_Common.PS_DICT_NUM_FAMILY_BLUES"); _vec2.push_back(L"20");
_vec1.push_back(L"FT_Common.PS_DICT_NUM_FAMILY_OTHER_BLUES"); _vec2.push_back(L"22");
_vec1.push_back(L"FT_Common.PS_DICT_NUM_OTHER_BLUES"); _vec2.push_back(L"18");
_vec1.push_back(L"FT_Common.PS_DICT_NUM_STEM_SNAP_H"); _vec2.push_back(L"26");
_vec1.push_back(L"FT_Common.PS_DICT_NUM_STEM_SNAP_V"); _vec2.push_back(L"28");
_vec1.push_back(L"FT_Common.PS_DICT_NUM_SUBRS"); _vec2.push_back(L"11");
_vec1.push_back(L"FT_Common.PS_DICT_OTHER_BLUE"); _vec2.push_back(L"19");
_vec1.push_back(L"FT_Common.PS_DICT_PAINT_TYPE"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.PS_DICT_PASSWORD"); _vec2.push_back(L"34");
_vec1.push_back(L"FT_Common.PS_DICT_RND_STEM_UP"); _vec2.push_back(L"31");
_vec1.push_back(L"FT_Common.PS_DICT_STD_HW"); _vec2.push_back(L"13");
_vec1.push_back(L"FT_Common.PS_DICT_STD_VW"); _vec2.push_back(L"14");
_vec1.push_back(L"FT_Common.PS_DICT_STEM_SNAP_H"); _vec2.push_back(L"27");
_vec1.push_back(L"FT_Common.PS_DICT_STEM_SNAP_V"); _vec2.push_back(L"29");
_vec1.push_back(L"FT_Common.PS_DICT_SUBR"); _vec2.push_back(L"12");
_vec1.push_back(L"FT_Common.PS_DICT_UNDERLINE_POSITION"); _vec2.push_back(L"42");
_vec1.push_back(L"FT_Common.PS_DICT_UNDERLINE_THICKNESS"); _vec2.push_back(L"43");
_vec1.push_back(L"FT_Common.PS_DICT_UNIQUE_ID"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.PS_DICT_VERSION"); _vec2.push_back(L"36");
_vec1.push_back(L"FT_Common.PS_DICT_WEIGHT"); _vec2.push_back(L"40");
_vec1.push_back(L"FT_Common.ROUND_XY_TO_GRID"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.SCALED_COMPONENT_OFFSET"); _vec2.push_back(L"2048");
_vec1.push_back(L"FT_Common.SPH_OPTION_BITMAP_WIDTHS"); _vec2.push_back(L"false");
_vec1.push_back(L"FT_Common.SPH_OPTION_SET_COMPATIBLE_WIDTHS"); _vec2.push_back(L"false");
_vec1.push_back(L"FT_Common.SPH_OPTION_SET_GRAYSCALE"); _vec2.push_back(L"false");
_vec1.push_back(L"FT_Common.SPH_OPTION_SET_RASTERIZER_VERSION"); _vec2.push_back(L"38");
_vec1.push_back(L"FT_Common.SPH_OPTION_SET_SUBPIXEL"); _vec2.push_back(L"true");
_vec1.push_back(L"FT_Common.SPH_TWEAK_ALLOW_X_DMOVEX"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.SPH_TWEAK_ALLOW_X_DMOVE"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.SPH_TWEAK_ALLOW_X_MOVE_ZP2"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.SPH_TWEAK_ALWAYS_DO_DELTAP"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.SPH_TWEAK_ALWAYS_SKIP_DELTAP"); _vec2.push_back(L"16");
_vec1.push_back(L"FT_Common.SPH_TWEAK_COURIER_NEW_2_HACK"); _vec2.push_back(L"32");
_vec1.push_back(L"FT_Common.SPH_TWEAK_DEEMBOLDEN"); _vec2.push_back(L"64");
_vec1.push_back(L"FT_Common.SPH_TWEAK_DELTAP_SKIP_EXAGGERATED_VALUES"); _vec2.push_back(L"128");
_vec1.push_back(L"FT_Common.SPH_TWEAK_DO_SHPIX"); _vec2.push_back(L"256");
_vec1.push_back(L"FT_Common.SPH_TWEAK_EMBOLDEN"); _vec2.push_back(L"512");
_vec1.push_back(L"FT_Common.SPH_TWEAK_MIAP_HACK"); _vec2.push_back(L"1024");
_vec1.push_back(L"FT_Common.SPH_TWEAK_MIRP_CVT_ZERO"); _vec2.push_back(L"8388608");
_vec1.push_back(L"FT_Common.SPH_TWEAK_NORMAL_ROUND"); _vec2.push_back(L"2048");
_vec1.push_back(L"FT_Common.SPH_TWEAK_NO_ALIGNRP_AFTER_IUP"); _vec2.push_back(L"4096");
_vec1.push_back(L"FT_Common.SPH_TWEAK_NO_CALL_AFTER_IUP"); _vec2.push_back(L"8192");
_vec1.push_back(L"FT_Common.SPH_TWEAK_NO_DELTAP_AFTER_IUP"); _vec2.push_back(L"16384");
_vec1.push_back(L"FT_Common.SPH_TWEAK_PIXEL_HINTING"); _vec2.push_back(L"32768");
_vec1.push_back(L"FT_Common.SPH_TWEAK_RASTERIZER_35"); _vec2.push_back(L"65536");
_vec1.push_back(L"FT_Common.SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES"); _vec2.push_back(L"131072");
_vec1.push_back(L"FT_Common.SPH_TWEAK_SKIP_INLINE_DELTAS"); _vec2.push_back(L"262144");
_vec1.push_back(L"FT_Common.SPH_TWEAK_SKIP_IUP"); _vec2.push_back(L"524288");
_vec1.push_back(L"FT_Common.SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES"); _vec2.push_back(L"1048576");
_vec1.push_back(L"FT_Common.SPH_TWEAK_SKIP_OFFPIXEL_Y_MOVES"); _vec2.push_back(L"2097152");
_vec1.push_back(L"FT_Common.SPH_TWEAK_TIMES_NEW_ROMAN_HACK"); _vec2.push_back(L"4194304");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_0"); _vec2.push_back(L"48");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_7"); _vec2.push_back(L"55");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_9"); _vec2.push_back(L"57");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_A"); _vec2.push_back(L"65");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_BS"); _vec2.push_back(L"47");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_B"); _vec2.push_back(L"66");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_C"); _vec2.push_back(L"67");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_D"); _vec2.push_back(L"68");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_E"); _vec2.push_back(L"69");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_F"); _vec2.push_back(L"70");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_G"); _vec2.push_back(L"71");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_H"); _vec2.push_back(L"72");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_I"); _vec2.push_back(L"73");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_J"); _vec2.push_back(L"74");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_K"); _vec2.push_back(L"75");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_LOGOR"); _vec2.push_back(L"124");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_LS1"); _vec2.push_back(L"40");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_LS2"); _vec2.push_back(L"91");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_LS3"); _vec2.push_back(L"123");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_L"); _vec2.push_back(L"76");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_MATH_1"); _vec2.push_back(L"60");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_MATH_2"); _vec2.push_back(L"62");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_MATH_3"); _vec2.push_back(L"37");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_MATH_MINUS"); _vec2.push_back(L"45");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_MATH_PLUS"); _vec2.push_back(L"43");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_M"); _vec2.push_back(L"77");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_N"); _vec2.push_back(L"78");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_O"); _vec2.push_back(L"79");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_POINT"); _vec2.push_back(L"46");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_P"); _vec2.push_back(L"80");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_Q"); _vec2.push_back(L"81");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_RS1"); _vec2.push_back(L"41");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_RS2"); _vec2.push_back(L"93");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_RS3"); _vec2.push_back(L"125");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_R"); _vec2.push_back(L"82");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_S0"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_SERP"); _vec2.push_back(L"59");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_SF"); _vec2.push_back(L"12");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_SHARP"); _vec2.push_back(L"35");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_SN"); _vec2.push_back(L"10");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_SPACE"); _vec2.push_back(L"32");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_SR"); _vec2.push_back(L"13");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_SS"); _vec2.push_back(L"92");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_ST"); _vec2.push_back(L"9");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_S"); _vec2.push_back(L"83");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_T"); _vec2.push_back(L"84");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_U"); _vec2.push_back(L"85");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_VOPROS"); _vec2.push_back(L"63");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_VOSCL"); _vec2.push_back(L"33");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_V"); _vec2.push_back(L"86");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_W"); _vec2.push_back(L"87");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_X"); _vec2.push_back(L"88");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_Y"); _vec2.push_back(L"89");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_Z"); _vec2.push_back(L"90");
_vec1.push_back(L"FT_Common.SYMBOL_CONST__"); _vec2.push_back(L"95");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_a"); _vec2.push_back(L"97");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_b"); _vec2.push_back(L"98");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_c"); _vec2.push_back(L"99");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_d"); _vec2.push_back(L"100");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_e"); _vec2.push_back(L"101");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_f"); _vec2.push_back(L"102");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_g"); _vec2.push_back(L"103");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_h"); _vec2.push_back(L"104");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_i"); _vec2.push_back(L"105");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_j"); _vec2.push_back(L"106");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_k"); _vec2.push_back(L"107");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_l"); _vec2.push_back(L"108");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_m"); _vec2.push_back(L"109");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_n"); _vec2.push_back(L"110");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_o"); _vec2.push_back(L"111");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_p"); _vec2.push_back(L"112");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_q"); _vec2.push_back(L"113");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_r"); _vec2.push_back(L"114");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_s"); _vec2.push_back(L"115");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_t"); _vec2.push_back(L"116");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_u"); _vec2.push_back(L"117");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_v"); _vec2.push_back(L"118");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_w"); _vec2.push_back(L"119");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_x"); _vec2.push_back(L"120");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_y"); _vec2.push_back(L"121");
_vec1.push_back(L"FT_Common.SYMBOL_CONST_z"); _vec2.push_back(L"122");
_vec1.push_back(L"FT_Common.T1_BLEND_BLUE_SCALE"); _vec2.push_back(L"9");
_vec1.push_back(L"FT_Common.T1_BLEND_BLUE_SHIFT"); _vec2.push_back(L"10");
_vec1.push_back(L"FT_Common.T1_BLEND_BLUE_VALUES"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.T1_BLEND_FAMILY_BLUES"); _vec2.push_back(L"11");
_vec1.push_back(L"FT_Common.T1_BLEND_FAMILY_OTHER_BLUES"); _vec2.push_back(L"12");
_vec1.push_back(L"FT_Common.T1_BLEND_FORCE_BOLD"); _vec2.push_back(L"13");
_vec1.push_back(L"FT_Common.T1_BLEND_ITALIC_ANGLE"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.T1_BLEND_MAX"); _vec2.push_back(L"14");
_vec1.push_back(L"FT_Common.T1_BLEND_OTHER_BLUES"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.T1_BLEND_STANDARD_HEIGHT"); _vec2.push_back(L"6");
_vec1.push_back(L"FT_Common.T1_BLEND_STANDARD_WIDTH"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.T1_BLEND_STEM_SNAP_HEIGHTS"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.T1_BLEND_STEM_SNAP_WIDTHS"); _vec2.push_back(L"7");
_vec1.push_back(L"FT_Common.T1_BLEND_UNDERLINE_POSITION"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.T1_BLEND_UNDERLINE_THICKNESS"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.T1_ENCODING_TYPE_ARRAY"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.T1_ENCODING_TYPE_EXPERT"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.T1_ENCODING_TYPE_ISOLATIN1"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.T1_ENCODING_TYPE_NONE"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.T1_ENCODING_TYPE_STANDARD"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.T1_FIELD_DICT_FONTDICT"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.T1_FIELD_DICT_PRIVATE"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.T1_FIELD_LOCATION_BBOX"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.T1_FIELD_LOCATION_BLEND"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.T1_FIELD_LOCATION_CID_INFO"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.T1_FIELD_LOCATION_FACE"); _vec2.push_back(L"7");
_vec1.push_back(L"FT_Common.T1_FIELD_LOCATION_FONT_DICT"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.T1_FIELD_LOCATION_FONT_EXTRA"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.T1_FIELD_LOCATION_FONT_INFO"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.T1_FIELD_LOCATION_LOADER"); _vec2.push_back(L"6");
_vec1.push_back(L"FT_Common.T1_FIELD_LOCATION_MAX"); _vec2.push_back(L"9");
_vec1.push_back(L"FT_Common.T1_FIELD_LOCATION_PRIVATE"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.T1_FIELD_TYPE_BBOX"); _vec2.push_back(L"7");
_vec1.push_back(L"FT_Common.T1_FIELD_TYPE_BOOL"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.T1_FIELD_TYPE_CALLBACK"); _vec2.push_back(L"10");
_vec1.push_back(L"FT_Common.T1_FIELD_TYPE_FIXED_1000"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.T1_FIELD_TYPE_FIXED_ARRAY"); _vec2.push_back(L"9");
_vec1.push_back(L"FT_Common.T1_FIELD_TYPE_FIXED"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.T1_FIELD_TYPE_INTEGER_ARRAY"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.T1_FIELD_TYPE_INTEGER"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.T1_FIELD_TYPE_KEY"); _vec2.push_back(L"6");
_vec1.push_back(L"FT_Common.T1_FIELD_TYPE_MAX"); _vec2.push_back(L"11");
_vec1.push_back(L"FT_Common.T1_FIELD_TYPE_NONE"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.T1_FIELD_TYPE_STRING"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.T1_FONTDIR_AFTER_PRIVATE"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.T1_MAX_CHARSTRINGS_OPERANDS"); _vec2.push_back(L"256");
_vec1.push_back(L"FT_Common.T1_MAX_MM_AXIS"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.T1_MAX_MM_DESIGNS"); _vec2.push_back(L"16");
_vec1.push_back(L"FT_Common.T1_MAX_MM_MAP_POINTS"); _vec2.push_back(L"20");
_vec1.push_back(L"FT_Common.T1_MAX_SUBRS_CALLS"); _vec2.push_back(L"16");
_vec1.push_back(L"FT_Common.T1_MAX_TABLE_ELEMENTS"); _vec2.push_back(L"32");
_vec1.push_back(L"FT_Common.T1_PRIVATE"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.T1_Parse_Have_Moveto"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.T1_Parse_Have_Path"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.T1_Parse_Have_Width"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.T1_Parse_Start"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.T1_TOKEN_TYPE_ANY"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.T1_TOKEN_TYPE_ARRAY"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.T1_TOKEN_TYPE_KEY"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.T1_TOKEN_TYPE_MAX"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.T1_TOKEN_TYPE_NONE"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.T1_TOKEN_TYPE_STRING"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.TABLE_EXTEND"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.TTAG_BASE"); _vec2.push_back(L"1111577413");
_vec1.push_back(L"FT_Common.TTAG_BDF"); _vec2.push_back(L"1111770656");
_vec1.push_back(L"FT_Common.TTAG_CFF"); _vec2.push_back(L"1128678944");
_vec1.push_back(L"FT_Common.TTAG_CID"); _vec2.push_back(L"1128875040");
_vec1.push_back(L"FT_Common.TTAG_DSIG"); _vec2.push_back(L"1146308935");
_vec1.push_back(L"FT_Common.TTAG_EBDT"); _vec2.push_back(L"1161970772");
_vec1.push_back(L"FT_Common.TTAG_EBLC"); _vec2.push_back(L"1161972803");
_vec1.push_back(L"FT_Common.TTAG_EBSC"); _vec2.push_back(L"1161974595");
_vec1.push_back(L"FT_Common.TTAG_FOND"); _vec2.push_back(L"1179602500");
_vec1.push_back(L"FT_Common.TTAG_GDEF"); _vec2.push_back(L"1195656518");
_vec1.push_back(L"FT_Common.TTAG_GPOS"); _vec2.push_back(L"1196445523");
_vec1.push_back(L"FT_Common.TTAG_GSUB"); _vec2.push_back(L"1196643650");
_vec1.push_back(L"FT_Common.TTAG_JSTF"); _vec2.push_back(L"1246975046");
_vec1.push_back(L"FT_Common.TTAG_LTSH"); _vec2.push_back(L"1280594760");
_vec1.push_back(L"FT_Common.TTAG_LWFN"); _vec2.push_back(L"1280788046");
_vec1.push_back(L"FT_Common.TTAG_MATH"); _vec2.push_back(L"1296127048");
_vec1.push_back(L"FT_Common.TTAG_META"); _vec2.push_back(L"1296389185");
_vec1.push_back(L"FT_Common.TTAG_MMFX"); _vec2.push_back(L"1296909912");
_vec1.push_back(L"FT_Common.TTAG_MMSD"); _vec2.push_back(L"1296913220");
_vec1.push_back(L"FT_Common.TTAG_OS2"); _vec2.push_back(L"1330851634");
_vec1.push_back(L"FT_Common.TTAG_OTTO"); _vec2.push_back(L"1330926671");
_vec1.push_back(L"FT_Common.TTAG_PCLT"); _vec2.push_back(L"1346587732");
_vec1.push_back(L"FT_Common.TTAG_POST"); _vec2.push_back(L"1347375956");
_vec1.push_back(L"FT_Common.TTAG_SING"); _vec2.push_back(L"1397313095");
_vec1.push_back(L"FT_Common.TTAG_TYP1"); _vec2.push_back(L"1415139377");
_vec1.push_back(L"FT_Common.TTAG_VDMX"); _vec2.push_back(L"1447316824");
_vec1.push_back(L"FT_Common.TTAG_avar"); _vec2.push_back(L"1635148146");
_vec1.push_back(L"FT_Common.TTAG_bdat"); _vec2.push_back(L"1650745716");
_vec1.push_back(L"FT_Common.TTAG_bhed"); _vec2.push_back(L"1651008868");
_vec1.push_back(L"FT_Common.TTAG_bloc"); _vec2.push_back(L"1651273571");
_vec1.push_back(L"FT_Common.TTAG_bsln"); _vec2.push_back(L"1651731566");
_vec1.push_back(L"FT_Common.TTAG_cmap"); _vec2.push_back(L"1668112752");
_vec1.push_back(L"FT_Common.TTAG_cvar"); _vec2.push_back(L"1668702578");
_vec1.push_back(L"FT_Common.TTAG_cvt"); _vec2.push_back(L"1668707360");
_vec1.push_back(L"FT_Common.TTAG_feat"); _vec2.push_back(L"1717920116");
_vec1.push_back(L"FT_Common.TTAG_fpgm"); _vec2.push_back(L"1718642541");
_vec1.push_back(L"FT_Common.TTAG_fvar"); _vec2.push_back(L"1719034226");
_vec1.push_back(L"FT_Common.TTAG_gasp"); _vec2.push_back(L"1734439792");
_vec1.push_back(L"FT_Common.TTAG_glyf"); _vec2.push_back(L"1735162214");
_vec1.push_back(L"FT_Common.TTAG_gvar"); _vec2.push_back(L"1735811442");
_vec1.push_back(L"FT_Common.TTAG_hdmx"); _vec2.push_back(L"1751412088");
_vec1.push_back(L"FT_Common.TTAG_head"); _vec2.push_back(L"1751474532");
_vec1.push_back(L"FT_Common.TTAG_hhea"); _vec2.push_back(L"1751672161");
_vec1.push_back(L"FT_Common.TTAG_hmtx"); _vec2.push_back(L"1752003704");
_vec1.push_back(L"FT_Common.TTAG_just"); _vec2.push_back(L"1786082164");
_vec1.push_back(L"FT_Common.TTAG_kern"); _vec2.push_back(L"1801810542");
_vec1.push_back(L"FT_Common.TTAG_lcar"); _vec2.push_back(L"1818452338");
_vec1.push_back(L"FT_Common.TTAG_loca"); _vec2.push_back(L"1819239265");
_vec1.push_back(L"FT_Common.TTAG_maxp"); _vec2.push_back(L"1835104368");
_vec1.push_back(L"FT_Common.TTAG_mort"); _vec2.push_back(L"1836020340");
_vec1.push_back(L"FT_Common.TTAG_morx"); _vec2.push_back(L"1836020344");
_vec1.push_back(L"FT_Common.TTAG_name"); _vec2.push_back(L"1851878757");
_vec1.push_back(L"FT_Common.TTAG_opbd"); _vec2.push_back(L"1869636196");
_vec1.push_back(L"FT_Common.TTAG_opsz"); _vec2.push_back(L"1869640570");
_vec1.push_back(L"FT_Common.TTAG_post"); _vec2.push_back(L"1886352244");
_vec1.push_back(L"FT_Common.TTAG_prep"); _vec2.push_back(L"1886545264");
_vec1.push_back(L"FT_Common.TTAG_prop"); _vec2.push_back(L"1886547824");
_vec1.push_back(L"FT_Common.TTAG_sfnt"); _vec2.push_back(L"1936092788");
_vec1.push_back(L"FT_Common.TTAG_slnt"); _vec2.push_back(L"1936486004");
_vec1.push_back(L"FT_Common.TTAG_trak"); _vec2.push_back(L"1953653099");
_vec1.push_back(L"FT_Common.TTAG_true"); _vec2.push_back(L"1953658213");
_vec1.push_back(L"FT_Common.TTAG_ttcf"); _vec2.push_back(L"1953784678");
_vec1.push_back(L"FT_Common.TTAG_ttc"); _vec2.push_back(L"1953784608");
_vec1.push_back(L"FT_Common.TTAG_typ1"); _vec2.push_back(L"1954115633");
_vec1.push_back(L"FT_Common.TTAG_vhea"); _vec2.push_back(L"1986553185");
_vec1.push_back(L"FT_Common.TTAG_vmtx"); _vec2.push_back(L"1986884728");
_vec1.push_back(L"FT_Common.TTAG_wdth"); _vec2.push_back(L"2003072104");
_vec1.push_back(L"FT_Common.TTAG_wght"); _vec2.push_back(L"2003265652");
_vec1.push_back(L"FT_Common.TT_ADOBE_ID_CUSTOM"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.TT_ADOBE_ID_EXPERT"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.TT_ADOBE_ID_LATIN_1"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.TT_ADOBE_ID_STANDARD"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.TT_APPLE_ID_DEFAULT"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.TT_APPLE_ID_ISO_10646"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.TT_APPLE_ID_UNICODE_1_1"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.TT_APPLE_ID_UNICODE_2_0"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.TT_APPLE_ID_UNICODE_32"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.TT_APPLE_ID_VARIANT_SELECTOR"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.TT_CMAP_FLAG_OVERLAPPING"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.TT_CMAP_FLAG_UNSORTED"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.TT_MAC_ID_ROMAN"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.TT_MAX_CODE_RANGES"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.TT_MS_ID_BIG_5"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.TT_MS_ID_GB2312"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.TT_MS_ID_JOHAB"); _vec2.push_back(L"6");
_vec1.push_back(L"FT_Common.TT_MS_ID_SJIS"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.TT_MS_ID_SYMBOL_CS"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.TT_MS_ID_UCS_4"); _vec2.push_back(L"10");
_vec1.push_back(L"FT_Common.TT_MS_ID_UNICODE_CS"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.TT_MS_ID_WANSUNG"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.TT_NAME_ID_CID_FINDFONT_NAME"); _vec2.push_back(L"20");
_vec1.push_back(L"FT_Common.TT_NAME_ID_COPYRIGHT"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.TT_NAME_ID_DESCRIPTION"); _vec2.push_back(L"10");
_vec1.push_back(L"FT_Common.TT_NAME_ID_DESIGNER_URL"); _vec2.push_back(L"12");
_vec1.push_back(L"FT_Common.TT_NAME_ID_DESIGNER"); _vec2.push_back(L"9");
_vec1.push_back(L"FT_Common.TT_NAME_ID_FONT_FAMILY"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.TT_NAME_ID_FONT_SUBFAMILY"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.TT_NAME_ID_FULL_NAME"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.TT_NAME_ID_LICENSE_URL"); _vec2.push_back(L"14");
_vec1.push_back(L"FT_Common.TT_NAME_ID_LICENSE"); _vec2.push_back(L"13");
_vec1.push_back(L"FT_Common.TT_NAME_ID_MAC_FULL_NAME"); _vec2.push_back(L"18");
_vec1.push_back(L"FT_Common.TT_NAME_ID_MANUFACTURER"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.TT_NAME_ID_PREFERRED_FAMILY"); _vec2.push_back(L"16");
_vec1.push_back(L"FT_Common.TT_NAME_ID_PREFERRED_SUBFAMILY"); _vec2.push_back(L"17");
_vec1.push_back(L"FT_Common.TT_NAME_ID_PS_NAME"); _vec2.push_back(L"6");
_vec1.push_back(L"FT_Common.TT_NAME_ID_SAMPLE_TEXT"); _vec2.push_back(L"19");
_vec1.push_back(L"FT_Common.TT_NAME_ID_TRADEMARK"); _vec2.push_back(L"7");
_vec1.push_back(L"FT_Common.TT_NAME_ID_UNIQUE_ID"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.TT_NAME_ID_VENDOR_URL"); _vec2.push_back(L"11");
_vec1.push_back(L"FT_Common.TT_NAME_ID_VERSION_STRING"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.TT_NAME_ID_WWS_FAMILY"); _vec2.push_back(L"21");
_vec1.push_back(L"FT_Common.TT_NAME_ID_WWS_SUBFAMILY"); _vec2.push_back(L"22");
_vec1.push_back(L"FT_Common.TT_PLATFORM_ADOBE"); _vec2.push_back(L"7");
_vec1.push_back(L"FT_Common.TT_PLATFORM_APPLE_UNICODE"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.TT_PLATFORM_CUSTOM"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.TT_PLATFORM_ISO"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.TT_PLATFORM_MACINTOSH"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.TT_PLATFORM_MICROSOFT"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.UNSCALED_COMPONENT_OFFSET"); _vec2.push_back(L"4096");
_vec1.push_back(L"FT_Common.USE_MY_METRICS"); _vec2.push_back(L"512");
_vec1.push_back(L"FT_Common.WE_HAVE_AN_XY_SCALE"); _vec2.push_back(L"64");
_vec1.push_back(L"FT_Common.WE_HAVE_A_2X2"); _vec2.push_back(L"128");
_vec1.push_back(L"FT_Common.WE_HAVE_A_SCALE"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.WE_HAVE_INSTR"); _vec2.push_back(L"256");
_vec1.push_back(L"FT_Common.a_c"); _vec2.push_back(L"256");
_vec1.push_back(L"FT_Common.a_i"); _vec2.push_back(L"4294967296");
_vec1.push_back(L"FT_Common.a_s"); _vec2.push_back(L"65536");
_vec1.push_back(L"FT_Common.cff_kind_bool"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.cff_kind_callback"); _vec2.push_back(L"7");
_vec1.push_back(L"FT_Common.cff_kind_delta"); _vec2.push_back(L"6");
_vec1.push_back(L"FT_Common.cff_kind_fixed_thousand"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.cff_kind_fixed"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.cff_kind_max"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.cff_kind_none"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.cff_kind_num"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.cff_kind_string"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.cff_op_abs"); _vec2.push_back(L"26");
_vec1.push_back(L"FT_Common.cff_op_add"); _vec2.push_back(L"27");
_vec1.push_back(L"FT_Common.cff_op_and"); _vec2.push_back(L"44");
_vec1.push_back(L"FT_Common.cff_op_blend"); _vec2.push_back(L"34");
_vec1.push_back(L"FT_Common.cff_op_callgsubr"); _vec2.push_back(L"50");
_vec1.push_back(L"FT_Common.cff_op_callothersubr"); _vec2.push_back(L"54");
_vec1.push_back(L"FT_Common.cff_op_callsubr"); _vec2.push_back(L"49");
_vec1.push_back(L"FT_Common.cff_op_closepath"); _vec2.push_back(L"53");
_vec1.push_back(L"FT_Common.cff_op_cntrmask"); _vec2.push_back(L"24");
_vec1.push_back(L"FT_Common.cff_op_div"); _vec2.push_back(L"29");
_vec1.push_back(L"FT_Common.cff_op_dotsection"); _vec2.push_back(L"25");
_vec1.push_back(L"FT_Common.cff_op_drop"); _vec2.push_back(L"35");
_vec1.push_back(L"FT_Common.cff_op_dup"); _vec2.push_back(L"39");
_vec1.push_back(L"FT_Common.cff_op_endchar"); _vec2.push_back(L"18");
_vec1.push_back(L"FT_Common.cff_op_eq"); _vec2.push_back(L"47");
_vec1.push_back(L"FT_Common.cff_op_exch"); _vec2.push_back(L"36");
_vec1.push_back(L"FT_Common.cff_op_flex1"); _vec2.push_back(L"17");
_vec1.push_back(L"FT_Common.cff_op_flex"); _vec2.push_back(L"14");
_vec1.push_back(L"FT_Common.cff_op_get"); _vec2.push_back(L"41");
_vec1.push_back(L"FT_Common.cff_op_hflex1"); _vec2.push_back(L"16");
_vec1.push_back(L"FT_Common.cff_op_hflex"); _vec2.push_back(L"15");
_vec1.push_back(L"FT_Common.cff_op_hhcurveto"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.cff_op_hintmask"); _vec2.push_back(L"23");
_vec1.push_back(L"FT_Common.cff_op_hlineto"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.cff_op_hmoveto"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.cff_op_hsbw"); _vec2.push_back(L"52");
_vec1.push_back(L"FT_Common.cff_op_hstemhm"); _vec2.push_back(L"21");
_vec1.push_back(L"FT_Common.cff_op_hstem"); _vec2.push_back(L"19");
_vec1.push_back(L"FT_Common.cff_op_hvcurveto"); _vec2.push_back(L"9");
_vec1.push_back(L"FT_Common.cff_op_ifelse"); _vec2.push_back(L"48");
_vec1.push_back(L"FT_Common.cff_op_index"); _vec2.push_back(L"37");
_vec1.push_back(L"FT_Common.cff_op_load"); _vec2.push_back(L"43");
_vec1.push_back(L"FT_Common.cff_op_max"); _vec2.push_back(L"59");
_vec1.push_back(L"FT_Common.cff_op_mul"); _vec2.push_back(L"32");
_vec1.push_back(L"FT_Common.cff_op_neg"); _vec2.push_back(L"30");
_vec1.push_back(L"FT_Common.cff_op_not"); _vec2.push_back(L"46");
_vec1.push_back(L"FT_Common.cff_op_or"); _vec2.push_back(L"45");
_vec1.push_back(L"FT_Common.cff_op_pop"); _vec2.push_back(L"55");
_vec1.push_back(L"FT_Common.cff_op_put"); _vec2.push_back(L"40");
_vec1.push_back(L"FT_Common.cff_op_random"); _vec2.push_back(L"31");
_vec1.push_back(L"FT_Common.cff_op_rcurveline"); _vec2.push_back(L"10");
_vec1.push_back(L"FT_Common.cff_op_return"); _vec2.push_back(L"51");
_vec1.push_back(L"FT_Common.cff_op_rlinecurve"); _vec2.push_back(L"11");
_vec1.push_back(L"FT_Common.cff_op_rlineto"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.cff_op_rmoveto"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.cff_op_roll"); _vec2.push_back(L"38");
_vec1.push_back(L"FT_Common.cff_op_rrcurveto"); _vec2.push_back(L"7");
_vec1.push_back(L"FT_Common.cff_op_sbw"); _vec2.push_back(L"57");
_vec1.push_back(L"FT_Common.cff_op_seac"); _vec2.push_back(L"56");
_vec1.push_back(L"FT_Common.cff_op_setcurrentpoint"); _vec2.push_back(L"58");
_vec1.push_back(L"FT_Common.cff_op_sqrt"); _vec2.push_back(L"33");
_vec1.push_back(L"FT_Common.cff_op_store"); _vec2.push_back(L"42");
_vec1.push_back(L"FT_Common.cff_op_sub"); _vec2.push_back(L"28");
_vec1.push_back(L"FT_Common.cff_op_unknown"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.cff_op_vhcurveto"); _vec2.push_back(L"12");
_vec1.push_back(L"FT_Common.cff_op_vlineto"); _vec2.push_back(L"6");
_vec1.push_back(L"FT_Common.cff_op_vmoveto"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.cff_op_vstemhm"); _vec2.push_back(L"22");
_vec1.push_back(L"FT_Common.cff_op_vstem"); _vec2.push_back(L"20");
_vec1.push_back(L"FT_Common.cff_op_vvcurveto"); _vec2.push_back(L"13");
_vec1.push_back(L"FT_Common.m_c"); _vec2.push_back(L"127");
_vec1.push_back(L"FT_Common.m_i"); _vec2.push_back(L"2147483647");
_vec1.push_back(L"FT_Common.m_s"); _vec2.push_back(L"32767");
_vec1.push_back(L"FT_Common.op_callothersubr"); _vec2.push_back(L"21");
_vec1.push_back(L"FT_Common.op_callsubr"); _vec2.push_back(L"22");
_vec1.push_back(L"FT_Common.op_closepath"); _vec2.push_back(L"5");
_vec1.push_back(L"FT_Common.op_div"); _vec2.push_back(L"20");
_vec1.push_back(L"FT_Common.op_dotsection"); _vec2.push_back(L"15");
_vec1.push_back(L"FT_Common.op_endchar"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.op_hlineto"); _vec2.push_back(L"6");
_vec1.push_back(L"FT_Common.op_hmoveto"); _vec2.push_back(L"7");
_vec1.push_back(L"FT_Common.op_hsbw"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.op_hstem3"); _vec2.push_back(L"17");
_vec1.push_back(L"FT_Common.op_hstem"); _vec2.push_back(L"16");
_vec1.push_back(L"FT_Common.op_hvcurveto"); _vec2.push_back(L"8");
_vec1.push_back(L"FT_Common.op_max"); _vec2.push_back(L"27");
_vec1.push_back(L"FT_Common.op_none"); _vec2.push_back(L"0");
_vec1.push_back(L"FT_Common.op_pop"); _vec2.push_back(L"23");
_vec1.push_back(L"FT_Common.op_return"); _vec2.push_back(L"24");
_vec1.push_back(L"FT_Common.op_rlineto"); _vec2.push_back(L"9");
_vec1.push_back(L"FT_Common.op_rmoveto"); _vec2.push_back(L"10");
_vec1.push_back(L"FT_Common.op_rrcurveto"); _vec2.push_back(L"11");
_vec1.push_back(L"FT_Common.op_sbw"); _vec2.push_back(L"4");
_vec1.push_back(L"FT_Common.op_seac"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.op_setcurrentpoint"); _vec2.push_back(L"25");
_vec1.push_back(L"FT_Common.op_unknown15"); _vec2.push_back(L"26");
_vec1.push_back(L"FT_Common.op_vhcurveto"); _vec2.push_back(L"12");
_vec1.push_back(L"FT_Common.op_vlineto"); _vec2.push_back(L"13");
_vec1.push_back(L"FT_Common.op_vmoveto"); _vec2.push_back(L"14");
_vec1.push_back(L"FT_Common.op_vstem3"); _vec2.push_back(L"19");
_vec1.push_back(L"FT_Common.op_vstem"); _vec2.push_back(L"18");
_vec1.push_back(L"FT_Common.tt_coderange_cvt"); _vec2.push_back(L"2");
_vec1.push_back(L"FT_Common.tt_coderange_font"); _vec2.push_back(L"1");
_vec1.push_back(L"FT_Common.tt_coderange_glyph"); _vec2.push_back(L"3");
_vec1.push_back(L"FT_Common.tt_coderange_none"); _vec2.push_back(L"0");
}
void string_replace(std::wstring& text, const std::wstring& replaceFrom, const std::wstring& replaceTo)
{
size_t posn = 0;
while (std::wstring::npos != (posn = text.find(replaceFrom, posn)))
{
text.replace(posn, replaceFrom.length(), replaceTo);
posn += replaceTo.length();
}
}
void CorrectScript(std::wstring& sData, std::vector<std::wstring>& _vec1, std::vector<std::wstring>& _vec2)
{
std::vector<std::wstring>::iterator i = _vec1.begin();
std::vector<std::wstring>::iterator j = _vec2.begin();
for (; i != _vec1.end(); i++, j++)
{
string_replace(sData, *i, *j);
}
}
int main()
{
std::wstring sBasePath = NSFile::GetProcessDirectory() + L"/../../Freetype/";
// FILES
std::vector<std::wstring> arFiles;
arFiles.push_back(sBasePath + L"config.js");
arFiles.push_back(sBasePath + L"services.js");
arFiles.push_back(sBasePath + L"base.js");
arFiles.push_back(sBasePath + L"modules/psnames.js");
arFiles.push_back(sBasePath + L"modules/psaux.js");
arFiles.push_back(sBasePath + L"modules/sfnt.js");
arFiles.push_back(sBasePath + L"modules/render.js");
arFiles.push_back(sBasePath + L"drivers/ttinterp.js");
arFiles.push_back(sBasePath + L"drivers/truetype.js");
arFiles.push_back(sBasePath + L"drivers/cff.js");
arFiles.push_back(sBasePath + L"drivers/t1.js");
arFiles.push_back(sBasePath + L"freetype.js");
// CONFIG MAP
std::vector<std::wstring> _vec1;
std::vector<std::wstring> _vec2;
GetConfigMap(_vec1, _vec2);
// READ
std::wstring sOutput = L"\"use strict\";\r\n\r\n";
for (std::vector<std::wstring>::iterator i = arFiles.begin(); i != arFiles.end(); i++)
{
std::wstring sFileInput = *i;
std::wstring sData = L"";
NSFile::CFileBinary::ReadAllTextUtf8(sFileInput, sData);
if (sFileInput.find(L"config.js") != std::wstring::npos)
{
std::wstring s0 = L"function _FT_Common()";
std::wstring::size_type nPos0 = sData.find(s0);
if (nPos0 != std::wstring::npos)
{
sData = sData.substr(nPos0);
}
std::wstring s1 = L"// GENERATOR_START_CONSTANTS";
std::wstring s2 = L"// GENERATOR_END_CONSTANTS";
std::wstring::size_type nPos1 = sData.find(s1);
std::wstring::size_type nPos2 = sData.find(s2);
if (nPos1 != std::wstring::npos && nPos2 != std::wstring::npos)
{
std::wstring sRes = sData.substr(0, nPos1) + sData.substr(nPos2 + s2.length());
sData = sRes;
}
}
CorrectScript(sData, _vec1, _vec2);
sOutput += sData;
sOutput += L"\n";
}
NSFile::CFileBinary::SaveToFile(sBasePath + L"../../font_engine.js", sOutput);
return 0;
}
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
function _FT_Common() function _FT_Common()
{ {
this.UintToInt = function(v){ this.UintToInt = function(v){
return (v>2147483647)?v-4294967296:v; return (v>2147483647)?v-4294967296:v;
} }
...@@ -100,7 +102,8 @@ function _FT_Common() ...@@ -100,7 +102,8 @@ function _FT_Common()
return ret; return ret;
} }
} }
var FT_Common = new _FT_Common();/******************************************************************************/ var FT_Common = new _FT_Common();
/******************************************************************************/
// SERVICES // SERVICES
/******************************************************************************/ /******************************************************************************/
...@@ -357,7 +360,8 @@ function FT_ServiceCache() ...@@ -357,7 +360,8 @@ function FT_ServiceCache()
this.service_GLYPH_DICT = null; this.service_GLYPH_DICT = null;
this.service_PFR_METRICS = null; this.service_PFR_METRICS = null;
this.service_WINFNT = null; this.service_WINFNT = null;
}/******************************************************************************/ }
/******************************************************************************/
// stream // stream
/******************************************************************************/ /******************************************************************************/
function FT_Frame_Field(v,s,o) function FT_Frame_Field(v,s,o)
...@@ -3909,7 +3913,8 @@ function ft_synthesize_vertical_metrics(metrics, advance) ...@@ -3909,7 +3913,8 @@ function ft_synthesize_vertical_metrics(metrics, advance)
metrics.vertBearingX = parseInt(metrics.horiBearingX - metrics.horiAdvance / 2); metrics.vertBearingX = parseInt(metrics.horiBearingX - metrics.horiAdvance / 2);
metrics.vertBearingY = parseInt((advance - height) / 2); metrics.vertBearingY = parseInt((advance - height) / 2);
metrics.vertAdvance = advance; metrics.vertAdvance = advance;
}var ft_standard_glyph_names = [".null","nonmarkingreturn","notequal","infinity","lessequal","greaterequal","partialdiff","summation","product","pi","integral", }
var ft_standard_glyph_names = [".null","nonmarkingreturn","notequal","infinity","lessequal","greaterequal","partialdiff","summation","product","pi","integral",
"Omega","radical","approxequal","Delta","nonbreakingspace","lozenge","apple","franc","Gbreve","gbreve","Idotaccent","Scedilla", "Omega","radical","approxequal","Delta","nonbreakingspace","lozenge","apple","franc","Gbreve","gbreve","Idotaccent","Scedilla",
"scedilla","Cacute","cacute","Ccaron","ccaron","dcroat",".notdef","space","exclam","quotedbl","numbersign","dollar","percent", "scedilla","Cacute","cacute","Ccaron","ccaron","dcroat",".notdef","space","exclam","quotedbl","numbersign","dollar","percent",
"ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three", "ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three",
...@@ -7997,7 +8002,8 @@ function create_psnames_module(library) ...@@ -7997,7 +8002,8 @@ function create_psnames_module(library)
psnames_mod.generic = null; psnames_mod.generic = null;
return psnames_mod; return psnames_mod;
}/******************************************************************************/ }
/******************************************************************************/
// t1tables // t1tables
/******************************************************************************/ /******************************************************************************/
function _isdigit(x) function _isdigit(x)
...@@ -12150,7 +12156,7 @@ function T1_FieldRec() ...@@ -12150,7 +12156,7 @@ function T1_FieldRec()
this.location = 0; this.location = 0;
this.type = 0; this.type = 0;
this.reader = null; this.reader = null;
this.offset = 0; // � ��� ��� ������ ������ ����� ������. � �� ����� � ������ this.offset = 0; // у нас это просто индекс члена класса. А не сдвиг в памяти
this.size = 0; this.size = 0;
this.array_max = 0; this.array_max = 0;
...@@ -12169,8 +12175,8 @@ function create_dublicate_t1_field(_field) ...@@ -12169,8 +12175,8 @@ function create_dublicate_t1_field(_field)
ret.location = _field.location; ret.location = _field.location;
ret.type = _field.type; ret.type = _field.type;
ret.reader = _field.reader; ret.reader = _field.reader;
ret.offset = _field.offset; // � ��� ��� ������ ������ � ������� (�.�. ��� �� ������� ��� ���� �� �����) ret.offset = _field.offset; // у нас это просто индекс в МАССИВЕ (т.е. для не массива это поле не нужно)
ret.size = _field.size; // �� �������� (�� ������� �������) ret.size = _field.size; // не пользуем (на будущее оставим)
ret.array_max = _field.array_max; ret.array_max = _field.array_max;
ret.count_offset = _field.count_offset; ret.count_offset = _field.count_offset;
...@@ -12599,6 +12605,7 @@ function create_psaux_module(library) ...@@ -12599,6 +12605,7 @@ function create_psaux_module(library)
return psaux_mod; return psaux_mod;
} }
/******************************************************************************/ /******************************************************************************/
// bdf // bdf
/******************************************************************************/ /******************************************************************************/
...@@ -18129,6 +18136,7 @@ function create_sfnt_module(library) ...@@ -18129,6 +18136,7 @@ function create_sfnt_module(library)
return sfnt_mod; return sfnt_mod;
} }
function CRasterMemory() function CRasterMemory()
{ {
this.width = 0; this.width = 0;
...@@ -20554,7 +20562,8 @@ function ft_smooth_render_generic(render, slot, mode, origin, required_mode) ...@@ -20554,7 +20562,8 @@ function ft_smooth_render_generic(render, slot, mode, origin, required_mode)
FT_Outline_Translate(outline, -origin.x, -origin.y); FT_Outline_Translate(outline, -origin.x, -origin.y);
return error; return error;
}var TT_Round_Off = 5; }
var TT_Round_Off = 5;
var TT_Round_To_Half_Grid = 0; var TT_Round_To_Half_Grid = 0;
var TT_Round_To_Grid = 1; var TT_Round_To_Grid = 1;
var TT_Round_To_Double_Grid = 2; var TT_Round_To_Double_Grid = 2;
...@@ -26997,7 +27006,8 @@ function CSubpixHintingHacks() ...@@ -26997,7 +27006,8 @@ function CSubpixHintingHacks()
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
} }
var global_SubpixHintingHacks = new CSubpixHintingHacks();/******************************************************************************/ var global_SubpixHintingHacks = new CSubpixHintingHacks();
/******************************************************************************/
// classes // classes
/******************************************************************************/ /******************************************************************************/
function TT_Size_Metrics() function TT_Size_Metrics()
...@@ -28166,19 +28176,6 @@ function tt_done_blend(memory, blend) ...@@ -28166,19 +28176,6 @@ function tt_done_blend(memory, blend)
/******************************************************************************/ /******************************************************************************/
// glyphloader // glyphloader
/******************************************************************************/ /******************************************************************************/
FT_Common.ARGS_ARE_WORDS = 0x0001;
FT_Common.ARGS_ARE_XY_VALUES = 0x0002;
FT_Common.ROUND_XY_TO_GRID = 0x0004;
FT_Common.WE_HAVE_A_SCALE = 0x0008;
FT_Common.MORE_COMPONENTS = 0x0020;
FT_Common.WE_HAVE_AN_XY_SCALE = 0x0040;
FT_Common.WE_HAVE_A_2X2 = 0x0080;
FT_Common.WE_HAVE_INSTR = 0x0100;
FT_Common.USE_MY_METRICS = 0x0200;
FT_Common.OVERLAP_COMPOUND = 0x0400;
FT_Common.SCALED_COMPONENT_OFFSET = 0x0800;
FT_Common.UNSCALED_COMPONENT_OFFSET = 0x1000;
function load_sbit_image(size, glyph, glyph_index, load_flags) function load_sbit_image(size, glyph, glyph_index, load_flags)
{ {
var metrics = new TT_SBit_MetricsRec(); var metrics = new TT_SBit_MetricsRec();
...@@ -28585,19 +28582,19 @@ function TT_Load_Composite_Glyph(loader) ...@@ -28585,19 +28582,19 @@ function TT_Load_Composite_Glyph(loader)
count_read += 4; count_read += 4;
count = 2; count = 2;
if (subglyph.flags & FT_Common.ARGS_ARE_WORDS) if (subglyph.flags & 1)
count += 2; count += 2;
if (subglyph.flags & FT_Common.WE_HAVE_A_SCALE) if (subglyph.flags & 8)
count += 2; count += 2;
else if (subglyph.flags & FT_Common.WE_HAVE_AN_XY_SCALE) else if (subglyph.flags & 64)
count += 4; count += 4;
else if (subglyph.flags & FT_Common.WE_HAVE_A_2X2) else if (subglyph.flags & 128)
count += 8; count += 8;
if (count_read + count > size_read) if (count_read + count > size_read)
return 21; return 21;
if (subglyph.flags & FT_Common.ARGS_ARE_WORDS) if (subglyph.flags & 1)
{ {
subglyph.arg1 = s.GetShort(); subglyph.arg1 = s.GetShort();
subglyph.arg2 = s.GetShort(); subglyph.arg2 = s.GetShort();
...@@ -28611,17 +28608,17 @@ function TT_Load_Composite_Glyph(loader) ...@@ -28611,17 +28608,17 @@ function TT_Load_Composite_Glyph(loader)
xx = yy = 0x10000; xx = yy = 0x10000;
xy = yx = 0; xy = yx = 0;
if (subglyph.flags & FT_Common.WE_HAVE_A_SCALE) if (subglyph.flags & 8)
{ {
xx = s.GetShort() << 2; xx = s.GetShort() << 2;
yy = xx; yy = xx;
} }
else if (subglyph.flags & FT_Common.WE_HAVE_AN_XY_SCALE) else if (subglyph.flags & 64)
{ {
xx = s.GetShort() << 2; xx = s.GetShort() << 2;
yy = s.GetShort() << 2; yy = s.GetShort() << 2;
} }
else if (subglyph.flags & FT_Common.WE_HAVE_A_2X2) else if (subglyph.flags & 128)
{ {
xx = s.GetShort() << 2; xx = s.GetShort() << 2;
yx = s.GetShort() << 2; yx = s.GetShort() << 2;
...@@ -28638,7 +28635,7 @@ function TT_Load_Composite_Glyph(loader) ...@@ -28638,7 +28635,7 @@ function TT_Load_Composite_Glyph(loader)
count_read += count; count_read += count;
} while (subglyph.flags & FT_Common.MORE_COMPONENTS); } while (subglyph.flags & 32);
gloader.current.num_subglyphs = num_subglyphs; gloader.current.num_subglyphs = num_subglyphs;
...@@ -28795,7 +28792,7 @@ function TT_Process_Composite_Component(loader, subglyph, start_point, num_base_ ...@@ -28795,7 +28792,7 @@ function TT_Process_Composite_Component(loader, subglyph, start_point, num_base_
var num_points = gloader.base.outline.n_points; var num_points = gloader.base.outline.n_points;
var x, y; var x, y;
var have_scale = (0 == (subglyph.flags & (FT_Common.WE_HAVE_A_SCALE | FT_Common.WE_HAVE_AN_XY_SCALE | FT_Common.WE_HAVE_A_2X2))) ? 0 : 1; var have_scale = (0 == (subglyph.flags & (8 | 64 | 128))) ? 0 : 1;
if (have_scale != 0) if (have_scale != 0)
{ {
...@@ -28803,7 +28800,7 @@ function TT_Process_Composite_Component(loader, subglyph, start_point, num_base_ ...@@ -28803,7 +28800,7 @@ function TT_Process_Composite_Component(loader, subglyph, start_point, num_base_
FT_Vector_Transform(base_vecs[i], subglyph.transform); FT_Vector_Transform(base_vecs[i], subglyph.transform);
} }
if (0 == (subglyph.flags & FT_Common.ARGS_ARE_XY_VALUES)) if (0 == (subglyph.flags & 2))
{ {
var k = subglyph.arg1; var k = subglyph.arg1;
var l = subglyph.arg2; var l = subglyph.arg2;
...@@ -28826,7 +28823,7 @@ function TT_Process_Composite_Component(loader, subglyph, start_point, num_base_ ...@@ -28826,7 +28823,7 @@ function TT_Process_Composite_Component(loader, subglyph, start_point, num_base_
if (x == 0 && y == 0) if (x == 0 && y == 0)
return 0; return 0;
if (have_scale != 0 && 0 != (subglyph.flags & FT_Common.SCALED_COMPONENT_OFFSET)) if (have_scale != 0 && 0 != (subglyph.flags & 2048))
{ {
var mac_xscale = FT_SqrtFixed(FT_MulFix(subglyph.transform.xx, subglyph.transform.xx) + var mac_xscale = FT_SqrtFixed(FT_MulFix(subglyph.transform.xx, subglyph.transform.xx) +
FT_MulFix(subglyph.transform.xy, subglyph.transform.xy)); FT_MulFix(subglyph.transform.xy, subglyph.transform.xy));
...@@ -28846,7 +28843,7 @@ function TT_Process_Composite_Component(loader, subglyph, start_point, num_base_ ...@@ -28846,7 +28843,7 @@ function TT_Process_Composite_Component(loader, subglyph, start_point, num_base_
x = FT_MulFix(x, x_scale); x = FT_MulFix(x, x_scale);
y = FT_MulFix(y, y_scale); y = FT_MulFix(y, y_scale);
if (subglyph.flags & FT_Common.ROUND_XY_TO_GRID) if (subglyph.flags & 4)
{ {
x = FT_PIX_ROUND(x); x = FT_PIX_ROUND(x);
y = FT_PIX_ROUND(y); y = FT_PIX_ROUND(y);
...@@ -29705,7 +29702,7 @@ function load_truetype_glyph(loader, glyph_index, recurse_count, header_only) ...@@ -29705,7 +29702,7 @@ function load_truetype_glyph(loader, glyph_index, recurse_count, header_only)
var i = 0; var i = 0;
for (; i < limit; ++i, ++subglyph ) for (; i < limit; ++i, ++subglyph )
{ {
if (subglyph.flags & FT_Common.ARGS_ARE_XY_VALUES) if (subglyph.flags & 2)
{ {
subglyph.arg1 += (deltas[i].x & 0xFFFF); subglyph.arg1 += (deltas[i].x & 0xFFFF);
subglyph.arg2 += (deltas[i].y & 0xFFFF); subglyph.arg2 += (deltas[i].y & 0xFFFF);
...@@ -29788,7 +29785,7 @@ function load_truetype_glyph(loader, glyph_index, recurse_count, header_only) ...@@ -29788,7 +29785,7 @@ function load_truetype_glyph(loader, glyph_index, recurse_count, header_only)
var bIsSubFlags = true; var bIsSubFlags = true;
if (bIsSubFlags && face.driver.library.tt_hint_props.TT_USE_BYTECODE_INTERPRETER) if (bIsSubFlags && face.driver.library.tt_hint_props.TT_USE_BYTECODE_INTERPRETER)
bIsSubFlags = ((subglyph.flags & FT_Common.WE_HAVE_INSTR) != 0); bIsSubFlags = ((subglyph.flags & 256) != 0);
if (((loader.load_flags & 2) == 0) && bIsSubFlags && num_points > start_point) if (((loader.load_flags & 2) == 0) && bIsSubFlags && num_points > start_point)
TT_Process_Composite_Glyph(loader, start_point, start_contour); TT_Process_Composite_Glyph(loader, start_point, start_contour);
...@@ -30796,7 +30793,8 @@ function create_tt_driver(library) ...@@ -30796,7 +30793,8 @@ function create_tt_driver(library)
driver.clazz = new TT_Driver_Class(); driver.clazz = new TT_Driver_Class();
return driver; return driver;
}/******************************************************************************/ }
/******************************************************************************/
// cfftypes // cfftypes
/******************************************************************************/ /******************************************************************************/
function CFF_IndexRec() function CFF_IndexRec()
...@@ -36762,7 +36760,8 @@ function create_cff_driver(library) ...@@ -36762,7 +36760,8 @@ function create_cff_driver(library)
driver.memory = library.Memory; driver.memory = library.Memory;
return driver; return driver;
}/******************************************************************************/ }
/******************************************************************************/
// afm // afm
/******************************************************************************/ /******************************************************************************/
function T1_Done_Metrics(memory, fi) function T1_Done_Metrics(memory, fi)
...@@ -40399,7 +40398,8 @@ function create_t1_driver(library) ...@@ -40399,7 +40398,8 @@ function create_t1_driver(library)
driver.clazz = new T1_Driver_Class(); driver.clazz = new T1_Driver_Class();
return driver; return driver;
}var FT_Error = 0; }
var FT_Error = 0;
function FT_Library() function FT_Library()
{ {
this.Memory = null; this.Memory = null;
...@@ -40469,6 +40469,7 @@ function FT_Library() ...@@ -40469,6 +40469,7 @@ function FT_Library()
error = this.ft_add_renderer(module); error = this.ft_add_renderer(module);
if (0 != error) if (0 != error)
{ {
//delete module;
return error; return error;
} }
} }
...@@ -41705,3 +41706,4 @@ function FT_CMap_New(clazz, init_data, charmap) ...@@ -41705,3 +41706,4 @@ function FT_CMap_New(clazz, init_data, charmap)
return cmap; return cmap;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment