#ifndef BLUECORE_FONT_MANAGER_H
#define BLUECORE_FONT_MANAGER_H

// system includes
#include <map>
#include <string>

// project includes
#include "Utilities/Referenced.h"

#include "RenderDevice.h"

// forward declaratins
class FTFont;

namespace BlueCore
{
class Font : public Referenced
{
    FTFont *_Font;
    unsigned char *_Buffer;
    ref_ptr<RenderDevice> _Device;

  protected:

    ~Font();

  public:

    Font(FTFont *font, unsigned char *buffer, RenderDevice *device);
    Font();

    void destroy();

    void print(float x, float y, const std::string &text, int halign = 0,
        int valign = 0) const;
};

class FontManager : public Referenced, public sigslot::has_slots<>
{

  private:

    typedef std::map<std::string, weak_ptr<Font> > FontMap;

    FontMap _fonts;
    ref_ptr<Font> _DefaultFont;

    void FontDestroyedSlot(Referenced*);

    void DeviceShutdownSlot();

    void destroy();

  public:

    FontManager(RenderDevice* device);
    ~FontManager();

    Font *loadFont(const std::string &name, int size, bool hinting = true);
    Font *getDefaultFont();

  private:

    ref_ptr<RenderDevice> _Device;
};

} // namespace BlueCore

#endif // BLUECORE_FONT_MANAGER_H
