diff --git a/Examples/UIExplorer/js/TextExample.android.js b/Examples/UIExplorer/js/TextExample.android.js index 4c275b74a..54ef95ac9 100644 --- a/Examples/UIExplorer/js/TextExample.android.js +++ b/Examples/UIExplorer/js/TextExample.android.js @@ -411,6 +411,23 @@ class TextExample extends React.Component { This very long text should be truncated with dots in the beginning. + + + + + Ey + + Default + + + + Ey + + includeFontPadding: false + + + By default Android will put extra space above text to allow for upper-case accents or other ascenders. With some fonts, this can make text look slightly misaligned when centered vertically. + ); } @@ -421,6 +438,14 @@ var styles = StyleSheet.create({ left: 5, backgroundColor: 'rgba(100, 100, 100, 0.3)' }, + includeFontPaddingText: { + fontSize: 120, + fontFamily: 'sans-serif', + backgroundColor: '#EEEEEE', + color: '#000000', + textAlignVertical: 'center', + alignSelf: 'center', + } }); module.exports = TextExample; diff --git a/Libraries/Text/TextStylePropTypes.js b/Libraries/Text/TextStylePropTypes.js index bc85c427b..4c84de66d 100644 --- a/Libraries/Text/TextStylePropTypes.js +++ b/Libraries/Text/TextStylePropTypes.js @@ -66,6 +66,13 @@ const TextStylePropTypes = { textAlignVertical: ReactPropTypes.oneOf( ['auto' /*default*/, 'top', 'bottom', 'center'] ), + /** + * Set to `false` to remove extra font padding intended to make space for certain ascenders / descenders. + * With some fonts, this padding can make text look slightly misaligned when centered vertically. + * For best results also set `textAlignVertical` to `center`. Default is true. + * @platform android + */ + includeFontPadding: ReactPropTypes.bool, textDecorationLine: ReactPropTypes.oneOf( ['none' /*default*/, 'underline', 'line-through', 'underline line-through'] ), diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java index 562576e09..255581a10 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java @@ -143,6 +143,11 @@ public class ReactTextViewManager extends BaseViewManager