From 3a3a8147994317041e60df464889b6bff12fedf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=AB=E5=90=89=E3=80=80=E5=9F=BA=E5=9F=8E?= Date: Tue, 30 Jul 2024 20:12:50 +0900 Subject: [PATCH 1/3] Fixes issue #340 --- src/tables/vhea.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tables/vhea.js b/src/tables/vhea.js index 004cdf93..4129a89a 100644 --- a/src/tables/vhea.js +++ b/src/tables/vhea.js @@ -2,11 +2,11 @@ import * as r from 'restructure'; // Vertical Header Table export default new r.Struct({ - version: r.uint16, // Version number of the Vertical Header Table + version: r.int32, // Version number of the Vertical Header Table ascent: r.int16, // The vertical typographic ascender for this font descent: r.int16, // The vertical typographic descender for this font lineGap: r.int16, // The vertical typographic line gap for this font - advanceHeightMax: r.int16, // The maximum advance height measurement found in the font + advanceHeightMax: r.uint16, // The maximum advance height measurement found in the font minTopSideBearing: r.int16, // The minimum top side bearing measurement found in the font minBottomSideBearing: r.int16, // The minimum bottom side bearing measurement found in the font yMaxExtent: r.int16, From 756c0cb977cdc1bd9f1225c2aef1fa86fa5d3b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=AB=E5=90=89=E3=80=80=E5=9F=BA=E5=9F=8E?= Date: Tue, 30 Jul 2024 23:05:09 +0900 Subject: [PATCH 2/3] Fix version reading issue --- src/tables/vhea.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tables/vhea.js b/src/tables/vhea.js index 4129a89a..e668a5a7 100644 --- a/src/tables/vhea.js +++ b/src/tables/vhea.js @@ -2,7 +2,7 @@ import * as r from 'restructure'; // Vertical Header Table export default new r.Struct({ - version: r.int32, // Version number of the Vertical Header Table + version: r.fixed32, // Version number of the Vertical Header Table ascent: r.int16, // The vertical typographic ascender for this font descent: r.int16, // The vertical typographic descender for this font lineGap: r.int16, // The vertical typographic line gap for this font From 87dfd194e17503a58375fa62b394ef9eb8c84a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=AB=E5=90=89=E3=80=80=E5=9F=BA=E5=9F=8E?= Date: Wed, 31 Jul 2024 22:34:47 +0900 Subject: [PATCH 3/3] Add vhea table test --- test/vhea.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/vhea.js diff --git a/test/vhea.js b/test/vhea.js new file mode 100644 index 00000000..c19da29e --- /dev/null +++ b/test/vhea.js @@ -0,0 +1,28 @@ +import assert from 'assert'; +import * as fontkit from 'fontkit'; + +describe('vhea table test', function () { + const font = fontkit.openSync(new URL('data/NotoSansCJK/NotoSansCJKkr-Regular.otf', import.meta.url)); + + it('should retrieve vhea table correctly', function () { + const actualVheaObject = font.vhea; + + const expectedVheaObject = { + version: 1.0625, + ascent: 500, + descent: -500, + lineGap: 0, + advanceHeightMax: 3000, + minTopSideBearing: -1002, + minBottomSideBearing: -677, + yMaxExtent: 2928, + caretSlopeRise: 0, + caretSlopeRun: 1, + caretOffset: 0, + metricDataFormat: 0, + numberOfMetrics: 65167, + }; + + assert.deepStrictEqual(actualVheaObject, expectedVheaObject, 'The vhea table does not match the expected format.'); + }); +});