text/v2: refactoring

This commit is contained in:
Hajime Hoshi 2024-04-21 22:46:51 +09:00
parent bc9e9d8562
commit bf7acd54bb

View File

@ -178,14 +178,16 @@ func (g *GoTextFaceSource) shape(text string, face *GoTextFace) ([]shaping.Outpu
return out.outputs, out.glyphs
}
g.f.SetVariations(face.variations)
f := face.Source.f
f.SetVariations(face.variations)
runes := []rune(text)
input := shaping.Input{
Text: runes,
RunStart: 0,
RunEnd: len(runes),
Direction: face.diDirection(),
Face: face.Source.f,
Face: f,
FontFeatures: face.features,
Size: float64ToFixed26_6(face.Size),
Script: face.gScript(),
@ -193,7 +195,7 @@ func (g *GoTextFaceSource) shape(text string, face *GoTextFace) ([]shaping.Outpu
}
var seg shaping.Segmenter
inputs := seg.Split(input, &singleFontmap{face: face.Source.f})
inputs := seg.Split(input, &singleFontmap{face: f})
if face.Direction == DirectionRightToLeft {
// Reverse the input for RTL texts.
@ -222,7 +224,7 @@ func (g *GoTextFaceSource) shape(text string, face *GoTextFace) ([]shaping.Outpu
switch data := g.f.GlyphData(gl.GlyphID).(type) {
case api.GlyphOutline:
if out.Direction.IsSideways() {
data.Sideways(fixed26_6ToFloat32(-gl.YOffset) / fixed26_6ToFloat32(out.Size) * float32(face.Source.f.Upem()))
data.Sideways(fixed26_6ToFloat32(-gl.YOffset) / fixed26_6ToFloat32(out.Size) * float32(f.Upem()))
}
segs = data.Segments
case api.GlyphSVG: