Using Custom Font

.·2023년 6월 16일
0

Setting

Set up TTF or OTF format font file that you want to import your App.

Google Fonts

Import

drag the font files to your Xcode Project that you want to import your custom font.

check Copy items if needed & Add to targets.

or

Project Target -> Project Properties -> Build Phases -> Copy Bundle Resources
and click + to import your custom font in your Xcode Projcet

Info.plist > Information Property List (Dictionary)

  • Fonts provided by application (Array)

import Item and set the value by font file name
⚠️ You must be include file extension name

Calling

Text("Hello, Wolrd!")
	.font(.custom("filename: String", fontsize: CGFloat))

like this,

Text("Hello, Wolrd!")
	.font(.custom("Pretendard-Bold", size: 16))

if custom font are still not available ,
You need to check the defined font name by belowing code...

init(){
    for family in UIFont.familyNames {
         print(family)
         for names in UIFont.fontNames(forFamilyName: family){
         print("== \(names)")
         }
    }
}

Execute the corresponding iteration statement to use the defined font name output.

Ref

0개의 댓글