# 字体文件使用指南 ## 字体文件位置 请将 **Bayon-Regular.ttf** 字体文件放置在此文件夹中。 ## 添加步骤 ### 1. 获取字体文件 - 从 Google Fonts 下载 Bayon 字体:https://fonts.google.com/specimen/Bayon - 或从设计师提供的字体文件中获取 `Bayon-Regular.ttf` ### 2. 添加到项目 1. 将 `Bayon-Regular.ttf` 文件拖放到此 `Fonts` 文件夹中 2. 在 Xcode 中,确保文件被添加到项目的 Target 中 3. 检查 `Info.plist` 中已经配置了 `UIAppFonts` 数组 ### 3. 验证字体是否正确加载 在 `AppDelegate.swift` 中添加调试代码: ```swift #if DEBUG FontManager.printAllAvailableFonts() // 检查 Bayon 字体是否可用 print("Bayon 字体可用:\(FontManager.isFontAvailable(.bayonRegular))") #endif ``` ## 当前配置状态 ### ✅ 已完成: - [x] Info.plist 配置完成 - [x] FontManager 工具类创建完成 - [x] LoginView 中 E-PARTI 文本已应用 Bayon 字体 - [x] 字体适配与屏幕尺寸兼容 ### ⏳ 待完成: - [ ] 添加 Bayon-Regular.ttf 字体文件到项目中 ## 使用方法 ### 方法1: 使用 FontManager(推荐) ```swift Text("E-PARTI") .font(FontManager.adaptedFont(.bayonRegular, designSize: 56, for: geometry.size.width)) ``` ### 方法2: 使用 View Extension ```swift Text("E-PARTI") .adaptedCustomFont(.bayonRegular, designSize: 56) ``` ### 方法3: 直接指定大小 ```swift Text("E-PARTI") .customFont(.bayonRegular, size: 56) ``` ## 故障排除 如果字体未生效,请检查: 1. 字体文件是否正确添加到项目 Target 中 2. Info.plist 中的字体文件名是否正确 3. 字体文件名与代码中使用的名称是否一致 4. 运行调试代码确认字体是否被系统识别