/*
	ZSolidFontFace.hpp
	Author: Patrick Baggett <ptbaggett@762studios.com>

	Purpose: TODO

	Changelog
	2011/09/18 - creation (ptbaggett)
*/

#pragma once

#ifndef _ZSOLIDFONTFACE_HPP
#define _ZSOLIDFONTFACE_HPP

#include <SST/SST_Vec2.h>

#include <ZRendererUtil/ZFontRenderer.hpp> //Need ZFontBounds structure

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

//Needed for friend class definition
class ZSolidFontRenderer;

// Structure representing glyph information for use in solid font rendering
struct ZSolidGlyphInfo
{
	FT_UInt glyphId;			// Glyph ID, as read from the font
	ZArray<SST_Vec2f> verts;	// Vertex data, every 3 vertices makes a triangle
	int advancex;				// Amount along X axis to advance pen by, in pixels
	int advancey;				// Amount along Y axis to advance pen by, in pixels
	ZFontBounds bbox;			// Bounding box of this glyph, in pixels
};

//Class representing a font face created by a SolidFontRenderer
class ZSolidFontFace
{
friend class ZSolidFontRenderer;
private:
	FT_Face face;
	char* fontData;
	int hasKerning;

	ZHashMap<unsigned int, ZSolidGlyphInfo> glyphCache;

public:

	/*
	Default Constructor.
	*/
	ZSolidFontFace();

	/*
	Destructor.
	*/
	~ZSolidFontFace();

	/*
	public ZSolidFontFace::cacheGlyph
	
	Caches a glyph, given a UTF-32 character code.  The glyph must not already be loaded.
	
	@param charCode - The UTF-32 character code for this glyph
	@return (const ZSolidGlyphInfo&) - Reference to the glyph information.
	@context (all)
	*/
	const ZSolidGlyphInfo& CacheGlyph(unsigned int charCode);

	/*
	public ZSolidFontFace::getGlyph
	
	Gets a glyph from the cache, or loads it if necessary.
	
	@param charCode - 
	@return (const ZSolidGlyphInfo*)
	@context (all)
	*/
	const ZSolidGlyphInfo* GetGlyph(unsigned int charCode);
};

#endif
