Add double underline drawing for specific grammar rules

This commit is contained in:
Aljaž Grilc 2025-05-28 21:01:43 +02:00
parent c67adcdc99
commit b9ab9b6a64

View File

@ -692,7 +692,9 @@ class BesService {
const x2 = rect.right
const y = rect.bottom
const scale = (rect.bottom - rect.top) / 18
this.drawAttentionRequired(x1, x2, y, amplitude, scale)
if (ruleId !== 'MORFOLOGIK_RULE') {
this.drawDoubleUnderline(x1, x2, y, scale)
} else this.drawAttentionRequired(x1, x2, y, amplitude, scale)
}
markerY1 = Math.min(...match.highlights.map(rect => rect.top))
@ -892,6 +894,23 @@ class BesService {
this.ctx.stroke()
}
/**
*
* @param {Number} x1 Sign left [px]
* @param {Number} x2 Sign right [px]
* @param {Number} y Sign baseline [px]
* @param {Number} scale Sign scale
*/
drawDoubleUnderline(x1, x2, y, scale) {
const dpr = window.devicePixelRatio
this.ctx.beginPath()
this.ctx.moveTo(x1 * dpr, (y - 2 * scale) * dpr)
this.ctx.lineTo(x2 * dpr, (y - 2 * scale) * dpr)
this.ctx.moveTo(x1 * dpr, (y + 1 * scale) * dpr)
this.ctx.lineTo(x2 * dpr, (y + 1 * scale) * dpr)
this.ctx.stroke()
}
/**
* Sets markup font
*