#ifndef TTF_RENDERER_H
#define TTF_RENDERER_H

#include "textrenderer.h"
#include "video_int.h"
#include "storage.h"
#include <vector>

#include <ft2build.h>
#include FT_FREETYPE_H

#ifdef Revision
#undef Revision
#endif
#define Revision "ttf_renderer.h $Revision: 1.4 $"
#define VERSION "1.0"

	class TTF_Renderer: public Text_Renderer
	{
		std::string _last_error_;
		Storage<std::string, FT_Face* > _fonts_;
		struct line_info
		{
			line_info(int iw, int ih, int iorigin):w(iw), h(ih), origin(iorigin){};
			int w;
			int h;
			int origin;
		};
		void _get_size_(FT_Face *face, uint16_t *text, std::vector<line_info> *linfo, int *w_total, int *h_total, int len);

		public:
			TTF_Renderer():_last_error_(""){};
			
			virtual bool _init();
			virtual bool init_font(std::string alias, std::string name);
			virtual bool render_text_line(std::string video_name, std::string alias, std::string text, VideoColor color, int size, std::string surface_name, std::string group_name="", bool overwrite=false);
			virtual bool render_text_line(std::string video_name, std::string alias, const std::vector<int> &text, VideoColor color, int size, std::string surface_name, std::string group_name="", bool overwrite=false, int *origin=0);
			virtual bool render_text_line_to_sprite ( std::string video_name, std::string alias, const std::vector<int> &text, VideoColor color, int size, std::string surface_name, std::string group_name, bool overwrite );
			
			virtual std::string _get_version(){return VERSION;}
			virtual std::string _get_driver_name(){return "librenderer_ttf";}
			virtual std::string _get_error(){return _last_error_;}
	};
	
	extern "C" Text_Renderer* _get_textrenderer( void);

#endif
