Skip to content

Commit

Permalink
Add font override properties in struct
Browse files Browse the repository at this point in the history
  • Loading branch information
louiszawadzki committed Jan 5, 2024
1 parent effe3c6 commit bea5879
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ public class SessionReplayWireframesBuilder {
static let fontSize: CGFloat = 10
}

public struct FontOverride {
let size: CGFloat?

public init(size: CGFloat?) {
self.size = size
}
}

public func createShapeWireframe(
id: WireframeID,
frame: CGRect,
Expand Down Expand Up @@ -98,7 +106,7 @@ public class SessionReplayWireframesBuilder {
clip: SRContentClip? = nil,
textColor: CGColor? = nil,
font: UIFont? = nil,
fontSize: CGFloat? = nil,
fontOverride: FontOverride? = nil,
fontScalingEnabled: Bool = false,
borderColor: CGColor? = nil,
borderWidth: CGFloat? = nil,
Expand All @@ -117,7 +125,7 @@ public class SessionReplayWireframesBuilder {
)
)

var fontSize = Int64(withNoOverflow: fontSize ?? font?.pointSize ?? Fallback.fontSize)
var fontSize = Int64(withNoOverflow: fontOverride?.size ?? font?.pointSize ?? Fallback.fontSize)
if text.count > 0, fontScalingEnabled {
// Calculates the approximate font size for available text area √(frameArea / numberOfCharacters)
let area = textFrame.width * textFrame.height
Expand Down

0 comments on commit bea5879

Please sign in to comment.