Contents

generateText(_:extrusionDepth:font:containerFrame:alignment:lineBreakMode:)

Generates a 3D mesh for rendering static text.

Declaration

@MainActor @preconcurrency static func generateText(_ string: String, extrusionDepth: Float = 0.25, font: MeshResource.Font = .systemFont(ofSize: MeshResource.Font.systemFontSize), containerFrame: CGRect = CGRect.zero, alignment: CTTextAlignment = .left, lineBreakMode: CTLineBreakMode = .byTruncatingTail) -> MeshResource
@MainActor @preconcurrency static func generateText(_ string: String, extrusionDepth: Float = 0.25, font: MeshResource.Font = .systemFont(ofSize: 16), containerFrame: CGRect = CGRect.zero, alignment: CTTextAlignment = .left, lineBreakMode: CTLineBreakMode = .byTruncatingTail) -> MeshResource

Parameters

  • string:

    The text to render.

  • extrusionDepth:

    The extent, in meters, of the extruded text in the z-axis direction.

  • font:

    The font to use. The font size is in meters.

  • containerFrame:

    The size, in meters, of the text frame in the local coordinate system where the text is laid out. The text frame has the same origin as the local coordinate system.

    Use a frame size of (0,0) to tell the method to create a frame large enough to contain the generated text.

  • alignment:

    How the text should be aligned in the text frame.

  • lineBreakMode:

    How the text should wrap when reaching a frame boundary.

Return Value

The text mesh.

See Also

Creating a text mesh resource