## 다이어리 프로젝트 with SandBurger
영어 폰트는 Roboto를 사용하여 추가할 필요가 없지만, 한글 폰트는 Spoqa Han Sans Neo를 사용하여 추가하였다.
폰트 다운로드 링크 : Spoqa Han Sans Neo
Spoqa Han Sans Neo
Spoqa unveil the new Spoqa Han Sans Neo, which has evolved in many ways. | 여러모로 개선을 거쳐 진화한 스포카 한 산스 네오를 공개합니다. | これまでいろいろ改善して進化した新しいスポカーハンサンスネオ
spoqa.github.io
res/font
font directory 생성 후, 다운로드 받은 폰트 파일을 넣어줍니다. 이때 파일명은 소문자로 해야합니다.
app_font.xml 안에는 적용할 font들의 정보를 작성합니다.
app_font.xml
<?xml version="1.0" encoding="utf-8"?>
<font-family
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="UnusedAttribute,ResourceCycle">
<font
android:font="@font/spoqa_han_sans_neo_bold"
android:fontStyle="normal"
android:fontWeight="700"
app:font="@font/spoqa_han_sans_neo_bold"
app:fontStyle="normal"
app:fontWeight="700" />
<font
android:font="@font/spoqa_han_sans_neo_medium"
android:fontStyle="normal"
android:fontWeight="500"
app:font="@font/spoqa_han_sans_neo_medium"
app:fontStyle="normal"
app:fontWeight="500"/>
<font
android:font="@font/spoqa_han_sans_neo_regular"
android:fontStyle="normal"
android:fontWeight="400"
app:font="@font/spoqa_han_sans_neo_regular"
app:fontStyle="normal"
app:fontWeight="400"/>
</font-family>
여기서 글꼴의 굵기마다 fontWeight를 다르게 주어야합니다.
ex) bold : fontWeight = 700, medium : fontWeight = 500
fragment_home.xml
<TextView
android:id="@+id/home_writing_content3_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/line_grey"
android:textSize="12sp"
android:fontFamily="@font/spoqa_han_sans_neo_regular"
android:text="글 쓰러 가기"
android:layout_marginEnd="9dp"
app:layout_constraintTop_toTopOf="@id/home_writing_box3_iv"
app:layout_constraintBottom_toBottomOf="@id/home_writing_box3_iv"
app:layout_constraintStart_toEndOf="@id/home_writing_time3_tv"
app:layout_constraintEnd_toEndOf="@id/home_writing_box3_iv"
/>
적용할 부분에 다음과 같이 fontFamily의 값으로 원하는 폰트를 적용합니다.
결과
적용한 font에 따라 위와 같이 폰트가 바뀌는 것을 볼 수 있습니다.
참고
'Kotlin_study' 카테고리의 다른 글
[Kotlin] Custom Calendar Library(kizitonwose) 사용하기 (0) | 2022.07.13 |
---|---|
[Kotlin] 동기와 비동기 살펴보기 (0) | 2022.07.04 |
[Kotlin] Custom Dialog 사용하기 (0) | 2022.06.30 |
[Kotlin] CosmoCalendar library 사용하기 (0) | 2022.06.29 |
[Kotlin] Bottom Navigation Icon Click Event 처리 (0) | 2022.03.02 |