#ifndef FREETYPEMODEL_H
#define FREETYPEMODEL_H

#include <QObject>
#include <QtGui>

#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H

class MainWindow;

class TFreeTypeModel : public QObject
{
    Q_OBJECT

    QString FontFileName;

    MainWindow* mainWindow;

    FT_Library FreeTypeLibrary;

    std::vector<QString> fontParamText;

    QColor backgroundColor;
    QColor fontColor;

    bool fontInited;

    void LoadFontFile();
    void DestroyFontFile();

    void ProcessSymbol(FT_Face& face, unsigned long charcode, int& shiftX, int& shiftY);
    void ProcessAndDrawSymbol(unsigned long charcode, QImage& img, int& shiftX, int& shiftY);

    void ProcessFont();

public:
    explicit TFreeTypeModel(QObject *parent = 0);

    ~TFreeTypeModel();
    
    void SetMainWindow(MainWindow* aMainWindow);

    void ClearFontParamText();

    QColor GetBackgroundColor();
    QColor GetFontColor();

signals:
    void SetFontNameTextSignal(QString text);
    void SetLoadResultTextSignal(QString text);
    void InvalidateSignal();
    //void AddRowToOutputTextSignal(QString text);

public slots:
    void LoadFont();
    void RenderFontSlot();
    void SaveFont();

    void SelectBackgroundColorPressed();
    void SelectFontColorPressed();
};

#endif // FREETYPEMODEL_H
