mirror of
https://github.com/status-im/react-native.git
synced 2025-01-09 17:15:54 +00:00
833961e05d
Summary: 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. We have found that the effect is very noticeable with certain custom fonts on Android. On iOS the font aligns vertically as expected. Android exposes a property `includeFontPadding` that will remove this extra padding if set to false. This PR exposes that to JS, and adds it to the documentation and UIExplorer. Closes https://github.com/facebook/react-native/pull/9323 Differential Revision: D4266713 Pulled By: lacker fbshipit-source-id: f9711254bc26c09b4586a865f0e95ef4bf77cf3f
98 lines
2.8 KiB
JavaScript
98 lines
2.8 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule TextStylePropTypes
|
|
* @flow
|
|
*/
|
|
'use strict';
|
|
|
|
const ReactPropTypes = require('React').PropTypes;
|
|
const ColorPropType = require('ColorPropType');
|
|
const ViewStylePropTypes = require('ViewStylePropTypes');
|
|
|
|
const TextStylePropTypes = {
|
|
...ViewStylePropTypes,
|
|
|
|
color: ColorPropType,
|
|
fontFamily: ReactPropTypes.string,
|
|
fontSize: ReactPropTypes.number,
|
|
fontStyle: ReactPropTypes.oneOf(['normal', 'italic']),
|
|
/**
|
|
* Specifies font weight. The values 'normal' and 'bold' are supported for
|
|
* most fonts. Not all fonts have a variant for each of the numeric values,
|
|
* in that case the closest one is chosen.
|
|
*/
|
|
fontWeight: ReactPropTypes.oneOf(
|
|
['normal' /*default*/, 'bold',
|
|
'100', '200', '300', '400', '500', '600', '700', '800', '900']
|
|
),
|
|
/**
|
|
* @platform ios
|
|
*/
|
|
fontVariant: ReactPropTypes.arrayOf(
|
|
ReactPropTypes.oneOf([
|
|
'small-caps',
|
|
'oldstyle-nums',
|
|
'lining-nums',
|
|
'tabular-nums',
|
|
'proportional-nums',
|
|
])
|
|
),
|
|
textShadowOffset: ReactPropTypes.shape(
|
|
{width: ReactPropTypes.number, height: ReactPropTypes.number}
|
|
),
|
|
textShadowRadius: ReactPropTypes.number,
|
|
textShadowColor: ColorPropType,
|
|
/**
|
|
* @platform ios
|
|
*/
|
|
letterSpacing: ReactPropTypes.number,
|
|
lineHeight: ReactPropTypes.number,
|
|
/**
|
|
* Specifies text alignment. The value 'justify' is only supported on iOS and
|
|
* fallbacks to `left` on Android.
|
|
*/
|
|
textAlign: ReactPropTypes.oneOf(
|
|
['auto' /*default*/, 'left', 'right', 'center', 'justify']
|
|
),
|
|
/**
|
|
* @platform android
|
|
*/
|
|
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']
|
|
),
|
|
/**
|
|
* @platform ios
|
|
*/
|
|
textDecorationStyle: ReactPropTypes.oneOf(
|
|
['solid' /*default*/, 'double', 'dotted','dashed']
|
|
),
|
|
/**
|
|
* @platform ios
|
|
*/
|
|
textDecorationColor: ColorPropType,
|
|
/**
|
|
* @platform ios
|
|
*/
|
|
writingDirection: ReactPropTypes.oneOf(
|
|
['auto' /*default*/, 'ltr', 'rtl']
|
|
),
|
|
};
|
|
|
|
module.exports = TextStylePropTypes;
|