25 lines
730 B
Swift
25 lines
730 B
Swift
import UIKit
|
|
|
|
#if canImport(DTCoreText)
|
|
import DTCoreText
|
|
#endif
|
|
|
|
enum RDEPUBDarkImageAdjuster {
|
|
#if canImport(DTCoreText)
|
|
|
|
static func adjustIfNeeded(
|
|
_ content: NSMutableAttributedString,
|
|
in range: NSRange? = nil,
|
|
configuration: RDEPUBReaderConfiguration
|
|
) -> NSMutableAttributedString {
|
|
// DTCoreText retains rendering state on its original image attachment.
|
|
// Replacing that attachment with a newly rendered UIImage preserves its
|
|
// layout size but can leave its drawing callback empty in dark mode.
|
|
// Keep the original attachment until image dimming can be performed
|
|
// without changing the attachment instance.
|
|
return content
|
|
}
|
|
|
|
#endif
|
|
}
|