Skip to content

Commit 9700e48

Browse files
committed
[Text] Account for font leading so descenders are not clipped
Summary: Prior to this diff, descenders (the hanging tail on letters like g and j) were clipped on the last line because the text measurer did not account for the font leading. With `NSStringDrawingUsesFontLeading` it honors the fonts line spacing. To test: open the Text demo of the UIExplorer and see that the bottom of the letter g is no longer clipped off. ## Before ![Screenshot Before](https://cloud.githubusercontent.com/assets/379606/6364746/1c5527a0-bc60-11e4-8aeb-2147a6eb6596.png) ## After ![Screenshot After](https://cloud.githubusercontent.com/assets/379606/6364747/1e9abe58-bc60-11e4-8c34-9f20ad8572ff.png) Closes facebook#96 Github Author: James Ide <[email protected]> Test Plan: Imported from GitHub, without a `Test Plan:` line.
1 parent e9a8cba commit 9700e48

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Libraries/Text/RCTShadowText.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
static css_dim_t RCTMeasure(void *context, float width)
1515
{
1616
RCTShadowText *shadowText = (__bridge RCTShadowText *)context;
17-
CGSize computedSize = [[shadowText attributedString] boundingRectWithSize:(CGSize){isnan(width) ? CGFLOAT_MAX : width, CGFLOAT_MAX} options:NSStringDrawingUsesLineFragmentOrigin context:nil].size;
17+
CGSize computedSize = [[shadowText attributedString] boundingRectWithSize:(CGSize){isnan(width) ? CGFLOAT_MAX : width, CGFLOAT_MAX}
18+
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
19+
context:nil].size;
1820

1921
css_dim_t result;
2022
result.dimensions[CSS_WIDTH] = RCTCeilPixelValue(computedSize.width);

0 commit comments

Comments
 (0)