1 /*---------------------------------------------------------------------------* 2 Project: Dolphin OS ROM font API 3 File: OSFont.h 4 5 Copyright 2001, 2002, 2004 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Log: OSFont.h,v $ 14 Revision 1.3 2007/04/25 09:06:03 hiratsu 15 Removed OSSetFontEncode(). 16 17 Revision 1.2 2006/02/04 11:56:47 hashida 18 (none) 19 20 Revision 1.1.1.1 2005/12/29 06:53:28 hiratsu 21 Initial import. 22 23 Revision 1.1.1.1 2005/05/12 02:41:07 yasuh-to 24 Ported from dolphin source tree. 25 26 27 5 2004/03/11 14:52 Shiki 28 Added OSANSItoUTF32() and OSSJIStoUTF32(). 29 30 4 2004/03/10 17:51 Shiki 31 Added support for UTF code. 32 33 3 2002/08/05 18:04 Shiki 34 Added const keywords to relevant function prototypes. 35 36 2 2001/04/25 14:25 Shiki 37 Modified OSGetFontWidth() interface. 38 39 1 2001/04/19 13:27 Shiki 40 Initial check-in. 41 $NoKeywords: $ 42 *---------------------------------------------------------------------------*/ 43 44 #ifndef __OSFONT_H__ 45 #define __OSFONT_H__ 46 47 #include <revolution/types.h> 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif 52 53 typedef struct OSFontHeader 54 { 55 u16 fontType; // Font type 56 u16 firstChar; // The first character code defined in the font 57 u16 lastChar; // The last character code defined in the font 58 u16 invalChar; // The font code to be substituted for invalid characters 59 u16 ascent; // The ascent (units above the base line) of characters 60 u16 descent; // The descent (units below the base line) of characters 61 u16 width; // The width of the widest character 62 u16 leading; // The leading (space) between rows 63 64 u16 cellWidth; // The cell (a single character) width in a sheet 65 u16 cellHeight; // The cell (a single character) height in a sheet 66 u32 sheetSize; // The size of a sheet in bytes 67 u16 sheetFormat; // The texture format of a sheet (GX_TF_*) 68 u16 sheetColumn; // The number of characters in a raw 69 u16 sheetRow; // The number of lines in a sheet 70 u16 sheetWidth; // The sheet width (texture width) 71 //32B 72 73 u16 sheetHeight; // The sheet height (texture height) 74 u16 widthTable; // Offset to character width table (const) 75 76 u32 sheetImage; // Offset to sheet image 77 u32 sheetFullSize; // The size of all sheets 78 79 u8 c0; // Font color table 80 u8 c1; 81 u8 c2; 82 u8 c3; 83 // 48B 84 } OSFontHeader; 85 86 // 87 // Common functions 88 // 89 90 // For OSGetFontEncode() 91 #define OS_FONT_ENCODE_ANSI 0u 92 #define OS_FONT_ENCODE_SJIS 1u 93 #define OS_FONT_ENCODE_UTF8 3u // UTF-8 [RFC 3629] 94 #define OS_FONT_ENCODE_UTF16 4u // UTF-16BE [RFC 2781] 95 #define OS_FONT_ENCODE_UTF32 5u // UTF-32 96 #define OS_FONT_ENCODE_MAX 5u 97 #define OS_FONT_ENCODE_VOID 0xffffu 98 99 #define OS_FONT_PROPORTIONAL FALSE 100 #define OS_FONT_FIXED TRUE 101 102 u16 OSGetFontEncode ( void ); 103 104 char* OSGetFontWidth ( const char* string, s32* width ); 105 106 // 107 // High level functions 108 // 109 110 // For OSInitFont(fontData) 111 #define OS_FONT_SIZE_ANSI ( 288 + 131072) // 1 sheet 112 #define OS_FONT_SIZE_SJIS (3840 + 1179648) // 9 sheets 113 #define OS_FONT_SIZE_UTF (OS_FONT_SIZE_ANSI + OS_FONT_SIZE_SJIS) 114 115 BOOL OSInitFont ( OSFontHeader* fontData ); 116 char* OSGetFontTexture( const char* string, void** image, s32 *x, s32 *y, s32* width ); 117 118 // 119 // Low level functions 120 // 121 122 // For OSLoadFont(*, temp) 123 #define OS_FONT_ROM_SIZE_ANSI 12288 // 0x03000 124 #define OS_FONT_ROM_SIZE_SJIS 315392 // 0x4D000 125 #define OS_FONT_ROM_SIZE_UTF OS_FONT_ROM_SIZE_SJIS 126 127 // For OSLoadFont(fontData, *) 128 #define OS_FONT_DATA_SIZE_ANSI 65824 129 #define OS_FONT_DATA_SIZE_SJIS 593636 130 #define OS_FONT_DATA_SIZE_UTF (OS_FONT_DATA_SIZE_ANSI + OS_FONT_DATA_SIZE_SJIS) 131 132 u32 OSLoadFont ( OSFontHeader* fontData, void* temp ); 133 char* OSGetFontTexel ( const char* string, void* image, s32 pos, s32 stride, s32* width ); 134 135 // 136 // UTF functions 137 // 138 char* OSUTF32to8 ( u32 utf32, char* utf8 ); 139 char* OSUTF8to32 ( const char* utf8, u32* utf32 ); 140 141 u16* OSUTF32to16 ( u32 utf32, u16* utf16 ); 142 u16* OSUTF16to32 ( const u16* utf16, u32* utf32 ); 143 144 u8 OSUTF32toANSI( u32 utf32 ); 145 u32 OSANSItoUTF32( u8 ansi ); 146 147 u16 OSUTF32toSJIS( u32 utf32 ); 148 u32 OSSJIStoUTF32( u16 sjis ); 149 150 BOOL OSSetFontWidth( BOOL fixed ); 151 152 #ifdef __cplusplus 153 } 154 #endif 155 156 #endif // __OSFONT_H__ 157