Skip to content

Commit ad328fe

Browse files
committed
[fix]: horizontal and vertical position of title
1 parent 46aced0 commit ad328fe

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Sources/ScriptToolkit/NSImageExtension.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ public extension NSImage {
9696
func image(withText text: String, attributes: [NSAttributedString.Key: Any], horizontalTitlePosition: CGFloat, verticalTitlePosition: CGFloat) -> NSImage {
9797
let image = self
9898
let text = text as NSString
99-
let options: NSString.DrawingOptions = [.usesLineFragmentOrigin, .usesFontLeading]
99+
// let options: NSString.DrawingOptions = [.usesLineFragmentOrigin, .usesFontLeading]
100100

101-
let textSize = text.boundingRect(with: image.size, options: options, attributes: attributes).size
101+
// let textSize = text.boundingRect(with: image.size, options: options, attributes: attributes).size
102102

103-
let x = (image.size.width - textSize.width) / 2
104-
let y = (image.size.height - textSize.height) / 2
105-
let point = NSMakePoint(x * horizontalTitlePosition, y * verticalTitlePosition)
103+
// let x = (image.size.width - textSize.width) / 2
104+
// let y = (image.size.height - textSize.height) / 2
105+
let point = NSMakePoint(image.size.width * horizontalTitlePosition, image.size.height * verticalTitlePosition)
106106

107107
image.lockFocus()
108108
text.draw(at: point, withAttributes: attributes)

0 commit comments

Comments
 (0)