Jinsujin / SwiftUI

SwiftUI๋ฅผ ๊ณต๋ถ€ํ•ด๋ณด๊ณ  ํ™œ์šฉํ•˜๋Š” ๊ณต๊ฐ„
0 stars 0 forks source link

Text #2

Closed Jinsujin closed 1 year ago

Jinsujin commented 1 year ago

๐Ÿ‘‰ Document Apple ์—์„œ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•œ System font ๋ชฉ๋ก

Text View ๋ฅผ ์‚ฌ์šฉํ•ด ๋ฌธ์ž์—ด์„ ๊พธ๋ฏธ๋Š” ๋‹ค์–‘ํ•œ modifier ๊ฐ€ ์กด์žฌํ•œ๋‹ค.

modifier ๋Š” ์ค‘์ฒฉํ•ด์„œ ์‚ฌ์šฉํ•จ์œผ๋กœ์„œ ๋‹ค์–‘ํ•˜๊ฒŒ ํ‘œ์‹œํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ค€๋‹ค.

Custom Font ์‚ฌ์šฉํ•˜๊ธฐ

  1. ํฐํŠธ ํŒŒ์ผ์„ ํ”„๋กœ์ ํŠธ์— ๋„ฃ๊ธฐ (Add to target ์ฒดํฌ)
  2. info.plist ์— Fonts provided by application ์†์„ฑ์„ ์ถ”๊ฐ€ํ•˜๊ณ , Item ์— ํŒŒ์ผ๋ช…(ํฐํŠธ๋ช….ttf) ์„ ๋ช…์‹œ
    • ํ™•์žฅ์ž๋ฅผ ๋ฐ˜๋“œ์‹œ ๊ธฐ์ž…ํ•ด์•ผ ํ•จ
  3. custom("ํฐํŠธ๋ช…") modifier๋ฅผ ์‚ฌ์šฉํ•ด ํฐํŠธ์‚ฌ์šฉ

    .font(.custom("Avenir Heavy", size: 16))


(์ฐธ๊ณ )ํฐํŠธ๋ฅผ ์ฐพ์ง€ ๋ชปํ• ๋•Œ

ํฐํŠธ์˜ ํŒŒ์ผ๋ช…๊ณผ ์‹ค์ œ ์‹œ์Šคํ…œ์—์„œ ์‚ฌ์šฉ๋˜๋Š” ์ด๋ฆ„์ด ๋‹ฌ๋ผ์„œ ๊ฐ€์ ธ์˜ค์ง€ ๋ชปํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค. ์ด๋Ÿด๋•Œ๋Š” ์•„๋ž˜์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•ด, ์‚ฌ์šฉ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ํฐํŠธ๋ช…๊ณผ ํŒจ๋ฐ€๋ฆฌํฐํŠธ๋ช…์„ ์•Œ์•„๋‚ผ ์ˆ˜ ์žˆ๋‹ค.

            .onAppear {
                for family: String in UIFont.familyNames {
                        print(family)
                        for names : String in UIFont.fontNames(forFamilyName: family){
                            print("=== \(names)")
                        }
                    }
            }
Jinsujin commented 1 year ago

SwiftUI ๋กœ ์ƒ์„ฑํ•œ ํ”„๋กœ์ ํŠธ์—์„œ plist.info ํŒŒ์ผ์€ ๋งŒ๋“ค์–ด์ง€์ง€ ์•Š๋Š”๋‹ค.