Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

715 B
Raw Blame
import { genFontFamily, genFontFamilyCode } from '@lobehub/ui';

interface FontFamilyOverrideParams {
  customFontFamily?: string;
  locale?: string;
  userFontFamily?: string;
  userFontFamilyCode?: string;
}

const hasFont = (font?: string) => !!font?.trim();

export const resolveFontFamilyOverride = ({
  customFontFamily,
  locale,
  userFontFamily,
  userFontFamilyCode,
}: FontFamilyOverrideParams) => ({
  fontFamily:
    hasFont(userFontFamily) || hasFont(customFontFamily)
      ? genFontFamily({ locale, prepend: [userFontFamily, customFontFamily] })
      : undefined,
  fontFamilyCode: hasFont(userFontFamilyCode)
    ? genFontFamilyCode({ locale, prepend: [userFontFamilyCode] })
    : undefined,
});