import { makeObservable, observable, action } from 'mobx';

class FontList {
    @observable fonts: string[] = [];

    constructor() {
        this.initializeFonts();
        this.sort();
    }

    private initializeFonts() {
        const systemFonts = this.getSystemFonts();
        systemFonts.forEach((fontFamily) => {
            const familyName = this.getFamilyName(fontFamily);
            this.fonts.push(familyName);
        });
    }

    private getSystemFonts(): string[] {
        // 在浏览器环境中，无法直接获取系统字体，这里简单模拟
        return ['Arial', 'Times New Roman', 'Courier New'];
    }

    private getFamilyName(fontFamily: string): string {
        // 在浏览器环境中，无法使用 WPF 的相关方法，直接返回字体名称
        return fontFamily;
    }

    @action
    private sort() {
        this.fonts.sort();
    }
}

export default FontList;