1
- import { PERC_SUPPORTED_STYLES , STYLESETS , stylePropTypes } from './HTMLUtils' ;
1
+ import { PERC_SUPPORTED_STYLES , STYLESETS , ABSOLUTE_FONT_SIZE , stylePropTypes } from './HTMLUtils' ;
2
2
import { generateDefaultBlockStyles , generateDefaultTextStyles } from './HTMLDefaultStyles' ;
3
3
import checkPropTypes from './checkPropTypes' ;
4
4
@@ -101,7 +101,7 @@ export function _getElementCSSClasses (htmlAttribs) {
101
101
* @param {object } { parentTag, emSize, ignoredStyles }
102
102
* @returns {object }
103
103
*/
104
- function cssToRNStyle ( css , styleset , { parentTag, emSize, ignoredStyles, allowedStyles } ) {
104
+ function cssToRNStyle ( css , styleset , { parentTag, emSize, ptSize , ignoredStyles, allowedStyles } ) {
105
105
const styleProps = stylePropTypes [ styleset ] ;
106
106
return Object . keys ( css )
107
107
. filter ( ( key ) => allowedStyles ? allowedStyles . indexOf ( key ) !== - 1 : true )
@@ -138,6 +138,13 @@ function cssToRNStyle (css, styleset, { parentTag, emSize, ignoredStyles, allowe
138
138
const pxSize = parseFloat ( value . replace ( 'em' , '' ) ) * emSize ;
139
139
return [ key , pxSize ] ;
140
140
}
141
+ if ( value . search ( 'pt' ) !== - 1 ) {
142
+ const pxSize = parseFloat ( value . replace ( 'pt' , '' ) ) * ptSize ;
143
+ return [ key , pxSize ] ;
144
+ }
145
+ if ( key === 'fontSize' ) {
146
+ return mapAbsoluteFontSize ( key , value ) ;
147
+ }
141
148
// See if we can convert a 20px to a 20 automagically
142
149
const numericValue = parseFloat ( value . replace ( 'px' , '' ) ) ;
143
150
if ( ! isNaN ( numericValue ) ) {
@@ -158,6 +165,19 @@ function cssToRNStyle (css, styleset, { parentTag, emSize, ignoredStyles, allowe
158
165
} , { } ) ;
159
166
}
160
167
168
+ /**
169
+ * @param {string } key: the key of style
170
+ * @param {string } value: the value of style
171
+ * @return {array }
172
+ */
173
+ function mapAbsoluteFontSize ( key , value ) {
174
+ let fontSize = value ;
175
+ if ( ABSOLUTE_FONT_SIZE . hasOwnProperty ( value ) ) {
176
+ fontSize = ABSOLUTE_FONT_SIZE [ value ] ;
177
+ }
178
+ return [ key , fontSize ] ;
179
+ }
180
+
161
181
/**
162
182
* @param str: the css style string
163
183
* @param styleset=STYLESETS.TEXT: the styleset to convert the styles against
0 commit comments