TextAlign

public enum TextAlign : UInt32

TextAlign adjusts the text relative to the text position. TextAlign affects glyphs drawn with: Canvas.drawText, Canvas.drawPosText, Canvas.drawPosTextH, Canvas.drawTextOnPath, Canvas.drawTextOnPathHV, Canvas.rawTextRSXform, Canvas.drawTextBlob, and Canvas.drawString; as well as calls that place text glyphs like getTextWidths() and getTextPath().

The text position is set by the font for both horizontal and vertical text. Typically, for horizontal text, the position is to the left side of the glyph on the base line; and for vertical text, the position is the horizontal center of the glyph at the caps height.

Align adjusts the glyph position to center it or move it to abut the position using the metrics returned by the font.

Align defaults to .left.

  • Leaves the glyph at the position computed by the font offset by the text position.

    Declaration

    Swift

    case left = 0
  • Moves the glyph half its width if flags has .verticalText clear, and half its height if flags has .verticalText set.

    Declaration

    Swift

    case center
  • Moves the glyph by its width if flags has verticalText clear, and by its height if flags has verticalText set.

    Declaration

    Swift

    case right