Skip to content

Commit d82eb05

Browse files
authored
Fixed type error per #1031 (#1032)
1 parent f9dac07 commit d82eb05

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ declare namespace Tesseract {
4141
load_number_dawg: string
4242
load_bigram_dawg: string
4343
}
44-
44+
4545
type LoggerMessage = {
4646
jobId: string
4747
progress: number
4848
status: string
4949
userJobId: string
5050
workerId: string
5151
}
52-
52+
5353
interface WorkerOptions {
5454
corePath: string
5555
langPath: string
@@ -166,7 +166,7 @@ declare namespace Tesseract {
166166
interface RowAttributes {
167167
ascenders: number;
168168
descenders: number;
169-
row_height: number;
169+
rowHeight: number;
170170
}
171171
interface Bbox {
172172
x0: number;

tests/recognize.test.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,21 @@ describe('recognize()', () => {
318318
expect(blocks[0].paragraphs[0].lines[0].words[0].text).to.be('繁體');
319319
expect(blocks[0].paragraphs[0].lines[0].text).to.be('繁體 中 文 測試\n');
320320
}).timeout(TIMEOUT);
321+
322+
it('should report RowAttributes', async () => {
323+
await worker.reinitialize('eng');
324+
const { data: { blocks } } = await worker.recognize(`${IMAGE_PATH}/testocr.png`, {}, { blocks: true });
325+
const firstLine = blocks[0].paragraphs[0].lines[0];
326+
327+
expect(firstLine.rowAttributes).to.be.an('object');
328+
expect(firstLine.rowAttributes.ascenders).to.be.a('number');
329+
expect(firstLine.rowAttributes.descenders).to.be.a('number');
330+
expect(firstLine.rowAttributes.rowHeight).to.be.a('number');
331+
332+
expect(firstLine.rowAttributes.ascenders).to.be.greaterThan(0);
333+
expect(firstLine.rowAttributes.descenders).to.be.greaterThan(0);
334+
expect(firstLine.rowAttributes.rowHeight).to.be.greaterThan(0);
335+
}).timeout(TIMEOUT);
321336
});
322337

323338
describe('should support layout blocks (json) output', () => {

0 commit comments

Comments
 (0)