Update RCTText.PAINT's text size to ensure that ellipsis is measured correctly
Summary: placeholder Reviewed By: ahmedre Differential Revision: D2786310
This commit is contained in:
parent
e3abc51dd7
commit
fd3e213593
|
@ -106,6 +106,12 @@ import com.facebook.react.uimanager.ViewProps;
|
|||
|
||||
int maximumWidth = Float.isNaN(width) ? Integer.MAX_VALUE : (int) width;
|
||||
|
||||
// Make sure we update the paint's text size. If we don't do this, ellipsis might be measured
|
||||
// incorrecly (but drawn correctly, which almost feels like an Android bug, because width of the
|
||||
// created layout may exceed the requested width). This is safe to do without making a copy per
|
||||
// RCTText instance because that size is ONLY used to measure the ellipsis but not to draw it.
|
||||
PAINT.setTextSize(getFontSize());
|
||||
|
||||
// at this point we need to create a StaticLayout to measure the text
|
||||
StaticLayout layout = StaticLayoutHelper.make(
|
||||
text,
|
||||
|
|
|
@ -152,6 +152,14 @@ import com.facebook.react.uimanager.ViewProps;
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns font size for this node.
|
||||
* When called on RCTText, this value is never -1 (unset).
|
||||
*/
|
||||
protected final int getFontSize() {
|
||||
return mFontStylingSpan.getFontSize();
|
||||
}
|
||||
|
||||
protected int getDefaultFontSize() {
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue