mirror of
https://github.com/danbulant/node-x11
synced 2026-06-16 21:21:20 +00:00
support 16 and 32 bit strings
This commit is contained in:
parent
88266bd3cb
commit
cd29ef9dde
1 changed files with 29 additions and 15 deletions
|
|
@ -380,9 +380,10 @@ exports.requireExt = function(display, callback)
|
|||
}
|
||||
var len = numGlyphs * 4 + imageBytes/4 + 3;
|
||||
// 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 ]
|
||||
//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
|
||||
for (i = 0; i < numGlyphs; i++) {
|
||||
|
|
@ -422,8 +423,23 @@ exports.requireExt = function(display, callback)
|
|||
// 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'];
|
||||
var bufferWriteBits = [,,,,,,,,'writeUInt8',,,,,,,,'writeUInt16LE',,,,,,,,,,,,,,,,'writeUInt32LE'];
|
||||
|
||||
// 8/16/32 bit string + 4-byte pad
|
||||
function wstring(bits, s) {
|
||||
var charLength = bits / 8;
|
||||
var dataLength = s.length*charLength;
|
||||
var res = new Buffer(xutil.padded_length(dataLength));
|
||||
debugger;
|
||||
var write = res[bufferWriteBits[bits]]
|
||||
res.fill(0);
|
||||
for(var i=0; i < s.length; i++)
|
||||
write.call(res, s.charCodeAt(i), i*charLength);
|
||||
return res;
|
||||
}
|
||||
|
||||
var compositeGlyphsOpcodeFromBits = [,,,,,,,,23,,,,,,,,24,,,,,,,,,,,,,,,,25];
|
||||
ext.CompositeGlyphs = function(glyphBits, op, src, dst, maskFormat, gsid, srcX, srcY, glyphs)
|
||||
{
|
||||
var opcode = compositeGlyphsOpcodeFromBits[glyphBits];
|
||||
|
|
@ -453,10 +469,10 @@ exports.requireExt = function(display, callback)
|
|||
var g = glyphs[i];
|
||||
switch (typeof g) {
|
||||
case 'string':
|
||||
X.pack_stream.pack('Cxxxssp', [g.length, 0, 0, g]);
|
||||
X.pack_stream.pack('Cxxxssa', [g.length, 0, 0, wstring(glyphBits, g)]);
|
||||
break;
|
||||
case 'object': // array
|
||||
X.pack_stream.pack('Cxxxssp', [g[2].length, g[0], g[1], g[2]]);
|
||||
X.pack_stream.pack('Cxxxssa', [g[2].length, g[0], g[1], wstring(glyphBits, g[2])]);
|
||||
break;
|
||||
case 'number': // glyphset id
|
||||
X.pack_stream.pack('CxxxL', [0xff, g]);
|
||||
|
|
@ -471,17 +487,15 @@ exports.requireExt = function(display, callback)
|
|||
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)
|
||||
{
|
||||
return ext.CompositeGlyphs(8, op, src, dst, maskFormat, gsid, srcX, srcY, glyphs);
|
||||
};
|
||||
ext.CompositeGlyphs16 = function(op, src, dst, maskFormat, gsid, srcX, srcY, glyphs)
|
||||
{
|
||||
return ext.CompositeGlyphs(16, op, src, dst, maskFormat, gsid, srcX, srcY, glyphs);
|
||||
};
|
||||
|
||||
// TODO: not ready yet. fix format in CompositeGlyphs to support 32 bit chars
|
||||
ext.CompositeGlyphs32 = function(op, src, dst, maskFormat, gsid, srcX, srcY, glyphs)
|
||||
{
|
||||
return ext.CompositeGlyphs(8, op, src, dst, maskFormat, gsid, srcX, srcY, glyphs);
|
||||
};
|
||||
ext.CompositeGlyphs32 = function(op, src, dst, maskFormat, gsid, srcX, srcY, glyphs)
|
||||
{
|
||||
return ext.CompositeGlyphs(32, op, src, dst, maskFormat, gsid, srcX, srcY, glyphs);
|
||||
};
|
||||
|
||||
// TODO: implement xutil-like code https://github.com/alexer/python-xlib-render/blob/master/xutil.py
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue