fix(编辑能力): 修正文字边框与改宽手柄错位

This commit is contained in:
xiaoqidun committed 2026-10-28 11:57:28 +08:00
1 parent 1215f7aa08
commit e35533859c
1 file changed
+6 -4
+6 -4
View File
@@ -3401,12 +3401,13 @@ func (e *businessEngine) editorObjects(index int, text *ofdgo.PageText) ([]any,
inverse, _ := matrix.Invert() inverse, _ := matrix.Invert()
local := inverse.TransformBox(box) local := inverse.TransformBox(box)
width := math.Max(object.TextObject.Size, local.X+local.W) width := math.Max(object.TextObject.Size, local.X+local.W)
if layout != (ofdgo.TextLayout{}) { if capability.LayoutKnown {
item["paragraphWidth"] = frame.W item["paragraphWidth"] = frame.W
width = frame.W
} }
frame = ofdgo.Box{W: width, H: math.Max(object.TextObject.Size, local.Y+local.H)} frame = ofdgo.Box{W: width, H: math.Max(object.TextObject.Size, local.Y+local.H)}
item["textFrame"] = map[string]any{"width": frame.W, "height": frame.H, "matrix": e.editorMatrix(matrix)} item["textFrame"] = map[string]any{"width": frame.W, "height": frame.H, "matrix": e.editorMatrix(matrix)}
if layout.Wrap { if capability.LayoutKnown {
bounds := matrix.TransformBox(frame) bounds := matrix.TransformBox(frame)
item["x"], item["y"], item["width"], item["height"] = bounds.X, bounds.Y, bounds.W, bounds.H item["x"], item["y"], item["width"], item["height"] = bounds.X, bounds.Y, bounds.W, bounds.H
} }
@@ -4017,16 +4018,17 @@ func (e *businessEngine) compositeObjects(args []platformValue) (any, error) {
inverse, _ := member.Matrix.Invert() inverse, _ := member.Matrix.Invert()
local := inverse.TransformBox(box) local := inverse.TransformBox(box)
width := math.Max(object.Size, local.X+local.W) width := math.Max(object.Size, local.X+local.W)
if layout != (ofdgo.TextLayout{}) { if member.Capabilities.LayoutKnown {
frame, err := object.TextFrame() frame, err := object.TextFrame()
if err != nil { if err != nil {
return nil, err return nil, err
} }
item["paragraphWidth"] = frame.W item["paragraphWidth"] = frame.W
width = frame.W
} }
frame := ofdgo.Box{W: width, H: math.Max(object.Size, local.Y+local.H)} frame := ofdgo.Box{W: width, H: math.Max(object.Size, local.Y+local.H)}
item["textFrame"] = map[string]any{"width": frame.W, "height": frame.H, "matrix": e.editorMatrix(member.Matrix)} item["textFrame"] = map[string]any{"width": frame.W, "height": frame.H, "matrix": e.editorMatrix(member.Matrix)}
if layout.Wrap { if member.Capabilities.LayoutKnown {
bounds := member.Matrix.TransformBox(frame) bounds := member.Matrix.TransformBox(frame)
item["x"], item["y"], item["width"], item["height"] = bounds.X, bounds.Y, bounds.W, bounds.H item["x"], item["y"], item["width"], item["height"] = bounds.X, bounds.Y, bounds.W, bounds.H
} }