2017-12-11 1 views
1

, 우리는 다음과 같이 설정할 수 있습니다 React Native의 fontFamily 소품을 사용하여 글꼴 그룹을 어떻게 설정할 수 있습니까? CSS에서와 마찬가지로

font-family:"Times New Roman",Georgia,Serif; 

그러나 RN에서

, 우리가
fontFamily: 'MidPlane00v3.1', 

우리가 어떻게 CSS를 같이 사용할 수있는 하나 개의 폰트를 설정할 수 있습니까? 글꼴 롤백 메커니즘을 사용하여 여러 바이트 중국어 단어를 표시해야합니다!

+0

u는 하나의 단어에서 다른 글꼴 스타일을 사용하는 그게입니다 어떻게 하시겠습니까? –

+0

@Adarsh ​​Sreeram, 한 문장에 여러 바이트의 중국어 단어를 표시하고 싶습니다! 예를 들어, MidPlane00과 MidPlane02라는 두 개의 글꼴 파일이 있습니다. 서로 다른 중국어 단어가 포함되어 있습니다.이 두 단어가 하나 인 '' 글꼴을 그룹화하기 위해 fontFamily를 사용하는 것만으로 생각할 수 있습니다. –

답변

0

React Native에서 컴포넌트에 대한 모든 텍스트 노드를 줄 바꿈해야합니다.

확인 당신의 대답이이 공식 문서 : 어떤 목적을위한 Offical Doc

// we define available font weight and styles for each font here 
const font = { 
    OpenSans: { 
    weights: { 
     ExtraBold: '800', 
     Bold: '700', 
     SemiBold: '600', 
     Light: '300', 
     Normal: '400' 
    }, 
    styles: { 
     Italic: 'italic' 
    } 
    }, 
    Verdana: ..., 
    Tahoma: ..., 
    ... 
} 

// generate styles for a font with given weight and style 
export const fontMaker = (options = {}) => { 
    let { weight, style, family } = Object.assign({ 
    weight: null, 
    style: null, 
    family: 'OpenSans' 
    }, options) 

    const { weights, styles } = font[family] 

    if (Platform.OS === 'android') { 
    weight = weights[weight] ? weight : '' 
    style = styles[style] ? style : '' 

    const suffix = weight + style 

    return { 
     fontFamily: family + (suffix.length ? `-${suffix}` : '') 
    } 
    } else { 
    weight = weights[weight] || weights.Normal 
    style = styles[style] || 'normal' 

    return { 
     fontFamily: family, 
     fontWeight: weight, 
     fontStyle: style 
    } 
    } 
} 

Refernce

관련 문제