| ... | @@ -197,12 +197,19 @@ Size T3MarkdownTextShadowNode::measureContent( | ... | @@ -197,12 +197,19 @@ Size T3MarkdownTextShadowNode::measureContent( |
| 197 | } | 197 | } |
| 198 | if (props.nativeId.rfind("t3-chip:", 0) == 0 && fragmentLength > 0) { | 198 | if (props.nativeId.rfind("t3-chip:", 0) == 0 && fragmentLength > 0) { |
| 199 | const std::string uri = props.nativeId.substr(3); | 199 | const std::string uri = props.nativeId.substr(3); |
| 200 | NSDictionary *payload = T3ContextChipPayload([NSString stringWithUTF8String:uri.c_str()]); | 200 | NSMutableDictionary *payload = |
| | 201 | [T3ContextChipPayload([NSString stringWithUTF8String:uri.c_str()]) mutableCopy]; |
| | 202 | // Chips must scale with the paragraph or smaller Dynamic Type sizes clip them. |
| | 203 | // Store the scaled payload so measurement and the rendered bitmap use the same font. |
| | 204 | payload[@"fontSizeMultiplier"] = @(fontSizeMultiplier); |
| | 205 | NSData *data = [NSJSONSerialization dataWithJSONObject:payload options:0 error:nil]; |
| | 206 | NSString *scaledUri = [@"chip:" stringByAppendingString: |
| | 207 | [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]]; |
| 201 | const CGFloat maxWidth = std::isfinite(layoutConstraints.maximumSize.width) | 208 | const CGFloat maxWidth = std::isfinite(layoutConstraints.maximumSize.width) |
| 202 | ? layoutConstraints.maximumSize.width : 320; | 209 | ? layoutConstraints.maximumSize.width : 320; |
| 203 | const CGSize size = T3ContextChipSize(payload, maxWidth); | 210 | const CGSize size = T3ContextChipSize(payload, maxWidth); |
| 204 | attachmentRanges.push_back(T3MarkdownTextAttachmentRange{ | 211 | attachmentRanges.push_back(T3MarkdownTextAttachmentRange{ |
| 205 | utf16Offset, 1, uri, false, | 212 | utf16Offset, 1, std::string(scaledUri.UTF8String), false, |
| 206 | static_cast<Float>(size.width), static_cast<Float>(size.height), | 213 | static_cast<Float>(size.width), static_cast<Float>(size.height), |
| 207 | }); | 214 | }); |
| 208 | } else if (props.nativeId.rfind(FileAttachmentNativeIdPrefix, 0) == 0 && fragmentLength > 0) { | 215 | } else if (props.nativeId.rfind(FileAttachmentNativeIdPrefix, 0) == 0 && fragmentLength > 0) { |