Transform applies given 2D transform matrix to the text character rotations, scaling, and positions, so that the text is rendered according to that transform. The fontSty is the font style used for specifying the font originally.
(mat math32.Matrix2, fontSty *styles.FontRender, ctxt *units.Context)
| 345 | // scaling, and positions, so that the text is rendered according to that transform. |
| 346 | // The fontSty is the font style used for specifying the font originally. |
| 347 | func (tr *Text) Transform(mat math32.Matrix2, fontSty *styles.FontRender, ctxt *units.Context) { |
| 348 | orgsz := fontSty.Size |
| 349 | tmpsty := styles.FontRender{} |
| 350 | tmpsty = *fontSty |
| 351 | rot := mat.ExtractRot() |
| 352 | scx, scy := mat.ExtractScale() |
| 353 | scalex := scx / scy |
| 354 | if scalex == 1 { |
| 355 | scalex = 0 |
| 356 | } |
| 357 | for si := range tr.Spans { |
| 358 | sr := &(tr.Spans[si]) |
| 359 | sr.RelPos = mat.MulVector2AsVector(sr.RelPos) |
| 360 | sr.LastPos = mat.MulVector2AsVector(sr.LastPos) |
| 361 | for i := range sr.Render { |
| 362 | rn := &sr.Render[i] |
| 363 | if rn.Face != nil { |
| 364 | tmpsty.Size = units.Value{Value: orgsz.Value * scy, Unit: orgsz.Unit, Dots: orgsz.Dots * scy} // rescale by y |
| 365 | tmpsty.Font = OpenFont(&tmpsty, ctxt) |
| 366 | rn.Face = tmpsty.Face.Face |
| 367 | } |
| 368 | rn.RelPos = mat.MulVector2AsVector(rn.RelPos) |
| 369 | rn.Size.Y *= scy |
| 370 | rn.Size.X *= scx |
| 371 | rn.RotRad = rot |
| 372 | rn.ScaleX = scalex |
| 373 | } |
| 374 | } |
| 375 | tr.BBox = tr.BBox.MulMatrix2(mat) |
| 376 | } |
| 377 | |
| 378 | // UpdateBBox updates the overall text bounding box |
| 379 | // based on actual glyph bounding boxes. |
no test coverage detected