fix: bei Cluster-Ueberschuss die breitesten N Cluster waehlen
Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 30s
CI / test-go-edu-search (push) Successful in 30s
CI / test-python-klausur (push) Failing after 2m5s
CI / test-python-agent-core (push) Successful in 22s
CI / test-nodejs-website (push) Successful in 20s
Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 30s
CI / test-go-edu-search (push) Successful in 30s
CI / test-python-klausur (push) Failing after 2m5s
CI / test-python-agent-core (push) Successful in 22s
CI / test-nodejs-website (push) Successful in 20s
Wenn mehr Pixel-Cluster als Text-Gruppen existieren (z.B. wegen Box-Rahmenlinien), werden jetzt die N breitesten Cluster ausgewaehlt statt naiv clusters[i]→groups[i] zuzuordnen. Text-Cluster sind breiter als Rahmenlinien-Cluster. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -126,10 +126,20 @@ export function usePixelWordPositions(
|
||||
|
||||
const wordPos: WordPosition[] = []
|
||||
|
||||
if (groups.length > 1 && clusters.length >= groups.length) {
|
||||
// Multiple text groups with enough clusters: map each group to a cluster
|
||||
// When more clusters than groups, pick the N widest clusters
|
||||
// (text clusters are wider than box-border clusters)
|
||||
let matchClusters = clusters
|
||||
if (groups.length > 1 && clusters.length > groups.length) {
|
||||
matchClusters = [...clusters]
|
||||
.sort((a, b) => (b.end - b.start) - (a.end - a.start))
|
||||
.slice(0, groups.length)
|
||||
.sort((a, b) => a.start - b.start)
|
||||
}
|
||||
|
||||
if (groups.length > 1 && matchClusters.length >= groups.length) {
|
||||
// Multiple text groups with matching clusters
|
||||
for (let i = 0; i < groups.length; i++) {
|
||||
const cl = clusters[i]
|
||||
const cl = matchClusters[i]
|
||||
const clusterW = cl.end - cl.start + 1
|
||||
const measured = ctx.measureText(groups[i])
|
||||
const autoFontPx = refFontSize * (clusterW / measured.width)
|
||||
|
||||
Reference in New Issue
Block a user