text: correct arabic diacritics handling

This commit fixes the association of diacritical marks with the proper script
during text segmentation, as well as fixing the visual position of diacritical
marks. The prior code inverted the Y axis positioning for diacritics, which made
them frequently overlap the glyph they were meant to appear above or below.

Signed-off-by: runitclean <runitclean@disroot.org>
This commit is contained in:
runitclean
2026-01-06 14:57:06 +00:00
committed by Chris Waldon
parent 99647591f6
commit 3af0ebb3a8
2 changed files with 105 additions and 3 deletions
+3 -3
View File
@@ -312,7 +312,7 @@ func splitByScript(inputs []shaping.Input, documentDir di.Direction, buf []shapi
r := input.Text[i]
runeScript := language.LookupScript(r)
if runeScript == language.Common || runeScript == currentInput.Script {
if runeScript == language.Common || runeScript == language.Inherited || runeScript == currentInput.Script {
continue
}
@@ -661,7 +661,7 @@ func (s *shaperImpl) Shape(pathOps *op.Ops, gs []Glyph) clip.PathSpec {
outline := glyphData
// Move to glyph position.
pos := f32.Point{
X: fixedToFloat((g.X - x) - g.Offset.X),
X: fixedToFloat((g.X - x) + g.Offset.X),
Y: -fixedToFloat(g.Offset.Y),
}
builder.Move(pos.Sub(lastPos))
@@ -761,7 +761,7 @@ func (s *shaperImpl) Bitmaps(ops *op.Ops, gs []Glyph) op.CallOp {
imgSize = bitmapData.size
}
off := op.Affine(f32.AffineId().Offset(f32.Point{
X: fixedToFloat((g.X - x) - g.Offset.X),
X: fixedToFloat((g.X - x) + g.Offset.X),
Y: fixedToFloat(g.Offset.Y + g.Bounds.Min.Y),
})).Push(ops)
cl := clip.Rect{Max: imgSize}.Push(ops)