/*---------------------------------------------------------------------------* Project: Font Library File: fnt.h Copyright (C) 2006 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Log: fnt.h,v $ Revision 1.3 2008/06/25 07:17:00 yoshioka_yasuhiro Added texture tiling functions. Revision 1.2 2008/04/14 04:31:59 yoshioka_yasuhiro Added FNTSetAlternateChar(). Revision 1.1 2006/10/18 02:49:26 nishida_yasunari Initial check in. $NoKeywords: $ *---------------------------------------------------------------------------*/ #ifndef __FNT_H__ #define __FNT_H__ #include #include #ifdef __cplusplus extern "C" { #endif #define FNT_RESOURCE_HEADER_SIZE (16 * 1024) typedef enum { FNT_CONSTRUCT_MORE_DATA, FNT_CONSTRUCT_FINISH, FNT_CONSTRUCT_ERROR, FNT_CONSTRUCT_CONTINUE, // Internal use FNT_MAX_CONSTRUCT_RESULT } FNTConstructResult; typedef enum { FNT_ENCODING_UTF8, // UTF-8 FNT_ENCODING_UTF16, // UTF-16 FNT_ENCODING_SJIS, // ShiftJIS FNT_ENCODING_CP1252, // CP1252 FNT_MAX_ENCODING } FNTEncoding; typedef struct { void* buffer; // Pointer to font buffer void* info; // Pointer to font information (in buffer) u16* adjust; // Glyph index adjust array (in buffer) u32 bufferSize; // Font buffer size u8 encoding; // Encoding for string u8 padding_[1]; u16 alterCharIndex; // Index of alternative character //20B u32 construct[108/4]; // Construct context //128B u8 bufferTop[]; // Font buffer top } FNTHeader; typedef struct { void* image; // Pointer to texture image sheet s8 left; // Left space width u8 glyphWidth; // Glyph width s8 charWidth; // Character width = left + glyphWidth + right space width u8 charHeight; // Character height GXTexFmt texFormat; // Texture image sheet format u16 texWidth; // Texture image sheet width (texels) u16 texHeight; // Texture image sheet height (texels) u16 cellX; // Horizontal position in texture image u16 cellY; // Vertical position in texture image } FNTTexture; typedef struct { u8 width; // Width (for TAB & scale standard) u8 height; // height u8 maxCharWidth; // Max character width u8 ascent; // Ascent u8 descent; // Descent s8 baselinePos; // Base line position s8 leading; // Leading (line feed) u8 cellWidth; // Cell width (max glyph width) u8 cellHeight; // Cell height u16 texWidth; // Texture image sheet width (texels) u16 texHeight; // Texture image sheet height (texels) } FNTMetrics; // Init functions u32 FNTGetDataSize( void* resource ); BOOL FNTConstruct( FNTHeader* font, void* resource ); void FNTInitStreamingConstruct( FNTHeader* font, u32 dataSize ); FNTConstructResult FNTStreamingConstruct( FNTHeader* font, void* stream, u32 streamSize); // Texture functions char* FNTGetTexture( const FNTHeader* font, const char* string, FNTTexture* tex ); GXTexFmt FNTGetTextureFormat( const FNTHeader* font ); // Metrics functions char* FNTGetWidth( const FNTHeader* font, const char* string, s32* width ); void FNTGetMetrics( const FNTHeader* font, FNTMetrics* metrics ); // Encoding functions FNTEncoding FNTGetEncoding( const FNTHeader* font ); FNTEncoding FNTSetEncoding( FNTHeader* font, FNTEncoding encoding ); // Alternate character function BOOL FNTSetAlternateChar( FNTHeader* font, const char* string ); // Texture tiling functions u32 FNTGetTileBufferSize(const FNTHeader* font); void FNTUntileTexture(FNTHeader* font, void* buf); void FNTTileTexture(FNTHeader* font, void* buf); #ifdef __cplusplus } #endif #endif // __FNT_H__