diff --git a/Sources/SpeziOnboarding/Consent/Export/ConsentDocument+Export.swift b/Sources/SpeziOnboarding/Consent/Export/ConsentDocument+Export.swift index 37b15fd..02e62ba 100644 --- a/Sources/SpeziOnboarding/Consent/Export/ConsentDocument+Export.swift +++ b/Sources/SpeziOnboarding/Consent/Export/ConsentDocument+Export.swift @@ -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 } diff --git a/Sources/SpeziOnboarding/Consent/Export/ConsentDocumentExportRepresentation+Render.swift b/Sources/SpeziOnboarding/Consent/Export/ConsentDocumentExportRepresentation+Render.swift index ac47ecd..dac6ad3 100644 --- a/Sources/SpeziOnboarding/Consent/Export/ConsentDocumentExportRepresentation+Render.swift +++ b/Sources/SpeziOnboarding/Consent/Export/ConsentDocumentExportRepresentation+Render.swift @@ -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)) } diff --git a/Tests/SpeziOnboardingTests/Resources/known_good_pdf_one_page_ios.pdf b/Tests/SpeziOnboardingTests/Resources/known_good_pdf_one_page_ios.pdf index 3b9e272..2c2e83a 100644 Binary files a/Tests/SpeziOnboardingTests/Resources/known_good_pdf_one_page_ios.pdf and b/Tests/SpeziOnboardingTests/Resources/known_good_pdf_one_page_ios.pdf differ diff --git a/Tests/SpeziOnboardingTests/Resources/known_good_pdf_two_pages_ios.pdf b/Tests/SpeziOnboardingTests/Resources/known_good_pdf_two_pages_ios.pdf index e23dbb4..be453c7 100644 Binary files a/Tests/SpeziOnboardingTests/Resources/known_good_pdf_two_pages_ios.pdf and b/Tests/SpeziOnboardingTests/Resources/known_good_pdf_two_pages_ios.pdf differ