Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify signature UIImage export #66

Merged
merged 3 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,18 @@ extension ConsentDocument {

#if !os(macOS)
private var signatureImage: UIImage {
var updatedDrawing = PKDrawing()

for stroke in signature.strokes {
// As the `PKDrawing.image()` function automatically converts the ink color dependent on the used color scheme (light or dark mode),
// force the ink used in the `UIImage` of the `PKDrawing` to always be black by adjusting the signature ink according to the color scheme.
let blackStroke = PKStroke(
ink: PKInk(stroke.ink.inkType, color: colorScheme == .light ? .black : .white),
path: stroke.path,
transform: stroke.transform,
mask: stroke.mask
)

updatedDrawing.strokes.append(blackStroke)
}

#if os(iOS)
let scale = UIScreen.main.scale
#else
let scale = 3.0 // retina scale is default
#endif

return updatedDrawing.image(
// As the `PKDrawing.image()` function automatically converts the ink color dependent on the used color scheme (light or dark mode),
// force the tint color used in the `UIImage` to `black`.
return signature.image(
from: .init(x: 0, y: 0, width: signatureSize.width, height: signatureSize.height),
scale: scale
)
).withRenderingMode(.alwaysTemplate).withTintColor(.black)
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ extension ConsentDocumentExportRepresentation {
markdown: markdown,
options: .init(interpretedSyntax: .inlineOnlyPreservingWhitespace)
)) ?? AttributedString(String(localized: "MARKDOWN_LOADING_ERROR", bundle: .module))

markdownString.font = configuration.fontSettings.documentContentFont

// Indirection needed to hide `Sendable` warnings of `NSFont` on macOS
markdownString.mergeAttributes(.init([.font: configuration.fontSettings.documentContentFont]))

return PDFAttributedText(text: NSAttributedString(markdownString))
}
Expand Down
Binary file not shown.
Binary file not shown.
Loading