[전기차 충전소 찾기 앱/ReactNative] 커스텀 폰트 적용하기

2024. 2. 6. 09:38·FRONTEND/ReactNative
728x90

https://blog.naver.com/drv983/223316019428

 

커스텀 폰트

https://docs.expo.dev/versions/latest/sdk/font/ https://docs.expo.dev/versions/latest/sdk/splash-scr...

blog.naver.com

 

 

 

 

 

https://docs.expo.dev/versions/latest/sdk/splash-screen/

 

SplashScreen

A library that provides access to controlling the visibility behavior of native splash screen.

docs.expo.dev

 

 

 

font와 splashScreen을 설치한다. 

 

splashScreen은 로딩 시 나타나는 페이지

 

 

폰트를 다운받는다.

https://noonnu.cc/font_page/694

 

눈누

프리텐다드 - 길형진 (orioncactus)

noonnu.cc

 

 

다운로드 받은 압축 파일을 푼다.

 

 

 

public -> static 

 

 

assets 폴더 내에 fonts 폴더를 만들어서 다운로드 받은 폰트들을 다 붙여넣기함

 

 

위에서 폰트 3개만 가져와서 사용한다. 

 

 

import { StatusBar } from "expo-status-bar";
import { StyleSheet, Text, View } from "react-native";
import { useFonts } from "expo-font";
import { useCallback } from "react";
import * as SplashScreen from "expo-splash-screen";

SplashScreen.preventAutoHideAsync();

export default function App() {
  const [fontsLoaded] = useFonts({
    "Pretend-Regular": require("./assets/fonts/Pretendard-Regular.otf"),
    "Pretend-Medium": require("./assets/fonts/Pretendard-Medium.otf"),
    "Pretend-Bold": require("./assets/fonts/Pretendard-Bold.otf"),
  });

  const onLayoutRootView = useCallback(async () => {
    if (fontsLoaded || fontError) {
      await SplashScreen.hideAsync();
    }
  }, [fontsLoaded]);

  if (!fontsLoaded) {
    return null;
  }

  return (
    <View style={styles.container} onLayout={onLayoutRootView}>
      <Text style={{ fontSize: 30 }}>프리텐디드 폰트</Text>
      <Text style={{ fontFamily: "Pretend-Regular", fontSize: 30 }}>
        세상에 이런 폰트가!
      </Text>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});

 

'FRONTEND > ReactNative' 카테고리의 다른 글

[전기차 충전소 찾기 앱/ReactNative] 로그인 구글 인증 -clerk 사용  (0) 2024.02.06
[전기차 충전소 찾기 앱/ReactNative] 스플래쉬 스크린  (2) 2024.02.06
[전기차 충전소 찾기 앱]프로젝트 시작  (0) 2024.02.06
[TodoApp] TodoApp만들기  (1) 2024.02.05
[날씨앱] expo 배포용 앱 만들기  (0) 2024.02.01
'FRONTEND/ReactNative' 카테고리의 다른 글
  • [전기차 충전소 찾기 앱/ReactNative] 로그인 구글 인증 -clerk 사용
  • [전기차 충전소 찾기 앱/ReactNative] 스플래쉬 스크린
  • [전기차 충전소 찾기 앱]프로젝트 시작
  • [TodoApp] TodoApp만들기
죠으닝
죠으닝
부지런히 개발하는 으니
    글쓰기 관리
  • 죠으닝
    💻으니의 개발 공부용 블로그💻
    죠으닝
    • GITHUB
  • 전체
    오늘
    어제
    • 모든 글 (453)
      • FRONTEND (213)
        • React (122)
        • Next.js (23)
        • Vue (30)
        • ReactNative (16)
        • 기타 (20)
        • Flutter (2)
      • BACKEND (157)
        • Java (26)
        • Jsp (27)
        • Spring (65)
        • SpringBoot (36)
        • Python (3)
      • DEV (6)
        • Error (3)
        • 배포 (3)
      • STUDY (13)
      • GIT (11)
      • Docker (8)
      • DB (28)
        • Programmers SQL 문제 풀이 (22)
        • ORACLE (0)
        • MySQL (4)
      • AWS (4)
      • 인공지능 (3)
  • 최근 글

  • 인기 글

  • 250x250
  • hELLO· Designed By정상우.v4.10.0
죠으닝
[전기차 충전소 찾기 앱/ReactNative] 커스텀 폰트 적용하기
상단으로
ㄴ

티스토리툴바