mirror of
https://github.com/danbulant/node-x11
synced 2026-05-21 05:19:14 +00:00
ComositeGlyph fixes
This commit is contained in:
parent
5b4bcbbe92
commit
8cfac532ec
1 changed files with 49 additions and 39 deletions
|
|
@ -384,54 +384,37 @@ exports.requireExt = function(display, callback)
|
|||
throw new Error('Glyph image length must be divisible by 4!');
|
||||
imageBytes += glyphLength;
|
||||
}
|
||||
console.log(imageBytes);
|
||||
var len = numGlyphs * 4 + imageBytes/4 + 3;
|
||||
// TODO: check length, use bigReq
|
||||
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 20, len, gsid, glyphs.length]);
|
||||
console.log('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]);
|
||||
//console.log('CCSLLL', [ext.majorOpcode, 20, 0, len+1, gsid, glyphs.length]);
|
||||
|
||||
debugger;
|
||||
// glyph ids
|
||||
for (i = 0; i < numGlyphs; i++) {
|
||||
var id = glyphs[i].id;
|
||||
console.log('============= added glyph ', id, String.fromCharCode(id));
|
||||
X.pack_stream.pack('L', [id]);
|
||||
X.pack_stream.pack('L', [glyphs[i].id]);
|
||||
}
|
||||
for (i = 0; i < numGlyphs; i++)
|
||||
{
|
||||
// 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]);
|
||||
console.log('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++) {
|
||||
X.pack_stream.write_queue.push(glyphs[i].image);
|
||||
//X.pack_stream.pack('a', [glyphs[i].image]);
|
||||
var il = glyphs[i].image.length;
|
||||
var pl = xutil.padded_length(il);
|
||||
if (pl - il > 0) {
|
||||
X.pack_stream.write_queue.push(new Buffer(pl - il));
|
||||
}
|
||||
}
|
||||
|
||||
//var padLength = paddedLength - imageBytes;
|
||||
//if (padLength > 0)
|
||||
// X.pack_stream.write_queue.push(new Buffer(padLength));
|
||||
X.pack_stream.flush();
|
||||
}
|
||||
|
||||
//AddGlyphsFromPicture, opcode=21 (not in spec)
|
||||
// FreeGlyps - 22
|
||||
// FreeGlyps - opcode 22
|
||||
// gsid(L) , glyphs.length (L) + each glyph id (L)
|
||||
//
|
||||
|
||||
// each GlyphEle:
|
||||
// 1 byte - number of glyphs
|
||||
// xxx
|
||||
// int16 deltax, deltay
|
||||
// + list of 8/16/32 byte indexes
|
||||
// + list of 8/16/32 byte indexesext.CompositeGlyphs
|
||||
// OR
|
||||
// 255 + 0 + 0 + glyphsetId / font:
|
||||
// CxxxssL, [255, 0, 0, glyphable]
|
||||
|
|
@ -442,40 +425,67 @@ 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
|
||||
|
||||
|
||||
var argnames = require('argnames');
|
||||
|
||||
ext.CompositeGlyphs8 = function(op, src, dst, maskFormat, gsid, srcX, srcY, glyphs)
|
||||
var compositeGlyphsOpcodeFromBits = [,,,,,,,,23,,,,,,,,24,,,,,,,,,,,,,,,,25];
|
||||
var formatFromBits = [,,,,,,,,'C',,,,,,,,'S',,,,,,,,,,,,,,,,'L'];
|
||||
ext.CompositeGlyphs = function(glyphBits, op, src, dst, maskFormat, gsid, srcX, srcY, glyphs)
|
||||
{
|
||||
argnames.dump()
|
||||
|
||||
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) {
|
||||
var g = glyphs[i];
|
||||
switch (typeof g) {
|
||||
case 'string':
|
||||
length += xutil.padded_length(g.length)/4 + 2;
|
||||
length += xutil.padded_length(g.length*charLength)/4 + 2;
|
||||
break;
|
||||
case 'object':
|
||||
length += xutil.padded_length(g[2].length*charLength)/4 + 2;
|
||||
break;
|
||||
case 'number': // glyphset id
|
||||
length += 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
X.pack_stream.pack(
|
||||
'CCSCxxxLLLLss',
|
||||
[ext.majorOpcode, 23, length, op, src, dst, maskFormat, gsid, srcX, srcY]
|
||||
[ext.majorOpcode, opcode, length, op, src, dst, maskFormat, gsid, srcX, srcY]
|
||||
);
|
||||
debugger
|
||||
console.log('CCSCxxxLLLLss', [ext.majorOpcode, 23, length, op, src, dst, maskFormat, gsid, srcX, srcY]);
|
||||
for (var i=0; i < glyphs.length; ++i) {
|
||||
var g = glyphs[i];
|
||||
switch (typeof g) {
|
||||
case 'string':
|
||||
debugger;
|
||||
X.pack_stream.pack('Cxxxssp', [xutil.padded_length(g.length), 0, 0, g]);
|
||||
console.log('Cxxxssp', [xutil.padded_length(g.length), 0, 0, g]);
|
||||
X.pack_stream.pack('Cxxxssp', [g.length, 0, 0, g]);
|
||||
break;
|
||||
case 'object': // array
|
||||
X.pack_stream.pack('Cxxxssp', [g[2].length, g[0], g[1], g[2]]);
|
||||
break;
|
||||
case 'number': // glyphset id
|
||||
X.pack_stream.pack('CxxxL', [0xff, g]);
|
||||
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);
|
||||
};
|
||||
|
||||
// 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);
|
||||
};
|
||||
|
||||
// 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);
|
||||
};
|
||||
|
||||
// TODO: implement xutil-like code https://github.com/alexer/python-xlib-render/blob/master/xutil.py
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue