mirror of
https://github.com/danbulant/node-x11
synced 2026-05-22 05:49:11 +00:00
fix in changefont glyphele serialization
This commit is contained in:
parent
cd29ef9dde
commit
cefaaf942f
1 changed files with 18 additions and 4 deletions
|
|
@ -372,11 +372,24 @@ exports.requireExt = function(display, callback)
|
|||
var imageBytes = 0;
|
||||
var glyphPaddedLength;
|
||||
var glyphLength;
|
||||
var stride;
|
||||
var glyph;
|
||||
for (var i = 0; i < numGlyphs; i++) {
|
||||
glyph = glyphs[i];
|
||||
if (glyph.width % 4 !== 0) {
|
||||
var stride = (glyph.width+3)&~3;
|
||||
var res = new Buffer(glyph.height*stride);
|
||||
res.fill(0);
|
||||
for (var y=0; y < glyph.height; ++y) {
|
||||
glyph.image.copy(res, y*stride, y*glyph.width, y*glyph.width + glyph.width);
|
||||
}
|
||||
glyph.image = res;
|
||||
glyph.width = stride;
|
||||
}
|
||||
glyphLength = glyphs[i].image.length;
|
||||
if (glyphLength % 4 !== 0)
|
||||
throw new Error('Glyph image length must be divisible by 4!');
|
||||
imageBytes += glyphLength;
|
||||
glyph.offX = glyph.offX / 64;
|
||||
glyph.offY = glyph.offY / 64;
|
||||
}
|
||||
var len = numGlyphs * 4 + imageBytes/4 + 3;
|
||||
// TODO: check length, use bigReq
|
||||
|
|
@ -447,6 +460,7 @@ exports.requireExt = function(display, callback)
|
|||
var charLength = glyphBits / 8;
|
||||
X.seq_num++;
|
||||
var length = 7;
|
||||
var glyphs_length_split = [];
|
||||
for (var i=0; i < glyphs.length; ++i) {
|
||||
var g = glyphs[i];
|
||||
switch (typeof g) {
|
||||
|
|
@ -457,7 +471,7 @@ exports.requireExt = function(display, callback)
|
|||
length += xutil.padded_length(g[2].length*charLength)/4 + 2;
|
||||
break;
|
||||
case 'number': // glyphset id
|
||||
length += 2;
|
||||
length += 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -475,7 +489,7 @@ exports.requireExt = function(display, callback)
|
|||
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]);
|
||||
X.pack_stream.pack('CxxxSSL', [0xff, 0, 0, g]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue