diff --git a/hbjs.cc b/hbjs.cc index 946ab2d..849a43b 100644 --- a/hbjs.cc +++ b/hbjs.cc @@ -190,6 +190,11 @@ static hb_bool_t do_trace (hb_buffer_t *buffer, HB_BUFFER_SERIALIZE_FORMAT_JSON, HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES); user_data->consumed += consumed; + if (hb_buffer_get_content_type(buffer) == HB_BUFFER_CONTENT_TYPE_GLYPHS) { + _user_data_printf (user_data, ", \"glyphs\": true"); + } else { + _user_data_printf (user_data, ", \"glyphs\": false"); + } _user_data_printf (user_data, "},\n"); return 1; diff --git a/test/index.js b/test/index.js index d7b9ae0..f7a69cd 100644 --- a/test/index.js +++ b/test/index.js @@ -153,4 +153,33 @@ describe('shape', function () { expect(glyphs[2]).to.deep.equal({cl: 1, g: 101, ax: 269, ay: 0, dx: 0, dy: 0, flags: 0} /* ب */); expect(glyphs[3]).to.deep.equal({cl: 0, g: 50, ax: 235, ay: 0, dx: 0, dy: 0, flags: 0} /* أ */); }); + + it('shape with tracing', function () { + this.blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf'))); + this.face = hb.createFace(this.blob); + this.font = hb.createFont(this.face); + this.buffer = hb.createBuffer(); + this.buffer.addText('abc'); + this.buffer.guessSegmentProperties(); + const result = hb.shapeWithTrace(this.font, this.buffer, 0, 0) + expect(result).to.have.lengthOf(42); + expect(result[0]).to.deep.equal({ + "m": "start table GSUB", + "glyphs": true, + "t": [ + {cl: 0, g: 68}, + {cl: 1, g: 69}, + {cl: 2, g: 70}, + ], + }); + expect(result[41]).to.deep.equal({ + "m": "end table GPOS", + "glyphs": true, + "t": [ + {cl: 0, g: 68, ax: 561, ay: 0, dx: 0, dy: 0}, + {cl: 1, g: 69, ax: 615, ay: 0, dx: 0, dy: 0}, + {cl: 2, g: 70, ax: 480, ay: 0, dx: 0, dy: 0}, + ], + }); + }); });