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:
Denis Koroskin 2015-12-23 14:55:45 -08:00 committed by Ahmed El-Helw
parent e3abc51dd7
commit fd3e213593
2 changed files with 14 additions and 0 deletions

View File

@ -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,

View File

@ -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;
}