/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


#ifndef	__FT2FONT__
#define	__NTEXTFONT__


		#include <ft2build.h>
		#include FT_FREETYPE_H

		#include "font/font_interface.h"
		#include "geometry/rect.h"
		#include "nstring/nstring.h"


namespace GS {

/// Freetype 2 font.
class	Freetype2Font : public IFont
{
		friend class Freetype2FontFactory;

		String		name;
		Array <char> buffer;

		bool		has_kerning;
		FT_Face		face;

public:

		/// Return the font name.
virtual	const char	*GetName() const { return name; }

		/// Return the bounding rect for a given string.
virtual	iRect		GetTextBoundRect(const char *) const;

		/// Set font size in pixels.
virtual	bool		SetPixelSize(int);
		/// Get font height in pixels.
virtual	int			GetHeight() const;
		/// Get font current glyph advance.
virtual	int			GetAdvance() const;

		/// Return true if the font supports kerning.
virtual	bool		HasKerning() const;
		/// Return the kerning for a codepoint pair.
virtual	int			GetKerning(uint previous_codepoint, uint codepoint) const;

		/// Load the glyph corresponding to a UTF-32 codepoint.
virtual	bool		LoadGlyph(uint codepoint, bool for_render);
		/// Render currently loaded glyph to a picture.
virtual	bool		RenderCurrentGlyph(Picture &picture, const iPoint &position, const iRect &clip, const Color &color = Color::White);

		Freetype2Font() : face(0) {}
		~Freetype2Font();
};

} // GS


#endif	// __NTEXTFONT__
