import { useTheme } from './useTheme' ; import type { ITheme } from '../theme' ; param props returns description export function useResolvedFontFamily ( props ) { const { fontFamily , fontStyle , fontWeight } = props ; let newFontFamily = fontFamily ; let newFontStyle = fontStyle ; let newFontWeight = fontWeight ; const { fontConfig , fontWeights , fonts } = useTheme ( ) ; if ( fontWeight && fontStyle && fontFamily && fontFamily in fonts ) { const fontToken = fonts [ fontFamily ] ; if ( fontConfig && fontConfig [ fontToken ] ) { newFontWeight = undefined ; newFontStyle = undefined ; let fontWeightNumber = fontWeight in fontWeights ? fontWeights [ fontWeight ] : fontWeight ; let fontVariant = fontConfig [ fontToken ] [ fontWeightNumber ] ; if ( typeof fontVariant === 'object' ) { if ( fontVariant [ fontStyle ] ) newFontFamily = fontVariant [ fontStyle ] ; } else { newFontFamily = fontVariant ; } } else { newFontFamily = fonts [ fontFamily ] ; } } return { fontFamily : newFontFamily , fontWeight : newFontWeight , fontStyle : newFontStyle , } ; }