mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-02 06:35:04 +00:00
Restructure fontSize handling.
This commit is contained in:
@@ -2,7 +2,7 @@ import _ from 'lodash';
|
||||
import React, {Children} from 'react';
|
||||
import TSpan from '../../elements/TSpan';
|
||||
|
||||
const fontRegExp = /^\s*((?:(?:normal|bold|italic)\s+)*)(?:(\d+(?:\.\d+)?)[ptexm%]*(?:\s*\/.*?)?\s+)?\s*"?([^"]*)/i;
|
||||
const fontRegExp = /^\s*((?:(?:normal|bold|italic)\s+)*)(?:(\d+(?:\.\d+)?[ptexm%])*(?:\s*\/.*?)?\s+)?\s*"?([^"]*)/i;
|
||||
const fontFamilyPrefix = /^[\s"']*/;
|
||||
const fontFamilySuffix = /[\s"']*$/;
|
||||
const spaceReg = /\s+/;
|
||||
@@ -42,12 +42,12 @@ function parseFontString(font) {
|
||||
return null;
|
||||
}
|
||||
let fontFamily = extractSingleFontFamily(match[3]);
|
||||
let fontSize = +match[2] || 12;
|
||||
let fontSize = match[2] || "12";
|
||||
let isBold = /bold/.exec(match[1]);
|
||||
let isItalic = /italic/.exec(match[1]);
|
||||
cachedFontObjectsFromString[font] = {
|
||||
fontFamily: fontFamily,
|
||||
fontSize: fontSize,
|
||||
fontSize,
|
||||
fontFamily,
|
||||
fontWeight: isBold ? 'bold' : 'normal',
|
||||
fontStyle: isItalic ? 'italic' : 'normal'
|
||||
};
|
||||
@@ -56,15 +56,14 @@ function parseFontString(font) {
|
||||
|
||||
export function extractFont(props) {
|
||||
let font = props.font;
|
||||
let fontSize = +props.fontSize;
|
||||
|
||||
let ownedFont = {
|
||||
fontFamily: extractSingleFontFamily(props.fontFamily),
|
||||
fontSize: isNaN(fontSize) ? null : fontSize,
|
||||
letterSpacing: props.letterSpacing,
|
||||
fontWeight: props.fontWeight,
|
||||
fontStyle: props.fontStyle,
|
||||
fontSize: props.fontSize,
|
||||
kerning: props.kerning,
|
||||
letterSpacing: props.letterSpacing,
|
||||
};
|
||||
|
||||
if (typeof props.font === 'string') {
|
||||
|
||||
Reference in New Issue
Block a user