     
     open override func updateFonts(with traitCollection: UITraitCollection) {
         super.updateFonts(with: traitCollection)
-        messageLabel.font = UIFont.wmf_preferredFontForFontFamily(.system, withTextStyle: .subheadline)
-        actionButton.titleLabel?.font = UIFont.wmf_preferredFontForFontFamily(.system, withTextStyle: .body)
-        dismissButton.titleLabel?.font = UIFont.wmf_preferredFontForFontFamily(.system, withTextStyle: .footnote)
-        captionTextView.font = UIFont.wmf_preferredFontForFontFamily(.system, withTextStyle: .footnote)
+        messageLabel.font = UIFont.wmf_preferredFontForFontFamily(.system, withTextStyle: .subheadline, compatibleWithTraitCollection: traitCollection)
+        actionButton.titleLabel?.font = UIFont.wmf_preferredFontForFontFamily(.system, withTextStyle: .body, compatibleWithTraitCollection: traitCollection)
+        dismissButton.titleLabel?.font = UIFont.wmf_preferredFontForFontFamily(.system, withTextStyle: .footnote, compatibleWithTraitCollection: traitCollection)
+        updateCaptionTextViewWithAttributedCaption()
     }
     
     @objc var isImageViewHidden = false {

            setNeedsLayout()
        }
    }
    
    @objc var caption: NSAttributedString? {
        set {
            guard let text = newValue else {
                isCaptionHidden = true
                return
            }
            
            let mutableText = NSMutableAttributedString(attributedString: text)
            guard mutableText.length > 0 else {
                isCaptionHidden = true
                return
            }
            
            let pStyle = NSMutableParagraphStyle()
            pStyle.lineBreakMode = .byWordWrapping
            pStyle.baseWritingDirection = .natural
            pStyle.alignment = .center
            let attributes = [NSAttributedStringKey.paragraphStyle: pStyle]
            mutableText.addAttributes(attributes, range: NSMakeRange(0, mutableText.length))
            captionTextView.attributedText = mutableText

            isCaptionHidden = false
        }

        get {
            return captionTextView.attributedText
        }
    }
    

            }
            origin.y += separatorFrame.height
            origin.y += captionSpacing
            // set width first to get proper content size
            captionTextView.frame = CGRect(origin: origin, size: CGSize(width: widthMinusMargins, height: 32))
            let captionTextViewSize = captionTextView.contentSize
            let captionFrame = CGRect(origin: origin, size: CGSize(width: widthMinusMargins, height: captionTextViewSize.height))
            if (apply) {
                captionTextView.frame = captionFrame
            }
            origin.y += captionFrame.height
        } else {
            origin.y += layoutMargins.bottom
        }
    
        return CGSize(width: size.width, height: origin.y)
    }
}
