From 03adb4260fc0c09686f2d3f2b773253b31759186 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Wed, 15 Oct 2025 19:14:42 +0300 Subject: [PATCH] patch fractional font size issue (#9199) --- patches/react-native-uitextview+1.4.0.patch | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 patches/react-native-uitextview+1.4.0.patch diff --git a/patches/react-native-uitextview+1.4.0.patch b/patches/react-native-uitextview+1.4.0.patch new file mode 100644 index 0000000000..345e6b0e85 --- /dev/null +++ b/patches/react-native-uitextview+1.4.0.patch @@ -0,0 +1,33 @@ +diff --git a/node_modules/react-native-uitextview/ios/RNUITextViewShadow.swift b/node_modules/react-native-uitextview/ios/RNUITextViewShadow.swift +index c34ba71..13d576a 100644 +--- a/node_modules/react-native-uitextview/ios/RNUITextViewShadow.swift ++++ b/node_modules/react-native-uitextview/ios/RNUITextViewShadow.swift +@@ -159,13 +159,23 @@ class RNUITextViewShadow: RCTShadowView { + let maxSize = CGSize(width: CGFloat(maxWidth), height: CGFloat(MAXFLOAT)) + let textSize = self.attributedText.boundingRect(with: maxSize, options: .usesLineFragmentOrigin, context: nil) + +- var totalLines = self.lineHeight == 0.0 ? 0 : Int(ceil(textSize.height / self.lineHeight)) +- +- if self.numberOfLines != 0, totalLines > self.numberOfLines { +- totalLines = self.numberOfLines ++ var finalHeight: CGFloat ++ ++ if self.numberOfLines != 0 && self.lineHeight != 0.0 { ++ // numberOfLines is set with custom line height - need to calculate lines and snap to lineHeight multiples ++ // NOTE: this calculation can be inaccurate with fractional font sizes ++ var totalLines = Int(ceil(textSize.height / self.lineHeight)) ++ if totalLines > self.numberOfLines { ++ totalLines = self.numberOfLines ++ } ++ finalHeight = CGFloat(totalLines) * self.lineHeight ++ } else { ++ // Either no numberOfLines limit, or no custom lineHeight - use actual text height ++ // (numberOfLines without custom lineHeight is handled by the UITextView's textContainer.maximumNumberOfLines) ++ finalHeight = textSize.height + } + +- self.frameSize = CGSize(width: CGFloat(maxWidth), height: CGFloat(CGFloat(totalLines) * self.lineHeight)) ++ self.frameSize = CGSize(width: CGFloat(maxWidth), height: finalHeight) + return YGSize(width: Float(self.frameSize.width), height: Float(self.frameSize.height)) + } +