🤼♀️/Flutter
[Flutter] Custom Font 추가하기
eungding
2020. 9. 18. 09:55
728x90
반응형
Use a custom font 문서를 봐주시면 됩니다.
플젝에 fonts라는 디렉토리를 만들고
여기에 폰트파일을 넣어주세요
그 다음 pubspec.yaml로 이동해주세요
flutter 밑에 fonts를 추가해줍니다.
fontfamily(앱에서 쓸 폰트이름) 랑 font file의 path를 적어주면 됩니다..!
이렇게 써주면 됩니다,,!
Text("안녕하십니까아아", style: TextStyle(fontFamily: 'GyeonggiMedium', fontSize: 15))
저는 style > font 파일을 만들어주고
이런 클래스를 만들어서 폰트를 관리해주게 했어요
class MyFontFamily {
static const gyeonggiLight = "GyeonggiLight";
static const gyeonggiMedium = "GyeonggiMedium";
static const nanumFlower = "NanumFlower";
static const nanumDiligence = "NanumDiligence";
}
사용하는 쪽에서 이렇게 쓸수있도록..!+!
Text("안녕하십니까아아", style: TextStyle(fontFamily: MyFontFamily.gyeonggiMedium, fontSize: 15))
[ 추가 ]
또한 아래처럼 한 family에 여러 weight의 폰트들을 둘 수도 있는데요!
그 때는 이런식으로 사용해주면 됩니다!
Text("안녕하세요", style: TextStyle(fontFamily: "SpoqaHanSansNeo", fontWeight: FontWeight.bold))
반응형