src/assets/fonts์ ์ํ๋ ํฐํธ์ ttfํ์ผ๋ค ๋ฃ๊ธฐ
react-native.config.js
module.exports = {
assets: ['src/assets/fonts'],
};
ํฐ๋ฏธ๋์ ์๋ ๋ช ๋ น์ด ์ ๋ ฅ
npx react-native-asset
android ์์๋ android/app/src/main/assets/fonts์ ํฐํธ๋ค์ด ์ ์์ฑ๋์๋์ง ํ์ธํ๊ณ ,
ios ์์๋ Info.plist ํ์ผ์ UIAppFonts๊ฐ ์ ๋๋ก ๋ค์ด๊ฐ๋์ง ํ์ธํ๋ฉด ๋๋ค.
// ํฐํธ ์ ์ฉํ๊ธฐ
<Text style={{fontFamily: 'NanumSquareNeo-dEb'}}>
tata-v
</Text>
tailwind.config.js
module.exports = {
content: ['./App.{js,jsx,ts,tsx}', './src/**/*.{js,jsx,ts,tsx}', './public/**/*.{js,jsx,ts,tsx,html}'],
theme: {
fontFamily: {
PTDBlack: ['Pretendard-Black'],
PTDBold: ['Pretendard-Bold'],
PTDExtraBold: ['Pretendard-ExtraBold'],
PTDExtraLight: ['Pretendard-ExtraLight'],
PTDLight: ['Pretendard-Light'],
PTDMedium: ['Pretendard-Medium'],
PTDRegular: ['Pretendard-Regular'],
PTDSemiBold: ['Pretendard-SemiBold'],
PTDThin: ['Pretendard-Thin'],
UhBeeBold: ['UhBee-Bold'],
UhBee: ['UhBee'],
},
},
...
์ ์ฉํ๋ ๊ณณ
<Text className="font-PTDBlack">Go To SignIn</Text>
src/style/font.style.js
import { StyleSheet } from 'react-native';
export const font = StyleSheet.create({
nanum400: {
fontFamily: 'NanumSquareNeo-aLt',
},
nanum500: {
fontFamily: 'NanumSquareNeo-bRg',
},
nanum700: {
fontFamily: 'NanumSquareNeo-cBd',
},
nanum800: {
fontFamily: 'NanumSquareNeo-dEb',
},
nanum900: {
fontFamily: 'NanumSquareNeo-eHv',
},
});
์ ์ฉํ๋ ๊ณณ
<Text style={font.nanum800} className="mt-[32px] text-gray900 text-xl">
tata-v
</Text>
์ปค์คํ Text ์ปดํฌ๋ํธ
import React from 'react';
import { Text, TextProps } from 'react-native';
interface CustomTextProps extends TextProps {}
const CustomText: React.FC<CustomTextProps> = ({ style, ...rest }) => {
const customStyle = {
fontFamily: 'Pretendard-Regular',
color: '#000000'
};
return <Text style={[customStyle, style]} {...rest} />;
};
src/assets/fonts์ ์ ์ฅ๋ ํฐํธ ํ์ผ์ ์ด๋ฆ์ด PostScript ์ด๋ฆ๊ณผ ์ผ์นํ์ง ์์ผ๋ฉด ํฐํธ๊ฐ ์ ๋๋ก ์ ์ฉ๋์ง ์๋๋ค.
ํฐํธ ํ์ผ ์ด๋ฆ์ PostScript ์ด๋ฆ๊ณผ ๋์ผํ๊ฒ ๋ณ๊ฒฝํด์ผ ํ๋ค.