packArtifactLeftToRight method

void packArtifactLeftToRight()

Adjusts the positions of artifacts to pack them from left to right.

This method repositions all artifacts in the band, aligning them from left to right with proper spacing. It performs the following steps:

  1. Adds top and bottom padding to each artifact's matrix.
  2. Shifts each artifact horizontally to align with the left edge of the band.
  3. Adjusts the vertical position of each artifact to align with the band's top.
  4. Updates the artifact's rectangle positions.
  5. Increments the left position for the next artifact, including character spacing.

This method modifies the positions of all artifacts in the band to create a left-aligned, properly spaced arrangement.

Implementation

void packArtifactLeftToRight() {
  double left = this.rectangle.left;

  for (final Artifact artifact in artifacts) {
    artifact.matrix.padTopBottom(
      paddingTop: (artifact.matrix.rectangle.top - rectangle.top).toInt(),
      paddingBottom:
          (rectangle.bottom - artifact.matrix.rectangle.bottom).toInt(),
    );

    final double dx = left - artifact.matrix.rectangle.left;
    final double dy = rectangle.top - artifact.matrix.rectangle.top;
    artifact.matrix.rectangle =
        artifact.matrix.rectangle.shift(Offset(dx, dy));
    artifact.matrix.rectangle = artifact.matrix.rectangle;
    left += artifact.matrix.rectangle.width;
    left += kerningWidth;
  }
}