From fb8411d4dfcd6fa900204457f51d2284c65f4a18 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Thu, 11 Jun 2020 12:32:30 -0700 Subject: [PATCH] Round text size to closest larger pixel size Summary: Changelog: [Internal] Round calculated text size to closest larger pixel size. In Paper we do this as well in https://fburl.com/diffusion/w2pj6ea0 Why do we need this? For example, we calculate height of the text to be 16.707235, yoga takes this value and assigns text to have height 17 anyway. I assume Yoga uses this extra 0.3 points of height to move other things around a little bit because Yoga doesn't deal with exact values. Reviewed By: shergin Differential Revision: D21999032 fbshipit-source-id: 73923dc3e27fa110adb3f76cfa635e0bfdc672d4 --- .../textlayoutmanager/platform/ios/RCTTextLayoutManager.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ReactCommon/fabric/textlayoutmanager/platform/ios/RCTTextLayoutManager.mm b/ReactCommon/fabric/textlayoutmanager/platform/ios/RCTTextLayoutManager.mm index 9bd39d06624..7e0c4a9231a 100644 --- a/ReactCommon/fabric/textlayoutmanager/platform/ios/RCTTextLayoutManager.mm +++ b/ReactCommon/fabric/textlayoutmanager/platform/ios/RCTTextLayoutManager.mm @@ -10,6 +10,7 @@ #import "NSTextStorage+FontScaling.h" #import "RCTAttributedTextUtils.h" +#import #import #import @@ -56,6 +57,8 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(EllipsizeMode ellipsi CGSize size = [layoutManager usedRectForTextContainer:textContainer].size; + size = (CGSize){RCTCeilPixelValue(size.width), RCTCeilPixelValue(size.height)}; + __block auto attachments = TextMeasurement::Attachments{}; [textStorage