| 1234567891011121314151617181920212223242526272829 |
- import { font } from '@kit.ArkUI';
- import { ContextHelper } from './ContextHelper';
- class RegisterFontUtil {
- //单例
- private static instance: RegisterFontUtil;
- private constructor() {
- }
- public static getInstance(): RegisterFontUtil {
- if (!RegisterFontUtil.instance) {
- RegisterFontUtil.instance = new RegisterFontUtil();
- }
- return RegisterFontUtil.instance;
- }
- registerFont(fontOption: font.FontOptions | font.FontOptions[]) {
- if (Array.isArray(fontOption)) {
- fontOption.forEach(item => {
- ContextHelper.UIContext.getFont().registerFont(item)
- })
- } else {
- ContextHelper.UIContext.getFont().registerFont(fontOption)
- }
- }
- }
- export const registerFontUtil = RegisterFontUtil.getInstance()
|