//================================================================================
// Xe UI toolkit
//
// Fonts internal header
//
// AUTHOR:  Gabor Nagy
// DATE:    2026-Aug-03 01:29:29
//
// Copyright (C) 1996-2026 by Gabor Nagy. All rights reserved.
//===============================================================================
#ifndef _XeFontsI_h
#define _XeFontsI_h

#include <E3D/Face.h>

#ifdef XeFREETYPE
#include <ft2build.h>
#include <freetype/freetype.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#endif

#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
extern "C" {
#endif

typedef struct
{
	char*  Foundry;
	char*  Family;
} _XeFontFoundryAndFamily;

typedef struct
{
	int         PrevGlyphIndex;
	EFloat32_2  Kerning;
} XeKerning;
EListA_t(XeKerning);

// Scaleable Glyph (Splines / Faces)
struct XeGlyph_S
{
// Theoretically, we could have glyphs that have both of these, but as far as I know, only Xe's .efn format supports such fonts
	EListA_s(, E3dSplinePtr, Splines);    // "Wire" fonts
	EListA_s(, E3dFacePtr, Faces);        // Outline fonts

	EListA_s(, XeKerning, Kerning);       // Kerning value for this Glyph when it's after other Glyphs

	EFloat32_2  HBearing, VBearing, Size;
	EFloat32_2  Advance;
	uint32_t    CurvesLoaded : 1;
};


#ifdef XeFREETYPE
extern FT_Library  _Xe_FTLibrary;

extern int     _XeFT_Init(void);
extern void    _XeFT_Exit(void);

extern int  XeFontSize_FTGlyphLoadAndRender(XeFontSize* PFontSize, const int PGlyphIndex, const EBool PAA,  XeGlyphRaster* PGlyphRaster);
#endif

extern XeFontStyleFlags  _XeFont_StyleNameToFlags(const char* PStyleName);
extern EIndex            _XeGlyph_CurvesFromFreeType(XeFont* PFont, const FT_GlyphSlot PFTGlyphSlot, XeGlyph* PGlyph, const float PScale, const EIndex PNumOfLinSteps);
extern void              _XeFont_FTSetPixelSize(XeFont* PFont,  const EIndex PPixelSizeX, const EIndex PPixelSizeY);

#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
} // Close scope of 'extern "C"' declaration
#endif


#endif // _XeFontsI_h
