Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add font size argument in text Wireframe builder #1613

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,6 +106,7 @@ public class SessionReplayWireframesBuilder {
clip: SRContentClip? = nil,
textColor: CGColor? = nil,
font: UIFont? = nil,
fontOverride: FontOverride? = nil,
fontScalingEnabled: Bool = false,
borderColor: CGColor? = nil,
borderWidth: CGFloat? = nil,
Expand All @@ -116,7 +125,7 @@ public class SessionReplayWireframesBuilder {
)
)

var fontSize = Int64(withNoOverflow: 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