mirror of
https://github.com/danbulant/node-x11
synced 2026-05-19 04:18:35 +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++;
|
||||
var numGlyphs = glyphs.length;
|
||||
var imageBytes = 0;
|
||||
var glyphPaddedLength;
|
||||
var glyphLength;
|
||||
var glyphPaddedLength;
|
||||
var glyphLength;
|
||||
for (var i = 0; i < numGlyphs; i++) {
|
||||
glyphLength = glyphs[i].image.length;
|
||||
if (glyphLength % 4 !== 0)
|
||||
throw new Error('Glyph image length must be divisible by 4!');
|
||||
imageBytes += glyphLength;
|
||||
}
|
||||
throw new Error('Glyph image length must be divisible by 4!');
|
||||
imageBytes += glyphLength;
|
||||
}
|
||||
var len = numGlyphs * 4 + imageBytes/4 + 3;
|
||||
// TODO: check length, use bigReq
|
||||
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 20, len, gsid, glyphs.length]);
|
||||
// BigReq: S + [ length ] replaced with SL + [ 0, length+1 ]
|
||||
//X.pack_stream.pack('CCSLLL', [ext.majorOpcode, 20, 0, len+1, gsid, glyphs.length]);
|
||||
|
||||
// glyph ids
|
||||
// glyph ids
|
||||
for (i = 0; i < numGlyphs; i++) {
|
||||
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++) {
|
||||
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
|
||||
for (i = 0; i < numGlyphs; i++) {
|
||||
|
|
@ -401,8 +401,8 @@ exports.requireExt = function(display, callback)
|
|||
|
||||
//AddGlyphsFromPicture, opcode=21 (not in spec)
|
||||
// FreeGlyps - opcode 22
|
||||
// gsid(L) , glyphs.length (L) + each glyph id (L)
|
||||
//
|
||||
// gsid(L) , glyphs.length (L) + each glyph id (L)
|
||||
//
|
||||
|
||||
// each GlyphEle:
|
||||
// 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
|
||||
|
||||
|
||||
// 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 formatFromBits = [,,,,,,,,'C',,,,,,,,'S',,,,,,,,,,,,,,,,'L'];
|
||||
ext.CompositeGlyphs = function(glyphBits, op, src, dst, maskFormat, gsid, srcX, srcY, glyphs)
|
||||
{
|
||||
var opcode = compositeGlyphsOpcodeFromBits[glyphBits];
|
||||
var charFormat = formatFromBits[glyphBits];
|
||||
var charLength = glyphBits / 8;
|
||||
var opcode = compositeGlyphsOpcodeFromBits[glyphBits];
|
||||
var charFormat = formatFromBits[glyphBits];
|
||||
var charLength = glyphBits / 8;
|
||||
X.seq_num++;
|
||||
var length = 7;
|
||||
for (var i=0; i < glyphs.length; ++i) {
|
||||
|
|
@ -433,13 +436,13 @@ exports.requireExt = function(display, callback)
|
|||
switch (typeof g) {
|
||||
case 'string':
|
||||
length += xutil.padded_length(g.length*charLength)/4 + 2;
|
||||
break;
|
||||
case 'object':
|
||||
break;
|
||||
case 'object':
|
||||
length += xutil.padded_length(g[2].length*charLength)/4 + 2;
|
||||
break;
|
||||
case 'number': // glyphset id
|
||||
break;
|
||||
case 'number': // glyphset id
|
||||
length += 2;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
X.pack_stream.pack(
|
||||
|
|
@ -452,22 +455,21 @@ exports.requireExt = function(display, callback)
|
|||
case 'string':
|
||||
X.pack_stream.pack('Cxxxssp', [g.length, 0, 0, g]);
|
||||
break;
|
||||
case 'object': // array
|
||||
case 'object': // array
|
||||
X.pack_stream.pack('Cxxxssp', [g[2].length, g[0], g[1], g[2]]);
|
||||
break;
|
||||
case 'number': // glyphset id
|
||||
case 'number': // glyphset id
|
||||
X.pack_stream.pack('CxxxL', [0xff, g]);
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
X.pack_stream.flush();
|
||||
};
|
||||
|
||||
ext.CompositeGlyphs8 = function(op, src, dst, maskFormat, gsid, srcX, srcY, glyphs)
|
||||
{
|
||||
return ext.CompositeGlyphs(8, 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);
|
||||
};
|
||||
|
||||
// TODO: not ready yet. fix format in CompositeGlyphs to support 16 bit chars
|
||||
ext.CompositeGlyphs16 = function(op, src, dst, maskFormat, gsid, srcX, srcY, glyphs)
|
||||
|
|
|
|||
Loading…
Reference in a new issue