Skip to content

Commit

Permalink
Merge pull request #581 from DataDog/louiszawadzki/fix-font-size-for-…
Browse files Browse the repository at this point in the history
…ios-SR

Pass font size to text wireframe builder
  • Loading branch information
louiszawadzki authored Jan 9, 2024
2 parents e57805b + 07739e9 commit 614d61e
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ internal class RCTTextViewRecorder: SessionReplayNodeRecorder {
textAlignment: shadow.textAttributes.alignment,
textColor: shadow.textAttributes.foregroundColor?.cgColor,
textObfuscator: textObfuscator(context),
font: nil, // Custom fonts are currently not supported for iOS
fontSize: shadow.textAttributes.fontSize,
contentRect: shadow.contentFrame
)
let node = SessionReplayNode(viewAttributes: attributes, wireframesBuilder: builder)
Expand All @@ -82,14 +82,17 @@ internal class RCTTextViewRecorder: SessionReplayNodeRecorder {
// Black color. This is the default for RN: https://github.com/facebook/react-native/blob/a5ee029cd02a636136058d82919480eeeb700067/packages/react-native/Libraries/Text/RCTTextAttributes.mm#L250
let DEFAULT_COLOR = UIColor.black.cgColor

// Default font size for RN: https://github.com/facebook/react-native/blob/16dff523b0a16d7fa9b651062c386885c2f48a6b/packages/react-native/React/Views/RCTFont.mm#L396
let DEFAULT_FONT_SIZE = CGFloat(14)

internal struct RCTTextViewWireframesBuilder: SessionReplayNodeWireframesBuilder {
let wireframeID: WireframeID
let attributes: SessionReplayViewAttributes
let text: String?
var textAlignment: NSTextAlignment
let textColor: CGColor?
let textObfuscator: SessionReplayTextObfuscating
let font: UIFont?
let fontSize: CGFloat
let contentRect: CGRect

public var wireframeRect: CGRect {
Expand Down Expand Up @@ -142,7 +145,7 @@ internal struct RCTTextViewWireframesBuilder: SessionReplayNodeWireframesBuilder
textAlignment: .init(systemTextAlignment: textAlignment, vertical: .top),
clip: clip,
textColor: textColor ?? DEFAULT_COLOR,
font: font,
fontOverride: SessionReplayWireframesBuilder.FontOverride(size: fontSize.isNaN ? DEFAULT_FONT_SIZE : fontSize),
borderColor: attributes.layerBorderColor,
borderWidth: attributes.layerBorderWidth,
backgroundColor: attributes.backgroundColor,
Expand Down

0 comments on commit 614d61e

Please sign in to comment.