mirror of
https://github.com/danbulant/node-x11
synced 2026-05-24 12:35:39 +00:00
tabs
This commit is contained in:
parent
8c81c10edc
commit
b9264546a9
1 changed files with 28 additions and 26 deletions
|
|
@ -370,27 +370,27 @@ exports.requireExt = function(display, callback)
|
||||||
X.seq_num++;
|
X.seq_num++;
|
||||||
var numGlyphs = glyphs.length;
|
var numGlyphs = glyphs.length;
|
||||||
var imageBytes = 0;
|
var imageBytes = 0;
|
||||||
var glyphPaddedLength;
|
var glyphPaddedLength;
|
||||||
var glyphLength;
|
var glyphLength;
|
||||||
for (var i = 0; i < numGlyphs; i++) {
|
for (var i = 0; i < numGlyphs; i++) {
|
||||||
glyphLength = glyphs[i].image.length;
|
glyphLength = glyphs[i].image.length;
|
||||||
if (glyphLength % 4 !== 0)
|
if (glyphLength % 4 !== 0)
|
||||||
throw new Error('Glyph image length must be divisible by 4!');
|
throw new Error('Glyph image length must be divisible by 4!');
|
||||||
imageBytes += glyphLength;
|
imageBytes += glyphLength;
|
||||||
}
|
}
|
||||||
var len = numGlyphs * 4 + imageBytes/4 + 3;
|
var len = numGlyphs * 4 + imageBytes/4 + 3;
|
||||||
// TODO: check length, use bigReq
|
// TODO: check length, use bigReq
|
||||||
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 20, len, gsid, glyphs.length]);
|
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 20, len, gsid, glyphs.length]);
|
||||||
// BigReq: S + [ length ] replaced with SL + [ 0, length+1 ]
|
// BigReq: S + [ length ] replaced with SL + [ 0, length+1 ]
|
||||||
//X.pack_stream.pack('CCSLLL', [ext.majorOpcode, 20, 0, len+1, gsid, glyphs.length]);
|
//X.pack_stream.pack('CCSLLL', [ext.majorOpcode, 20, 0, len+1, gsid, glyphs.length]);
|
||||||
|
|
||||||
// glyph ids
|
// glyph ids
|
||||||
for (i = 0; i < numGlyphs; i++) {
|
for (i = 0; i < numGlyphs; i++) {
|
||||||
X.pack_stream.pack('L', [glyphs[i].id]);
|
X.pack_stream.pack('L', [glyphs[i].id]);
|
||||||
}
|
}
|
||||||
// width + heiht + origin xy + advance xy
|
// width + heiht + origin xy + advance xy
|
||||||
for (i = 0; i < numGlyphs; i++) {
|
for (i = 0; i < numGlyphs; i++) {
|
||||||
X.pack_stream.pack('SSssss', [glyphs[i].width, glyphs[i].height, glyphs[i].x, glyphs[i].y, glyphs[i].offX, glyphs[i].offY]);
|
X.pack_stream.pack('SSssss', [glyphs[i].width, glyphs[i].height, -glyphs[i].x, glyphs[i].y, glyphs[i].offX, glyphs[i].offY]);
|
||||||
}
|
}
|
||||||
// image
|
// image
|
||||||
for (i = 0; i < numGlyphs; i++) {
|
for (i = 0; i < numGlyphs; i++) {
|
||||||
|
|
@ -401,8 +401,8 @@ exports.requireExt = function(display, callback)
|
||||||
|
|
||||||
//AddGlyphsFromPicture, opcode=21 (not in spec)
|
//AddGlyphsFromPicture, opcode=21 (not in spec)
|
||||||
// FreeGlyps - opcode 22
|
// FreeGlyps - opcode 22
|
||||||
// gsid(L) , glyphs.length (L) + each glyph id (L)
|
// gsid(L) , glyphs.length (L) + each glyph id (L)
|
||||||
//
|
//
|
||||||
|
|
||||||
// each GlyphEle:
|
// each GlyphEle:
|
||||||
// 1 byte - number of glyphs
|
// 1 byte - number of glyphs
|
||||||
|
|
@ -419,13 +419,16 @@ exports.requireExt = function(display, callback)
|
||||||
// [ "just string (0,0) offset is used", [ 10, 10, "string offseted 10,10 from previous pen position" ], 1234567 ] 1234567 is glypfset id or FONT
|
// [ "just string (0,0) offset is used", [ 10, 10, "string offseted 10,10 from previous pen position" ], 1234567 ] 1234567 is glypfset id or FONT
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: pre-process input so strings larger than 254 chars are supported
|
||||||
|
// (split them into multiple entries with 0,0 offset)
|
||||||
|
|
||||||
var compositeGlyphsOpcodeFromBits = [,,,,,,,,23,,,,,,,,24,,,,,,,,,,,,,,,,25];
|
var compositeGlyphsOpcodeFromBits = [,,,,,,,,23,,,,,,,,24,,,,,,,,,,,,,,,,25];
|
||||||
var formatFromBits = [,,,,,,,,'C',,,,,,,,'S',,,,,,,,,,,,,,,,'L'];
|
var formatFromBits = [,,,,,,,,'C',,,,,,,,'S',,,,,,,,,,,,,,,,'L'];
|
||||||
ext.CompositeGlyphs = function(glyphBits, op, src, dst, maskFormat, gsid, srcX, srcY, glyphs)
|
ext.CompositeGlyphs = function(glyphBits, op, src, dst, maskFormat, gsid, srcX, srcY, glyphs)
|
||||||
{
|
{
|
||||||
var opcode = compositeGlyphsOpcodeFromBits[glyphBits];
|
var opcode = compositeGlyphsOpcodeFromBits[glyphBits];
|
||||||
var charFormat = formatFromBits[glyphBits];
|
var charFormat = formatFromBits[glyphBits];
|
||||||
var charLength = glyphBits / 8;
|
var charLength = glyphBits / 8;
|
||||||
X.seq_num++;
|
X.seq_num++;
|
||||||
var length = 7;
|
var length = 7;
|
||||||
for (var i=0; i < glyphs.length; ++i) {
|
for (var i=0; i < glyphs.length; ++i) {
|
||||||
|
|
@ -433,13 +436,13 @@ exports.requireExt = function(display, callback)
|
||||||
switch (typeof g) {
|
switch (typeof g) {
|
||||||
case 'string':
|
case 'string':
|
||||||
length += xutil.padded_length(g.length*charLength)/4 + 2;
|
length += xutil.padded_length(g.length*charLength)/4 + 2;
|
||||||
break;
|
break;
|
||||||
case 'object':
|
case 'object':
|
||||||
length += xutil.padded_length(g[2].length*charLength)/4 + 2;
|
length += xutil.padded_length(g[2].length*charLength)/4 + 2;
|
||||||
break;
|
break;
|
||||||
case 'number': // glyphset id
|
case 'number': // glyphset id
|
||||||
length += 2;
|
length += 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
X.pack_stream.pack(
|
X.pack_stream.pack(
|
||||||
|
|
@ -452,22 +455,21 @@ exports.requireExt = function(display, callback)
|
||||||
case 'string':
|
case 'string':
|
||||||
X.pack_stream.pack('Cxxxssp', [g.length, 0, 0, g]);
|
X.pack_stream.pack('Cxxxssp', [g.length, 0, 0, g]);
|
||||||
break;
|
break;
|
||||||
case 'object': // array
|
case 'object': // array
|
||||||
X.pack_stream.pack('Cxxxssp', [g[2].length, g[0], g[1], g[2]]);
|
X.pack_stream.pack('Cxxxssp', [g[2].length, g[0], g[1], g[2]]);
|
||||||
break;
|
break;
|
||||||
case 'number': // glyphset id
|
case 'number': // glyphset id
|
||||||
X.pack_stream.pack('CxxxL', [0xff, g]);
|
X.pack_stream.pack('CxxxL', [0xff, g]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
X.pack_stream.flush();
|
X.pack_stream.flush();
|
||||||
};
|
};
|
||||||
|
|
||||||
ext.CompositeGlyphs8 = function(op, src, dst, maskFormat, gsid, srcX, srcY, glyphs)
|
ext.CompositeGlyphs8 = function(op, src, dst, maskFormat, gsid, srcX, srcY, glyphs)
|
||||||
{
|
{
|
||||||
return ext.CompositeGlyphs(8, op, src, dst, maskFormat, gsid, srcX, srcY, glyphs);
|
return ext.CompositeGlyphs(8, op, src, dst, maskFormat, gsid, srcX, srcY, glyphs);
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: not ready yet. fix format in CompositeGlyphs to support 16 bit chars
|
// TODO: not ready yet. fix format in CompositeGlyphs to support 16 bit chars
|
||||||
ext.CompositeGlyphs16 = function(op, src, dst, maskFormat, gsid, srcX, srcY, glyphs)
|
ext.CompositeGlyphs16 = function(op, src, dst, maskFormat, gsid, srcX, srcY, glyphs)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue