/****************************************************************************************

		IMCFont.h

		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		Author:	Yann
		Date:	10/14/99

		Font and Fonts List COM interfaces

		Revision History

		when		who			what & why
		==========	==========	======================================================
		10/14/99	Yann		Creation

*****************************************************************************************/
#ifndef __IMCFONT__
#define __IMCFONT__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "MCCompObj.h"
#include "MCBasicDefines.h"
#include "MCBasicTypes.h"

class TMCString;

//*********************** Globally Unique Ids ********************************

MCDEFINE_GUID_H(IID_IMCFont);

//****************************************************************************

/// Type of fonts
typedef int16 MCFontType;

enum
{
	kFontNotSpecified	= -1,
	kFontTrueType		= 0,
	kFontATM			= 1,
	kFontBitmap			= 2,
	kFontVector			= 3
};

/// Cross-platform Styles codes
typedef uint16 MCFontStyle;

enum
{
	kMCFontUnknown		= 0xFFFF,
	kMCFontPlain		= 0x0000,
	kMCFontBold			= 0x0001,
	kMCFontItalic		= 0x0002,
	kMCFontUnderline	= 0x0004,
	kMCFontShadow		= 0x0008,
	kMCFontOutline		= 0x0010,
	kMCFontCondense		= 0x0020,
	kMCFontExtent		= 0x0040,
	kMCFontStrikeOut	= 0x0080,
	kMCFontExtraLight	= 0x0100,
	kMCFontLight		= 0x0200,
	kMCFontMedium		= 0x0400,
	kMCFontSemiBold		= 0x0800,
	kMCFontExtraBold	= 0x1000,
	kMCFontHeavy		= 0x2000,
	kMCFontThin			= 0x4000,
	kMCFontWeight		= 0x8000	// Use this constant as a font style if you want to specify the weight by using SetWeight()
};

/// Character codes are 16 bits to allow double-byte support
typedef uint16 MCCharCode;

/// TOutlinePoint is used for outlines extraction in IMCFont
///
class TOutlinePoint
{
public:
	TOutlinePoint(void){};
	TOutlinePoint(real64 inX, real64 inY) : x(inX), y(inY) {};
	real32 x;
	real32 y;
};

/// TMCCharacterMetrics is used for outlines extraction in IMCFont
///
class TMCCharacterMetrics
{
public:
	TMCCharacterMetrics(void) : fAdvance(0,0) {fSidebearing = 0;}
	real32			fSidebearing;
	TOutlinePoint	fAdvance;
};

/// Used by IMCFont::GetFontInfo
///
class MCFontInfo
{
public:
	int32 fAscent;
	int32 fDescent;
	int32 fWidthMax;
	int32 fLeading;
};


/******************************************************************************\
*                                                                              *
*           Callbacks for outlines extraction                                  *
*                                                                              *
\******************************************************************************/

typedef MCErr (*TextBeginPathProc) (const TOutlinePoint& pt, boolean direct, void* param);
typedef MCErr (*TextLineToProc) (const TOutlinePoint& pt, void* param);
typedef MCErr (*TextCurveToProc) (const TOutlinePoint& pt0, const TOutlinePoint& pt1, void* param);
typedef MCErr (*TextBezierProc) (const TOutlinePoint& pt0, const TOutlinePoint& pt1, const TOutlinePoint& pt2, void* param);
typedef MCErr (*TextEndPathProc) (void* param);



/// \addtogroup MCCore
/// \{

/// IMCFont is the interface to access a font.
///
struct IMCFont : public IMCUnknown
{
//Get
	virtual void			MCCOMAPI GetName		(TMCString& outName) const = 0;
	virtual int16			MCCOMAPI GetFontNum		() const = 0;
	virtual int16			MCCOMAPI GetFontType	() const = 0;
	virtual MCFontStyle		MCCOMAPI GetFontStyle	() const = 0;
	virtual real32			MCCOMAPI GetSize		() const = 0;
	virtual uint32			MCCOMAPI GetWeight		() const = 0;
	virtual MCErr			MCCOMAPI GetFontInfo	(MCFontInfo& outInfo) = 0;

//Set
	virtual void			MCCOMAPI SetName		(const TMCString& inName) = 0;
	virtual void			MCCOMAPI SetFontNum		(int16 inFontNum) = 0;
	virtual void			MCCOMAPI SetFontType	(int16 inFontType) = 0;
	virtual void			MCCOMAPI SetFontStyle	(MCFontStyle inFontStyle) = 0;
	virtual void			MCCOMAPI SetSize		(real32 inSize) = 0;
	virtual void			MCCOMAPI SetWeight		(uint32 inWeight) = 0;

//Cloning and copying
	virtual void			MCCOMAPI Clone			(IMCFont** clone) const = 0;
	virtual void			MCCOMAPI CopyData		(IMCFont* destFont) const = 0;
	virtual MCErr			MCCOMAPI BuildOutline	(	
													TextBeginPathProc		beginPathProc,
													TextLineToProc			lineToProc,
													TextCurveToProc			curveToProc,
													TextBezierProc			bezierToProc,
													TextEndPathProc			endPathProc,								
													MCCharCode				inChar,
													TMCCharacterMetrics&	outMetrics,
													void*					privData) = 0;	
};

/// \}

/// \addtogroup MCCore
/// \{

/// IMCFontList access a list of fonts.
///
struct IMCFontList : public IMCUnknown
{
//Get
	virtual uint32			MCCOMAPI GetFontCount	() const = 0;
	virtual void			MCCOMAPI GetFont		(uint32 inIndex, IMCFont** outFont) const = 0;
	virtual void			MCCOMAPI GetDefaultFont	(IMCFont** outFont) const = 0;	// Return default application font
	virtual void			MCCOMAPI GetSystemFont	(IMCFont** outFont) const = 0;	// Return default system font

//Searching for a font
	virtual int32			MCCOMAPI FindFont		(	// Find a font by its name (simple version)
													const TMCString&	inFontName,					//Font Name
													IMCFont**			outFont) = 0;				// Resulting font
	virtual int32			MCCOMAPI FindFont		(	// Find a font by its name (complicated version)
													const TMCString&	inFontName,					//Font Name
													MCFontType			inRequestedFontType,		// Type: kFontNotSpecified for any type font
													MCFontStyle			inRequestedStyle,			// Style: kMCFontPlain etc.
													int32				inRequestedPitchAndFamily,	// Pitch and Family default = 0
													IMCFont**			outFont,					// Resulting font
													int32				inStartSearchFrom = 0) = 0;	// Start searching from this index default is 0
	virtual int32			MCCOMAPI FindFontByNum	(int16 fontNum, IMCFont** outFont) = 0;			// Find a font by its font ID
};

/// \}

#endif
