mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 06:14:22 +01:00
fix emojiMask not working correctly.
its index was being reset for each wrapped line thus not corresponding to the actual position in the full paragraph content anymore. basically if the emojiMask was [false, false, false, true, false] for "abc🔛d" but that text was split in two lines like: "abc 🔛d" then the emojiMask would be read at 0, 1, 2, then 0, 1. now that is fixed.
This commit is contained in:
@@ -518,10 +518,11 @@ func drawShapedRunAt(
|
||||
clr color.Color,
|
||||
out shaping.Output,
|
||||
emojiMask []bool,
|
||||
maskBaseIndex int,
|
||||
img draw.Image,
|
||||
startX,
|
||||
startY int,
|
||||
) int {
|
||||
) (charsWritten int, endingX int) {
|
||||
scale := float32(fontSize) / float32(out.Face.Upem())
|
||||
|
||||
b := img.Bounds()
|
||||
@@ -536,7 +537,7 @@ func drawShapedRunAt(
|
||||
|
||||
face := out.Face
|
||||
currentScale := scale
|
||||
if emojiMask[i] {
|
||||
if emojiMask[maskBaseIndex+i] {
|
||||
face = emojiFace
|
||||
currentScale = float32(fontSize) / float32(face.Upem())
|
||||
}
|
||||
@@ -551,10 +552,12 @@ func drawShapedRunAt(
|
||||
panic("format not supported for glyph")
|
||||
}
|
||||
|
||||
charsWritten++
|
||||
x += fixed266ToFloat(g.XAdvance)
|
||||
}
|
||||
f.Draw()
|
||||
return int(math.Ceil(float64(x)))
|
||||
|
||||
return charsWritten, int(math.Ceil(float64(x)))
|
||||
}
|
||||
|
||||
// this draws a font glyph (i.e. a letter) according to instructions and scale and whatever
|
||||
|
||||
Reference in New Issue
Block a user