Fix ordering of smaller text boxes

This commit is contained in:
ZXY101
2024-02-05 12:43:36 +02:00
parent 159a6d50d4
commit 2e28843a07

View File

@@ -7,7 +7,8 @@
export let page: Page; export let page: Page;
export let src: File; export let src: File;
$: textBoxes = page.blocks.map((block) => { $: textBoxes = page.blocks
.map((block) => {
const { img_height, img_width } = page; const { img_height, img_width } = page;
const { box, font_size, lines, vertical } = block; const { box, font_size, lines, vertical } = block;
@@ -20,6 +21,7 @@
const width = xmax - xmin; const width = xmax - xmin;
const height = ymax - ymin; const height = ymax - ymin;
const area = width * height;
const textBox = { const textBox = {
left: `${xmin}px`, left: `${xmin}px`,
@@ -28,10 +30,14 @@
height: `${height}px`, height: `${height}px`,
fontSize: $settings.fontSize === 'auto' ? `${font_size}px` : `${$settings.fontSize}pt`, fontSize: $settings.fontSize === 'auto' ? `${font_size}px` : `${$settings.fontSize}pt`,
writingMode: vertical ? 'vertical-rl' : 'horizontal-tb', writingMode: vertical ? 'vertical-rl' : 'horizontal-tb',
lines lines,
area
}; };
return textBox; return textBox;
})
.sort(({ area: a }, { area: b }) => {
return a - b;
}); });
$: fontWeight = $settings.boldFont ? 'bold' : '400'; $: fontWeight = $settings.boldFont ? 'bold' : '400';