All files / hooks useFonts.ts

33.33% Statements 1/3
100% Branches 0/0
0% Functions 0/1
33.33% Lines 1/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                                              1x                    
import { useFonts } from 'expo-font';
 
/**
 * 自定义 Hook:加载 Google Fonts
 *
 * 使用的字体:
 * - MaoKen: 猫啃字体,适合标题(iOS/Android 兼容)
 *
 * @returns {boolean} fontsLoaded - 字体是否加载完成
 */
export function useCustomFonts() {
  const [fontsLoaded] = useFonts({
    // 使用小写和连字符,Android 兼容
    maoKen: require('@/assets/fonts/MaoKen.ttf'),
  });
 
  return fontsLoaded;
}
 
/**
 * 字体配置常量
 * 方便在整个应用中统一使用
 */
export const FontFamily = {
  title: {
    light: 'Poppins-Light',
    bold: 'Poppins-Bold',
  },
  body: {
    regular: 'Nunito-Regular',
    bold: 'Nunito-Bold',
  },
} as const;