Skip to content

Commit

Permalink
Add drawTextInRect to Swift
Browse files Browse the repository at this point in the history
  • Loading branch information
gurtt committed Dec 20, 2024
1 parent 8da924b commit 1078eb7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Sources/PlaydateKit/Core/Graphics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,28 @@ public enum Graphics {
CInt(point.y)
))
}

/// Draws the text in the given rectangle using the provided options. If no font has
/// been set with setFont, the default system font Asheville Sans 14 Light is used.
public static func drawTextInRect(
_ text: String,
in rect: Rect,
wrap: TextWrap = .clip,
aligned: TextAlignment = .left
) {
graphics.drawTextInRect.unsafelyUnwrapped(
text,
text.utf8.count,
.kUTF8Encoding,
CInt(rect.x),
CInt(rect.y),
CInt(rect.width),
CInt(rect.height),
wrap,
aligned
)
}


/// Draws an ellipse inside the rectangle `rect` of width `lineWidth` (inset from the rectangle bounds).
/// If `startAngle` != `endAngle`, this draws an arc between the given angles.
Expand Down

0 comments on commit 1078eb7

Please sign in to comment.