TwlIPL_commit-99/add-ins/TwlSystem/include/nnsys/g2d/g2d_Font.h

805 lines
26 KiB
C
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*---------------------------------------------------------------------------*
Project: NITRO-System - include - nnsys - g2d
File: g2d_Font.h
Copyright 2004-2008 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.
$Revision: 172 $
*---------------------------------------------------------------------------*/
#ifndef G2D_FONT_H_
#define G2D_FONT_H_
#include <nnsys/g2d/g2d_config.h>
#include <nnsys/g2d/g2di_AssertUtil.h>
#include <nnsys/g2d/fmt/g2d_Font_data.h>
#include <nnsys/g2d/g2di_SplitChar.h>
#include <nnsys/g2d/g2di_Char.h>
#ifdef __cplusplus
extern "C" {
#endif
//---------------------------------------------------------------------
//*****************************************************************************
// Font ƒ}ƒNƒ<4E>
//*****************************************************************************
#define NNS_G2D_FONT_ASSERT( pFont ) \
NNS_G2D_ASSERTMSG( \
((pFont) != NULL) \
&& (*(((u32*)((pFont)->pRes)) - 2) == NNS_G2D_BINBLK_SIG_FINFDATA) \
&& ((pFont)->pRes->pGlyph != NULL) \
&& NNS_G2D_IS_VALID_POINTER((pFont)->cbCharSpliter) \
, "invalid NNSG2dFont data" )
#define NNS_G2D_GLYPH_ASSERT( pGlyph ) \
NNS_G2D_ASSERTMSG( \
((pGlyph) != NULL) \
&& ((pGlyph)->image != NULL) \
, "invalid NNSG2dGlyph data") \
#define NNS_G2D_FONT_MAX_GLYPH_INDEX( pFont ) \
((*((u32*)(pFont)->pRes->pGlyph - 1) - sizeof(*((pFont)->pRes->pGlyph))) \
/ (pFont)->pRes->pGlyph->cellSize) \
#define NNS_G2D_GLYPH_INDEX_NOT_FOUND 0xFFFF
//*****************************************************************************
// Font ’è‹`
//*****************************************************************************
// ƒtƒHƒ“ƒg
typedef struct NNSG2dFont
{
NNSG2dFontInformation* pRes; // “WŠJ<C5A0>Ï݃tƒHƒ“ƒgƒŠƒ\<5C>[ƒXÖ̃|ƒCƒ“ƒ^
NNSiG2dSplitCharCallback cbCharSpliter; // •¶Žš—ñƒGƒ“ƒR<C692>[ƒfƒBƒ“ƒO<C692>ˆ<CB86>ƒR<C692>ƒoƒbƒNÖ̃|ƒCƒ“ƒ^
}
NNSG2dFont;
// ƒOƒŠƒt
typedef struct NNSG2dGlyph
{
const NNSG2dCharWidths* pWidths; // •<><E280A2>î•ñÖ̃|ƒCƒ“ƒ^
const u8* image; // ƒOƒŠƒtƒCƒ<43><C692>[ƒWÖ̃|ƒCƒ“ƒ^
}
NNSG2dGlyph;
// •¶Žš—ñ‹éŒ`
typedef struct NNSG2dTextRect
{
int width; // ‹éŒ`•<>
int height; // ‹éŒ`<60>³
}
NNSG2dTextRect;
//*****************************************************************************
// Font <20>\z
//*****************************************************************************
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontInit*
Description: ƒtƒHƒ“ƒgƒŠƒ\<5C>[ƒX©çƒtƒHƒ“ƒgð<E2809A>\zµÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
pNftrFile: ƒtƒHƒ“ƒgƒŠƒ\<5C>[ƒXÖ̃|ƒCƒ“ƒ^<5E>B
Returns: ƒtƒHƒ“ƒgÌ<E2809A>\zÉ<E2809A>¬Œ÷µ½<E2809A>ê<EFBFBD>ÍFALSEˆÈŠOð•Եܷ<E2809A>B
*---------------------------------------------------------------------------*/
void NNS_G2dFontInitAuto(NNSG2dFont* pFont, void* pNftrFile);
void NNS_G2dFontInitUTF8(NNSG2dFont* pFont, void* pNftrFile);
void NNS_G2dFontInitUTF16(NNSG2dFont* pFont, void* pNftrFile);
void NNS_G2dFontInitShiftJIS(NNSG2dFont* pFont, void* pNftrFile);
void NNS_G2dFontInitCP1252(NNSG2dFont* pFont, void* pNftrFile);
//*****************************************************************************
// Font <E28098>ì
//*****************************************************************************
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontFindGlyphIndex
Description: •¶ŽšƒR<C692>[ƒh©çΉž·éƒOƒŠƒt̃Cƒ“ƒfƒbƒNƒXðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
c: ƒOƒŠƒtƒCƒ“ƒfƒbƒNƒXðŽæ“¾·é•¶ŽšƒR<C692>[ƒh<C692>B
Returns: c ÉΉž·éƒOƒŠƒtª<E28098>Ý·é<E2809A>ê<EFBFBD>ͻ̃Cƒ“ƒfƒbƒNƒX<C692>B
<E28098>ݵȢ<E2809A>ê<EFBFBD>Í NNS_G2D_GLYPH_INDEX_NOT_FOUND<4E>B
*---------------------------------------------------------------------------*/
u16 NNS_G2dFontFindGlyphIndex( const NNSG2dFont* pFont, u16 c );
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetCharWidthsFromIndex
Description: ƒOƒŠƒtƒCƒ“ƒfƒbƒNƒX©ç•¶Žš•<C5A1><E280A2>î•ñðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
idx: ƒOƒŠƒtƒCƒ“ƒfƒbƒNƒX<C692>B
Returns: •¶Žš•<C5A1><E280A2>î•ñÖ̃|ƒCƒ“ƒ^<5E>B
*---------------------------------------------------------------------------*/
const NNSG2dCharWidths* NNS_G2dFontGetCharWidthsFromIndex(
const NNSG2dFont* pFont, u16 idx );
//*****************************************************************************
// Font ƒAƒNƒZƒT
//*****************************************************************************
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetType
Description: ƒtƒHƒ“ƒg̃^ƒCƒvðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
Returns: ƒtƒHƒ“ƒg̃^ƒCƒv<C692>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE NNSG2dFontType NNS_G2dFontGetType( const NNSG2dFont* pFont )
{
NNS_G2D_FONT_ASSERT(pFont);
return (NNSG2dFontType)pFont->pRes->fontType;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetLineFeed
Description: ƒtƒHƒ“ƒg̉ü<E280B0>s•<73>ðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
Returns: ƒtƒHƒ“ƒg̉ü<E280B0>s•<73><E280A2>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE s8 NNS_G2dFontGetLineFeed( const NNSG2dFont* pFont )
{
NNS_G2D_FONT_ASSERT(pFont);
return pFont->pRes->linefeed;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetAlternateGlyphIndex
Description: ƒtƒHƒ“ƒgÌãÖ•¶ŽšƒOƒŠƒtƒCƒ“ƒfƒbƒNƒXðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
Returns: ƒtƒHƒ“ƒgÌãÖ•¶ŽšƒOƒŠƒtƒCƒ“ƒfƒbƒNƒX<C692>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE u16 NNS_G2dFontGetAlternateGlyphIndex( const NNSG2dFont* pFont )
{
NNS_G2D_FONT_ASSERT(pFont);
return pFont->pRes->alterCharIndex;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetDefaultCharWidths
Description: ƒfƒtƒHƒƒgÌ•¶Žš•<C5A1><E280A2>î•ñðŽæ“¾µÜ·<E2809A>B
ƒfƒtƒHƒƒgÌ•¶Žš•<C5A1><E280A2>î•ñÍ•¶ŽšªŒÅ—LÌ•¶Žš•<C5A1><E280A2>î•ñðŽ<C3B0>½È¢<E2809A>ê<EFBFBD>É
Žg—p³êÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
Returns: ƒfƒtƒHƒƒgÌ•¶Žš•<C5A1><E280A2>î•ñÖ̃|ƒCƒ“ƒ^<5E>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE NNSG2dCharWidths* NNS_G2dFontGetDefaultCharWidths( const NNSG2dFont* pFont )
{
NNS_G2D_FONT_ASSERT(pFont);
return &pFont->pRes->defaultWidth;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetHeight
Description: ƒtƒHƒ“ƒgÌ<E2809A>³ðŽæ“¾µÜ·<E2809A>B
Ê<E28099>í<EFBFBD>AƒOƒŠƒtƒCƒ<43><C692>[ƒWÌ<E2809A>³ªƒtƒHƒ“ƒgÌ<E2809A>³ÉÈèÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
Returns: ƒtƒHƒ“ƒgÌ<E2809A>³<E2809A>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE u8 NNS_G2dFontGetHeight( const NNSG2dFont* pFont )
{
NNS_G2D_FONT_ASSERT(pFont);
return pFont->pRes->pGlyph->cellHeight;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetCellHeight
Description: ƒOƒŠƒtƒCƒ<43><C692>[ƒWÌ<E2809A>³ðŽæ“¾µÜ·<E2809A>B
ƒOƒŠƒtƒCƒ<43><C692>[ƒWÌ嫳̓tƒHƒ“ƒg“àÌSÄÌ•¶ŽšÅ¤ÊÅ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
Returns: ƒOƒŠƒtƒCƒ<43><C692>[ƒWÌ<E2809A>³<E2809A>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE u8 NNS_G2dFontGetCellHeight( const NNSG2dFont* pFont )
{
NNS_G2D_FONT_ASSERT(pFont);
return pFont->pRes->pGlyph->cellHeight;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetCellWidth
Description: ƒOƒŠƒtƒCƒ<43><C692>[ƒWÌ•<C38C>ðŽæ“¾µÜ·<E2809A>B
ƒOƒŠƒtƒCƒ<43><C692>[ƒWÌ嫳̓tƒHƒ“ƒg“àÌSÄÌ•¶ŽšÅ¤ÊÅ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
Returns: ƒOƒŠƒtƒCƒ<43><C692>[ƒWÌ•<C38C><E280A2>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE u8 NNS_G2dFontGetCellWidth( const NNSG2dFont* pFont )
{
NNS_G2D_FONT_ASSERT(pFont);
return pFont->pRes->pGlyph->cellWidth;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetBaselinePos
Description: ƒOƒŠƒtƒCƒ<43><C692>[ƒWÌ<E2809A>ã[©çݽƒx<C692>[ƒXƒ‰ƒCƒ“̈ÊuðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
Returns: ƒOƒŠƒtƒCƒ<43><C692>[ƒWÌ<E2809A>ã[‚ð 0 Ƶ½ƒx<C692>[ƒXƒ‰ƒCƒ“̈Êu
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE int NNS_G2dFontGetBaselinePos( const NNSG2dFont* pFont )
{
NNS_G2D_FONT_ASSERT( pFont );
return pFont->pRes->pGlyph->baselinePos;
}
/*---------------------------------------------------------------------------*
Name: NNSi_G2dFontGetGlyphDataSize
Description: ƒOƒŠƒtƒCƒ<43><C692>[ƒWÌ1•¶Žš ½è̃oƒCƒgƒTƒCƒYðŽæ“¾µÜ·<E2809A>B
ƒOƒŠƒtƒCƒ<43><C692>[ƒWÌ嫳̓tƒHƒ“ƒg“àÌSÄÌ•¶ŽšÅ¤ÊÅ·<E2809A>B
(CellWidth * CellHeight * bpp + 7) / 8 Æ“™µ­ÈèÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
Returns: ƒOƒŠƒtƒCƒ<43><C692>[ƒWÌ1•¶Žš ½è̃oƒCƒgƒTƒCƒY<C692>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE int NNSi_G2dFontGetGlyphDataSize( const NNSG2dFont* pFont )
{
NNS_G2D_FONT_ASSERT(pFont);
return pFont->pRes->pGlyph->cellSize;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetMaxCharWidth
Description: ƒtƒHƒ“ƒgÌ<E2809A>Åå•¶Žš•<C5A1>ðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
Returns: ƒtƒHƒ“ƒgÌ<E2809A>Åå•¶Žš•<C5A1><E280A2>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE u8 NNS_G2dFontGetMaxCharWidth( const NNSG2dFont* pFont )
{
NNS_G2D_FONT_ASSERT(pFont);
return pFont->pRes->pGlyph->maxCharWidth;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetBpp
Description: ƒOƒŠƒtƒCƒ<43><C692>[ƒWÌ1ƒhƒbƒg ½è̃rƒbƒg<C692>ðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
Returns: ƒOƒŠƒtƒCƒ<43><C692>[ƒWÌ1ƒhƒbƒg ½è̃rƒbƒg<C692><EFBFBD>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE u8 NNS_G2dFontGetBpp( const NNSG2dFont* pFont )
{
NNS_G2D_FONT_ASSERT(pFont);
return pFont->pRes->pGlyph->bpp;
}
/*---------------------------------------------------------------------------*
Name: NNSi_G2dFontGetEncoding
Description: ƒtƒHƒ“ƒgªÎ‰ž·é•¶Žš—ñƒGƒ“ƒR<C692>[ƒfƒBƒ“ƒOðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
Returns: ƒtƒHƒ“ƒgªÎ‰ž·é•¶Žš—ñƒGƒ“ƒR<C692>[ƒfƒBƒ“ƒO<C692>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE NNSG2dFontEncoding NNSi_G2dFontGetEncoding( const NNSG2dFont* pFont )
{
NNS_G2D_FONT_ASSERT(pFont);
return (NNSG2dFontEncoding)pFont->pRes->encoding;
}
/*---------------------------------------------------------------------------*
Name: NNSi_G2dFontGetSpliter
Description: •¶Žš—ñƒGƒ“ƒR<C692>[ƒfƒBƒ“ƒO<C692>ˆ<CB86>ƒR<C692>ƒoƒbƒNŠÖ<C5A0>Ö̃|ƒCƒ“ƒ^‚ð
Žæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
Returns: •¶Žš—ñƒGƒ“ƒR<C692>[ƒfƒBƒ“ƒO<C692>ˆ<CB86>ƒR<C692>ƒoƒbƒNŠÖ<C5A0>Ö̃|ƒCƒ“ƒ^<5E>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE NNSiG2dSplitCharCallback NNSi_G2dFontGetSpliter( const NNSG2dFont* pFont )
{
NNS_G2D_FONT_ASSERT(pFont);
return pFont->cbCharSpliter;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetGlyphImageFromIndex
Description: ƒOƒŠƒtƒCƒ“ƒfƒbƒNƒX©çƒOƒŠƒtƒCƒ<43><C692>[ƒWðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
idx: ƒOƒŠƒtƒCƒ“ƒfƒbƒNƒX<C692>B
Returns: ƒOƒŠƒtƒCƒ<43><C692>[ƒWÖ̃|ƒCƒ“ƒ^<5E>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE const u8* NNS_G2dFontGetGlyphImageFromIndex(
const NNSG2dFont* pFont, u16 idx )
{
NNS_G2D_FONT_ASSERT(pFont);
NNS_G2D_ASSERT( idx < NNS_G2D_FONT_MAX_GLYPH_INDEX(pFont) );
return pFont->pRes->pGlyph->glyphTable + idx * NNSi_G2dFontGetGlyphDataSize(pFont);
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetFlags
Description: ƒOƒŠƒtÌ“Á¥ƒtƒ‰ƒOðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
Returns: ƒOƒŠƒtÌ“Á¥ƒtƒ‰ƒOð•Եܷ<E2809A>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE u8 NNS_G2dFontGetFlags(const NNSG2dFont* pFont)
{
NNS_G2D_FONT_ASSERT(pFont);
return pFont->pRes->pGlyph->flags;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontSetLineFeed
Description: ƒtƒHƒ“ƒg̉ü<E280B0>s•<73>ð<E2809A>ÝèµÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
linefeed: <20>Vµ¢‰ü<E280B0>s•<73>
Returns: ƒtƒHƒ“ƒg̉ü<E280B0>s•<73><E280A2>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE void NNS_G2dFontSetLineFeed( NNSG2dFont* pFont, s8 linefeed )
{
NNS_G2D_FONT_ASSERT(pFont);
pFont->pRes->linefeed = linefeed;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontSetDefaultCharWidths
Description: ƒfƒtƒHƒƒgÌ•¶Žš•<C5A1><E280A2>î•ñð<E2809A>ÝèµÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
gw: <20>Vµ¢ƒfƒtƒHƒƒg•¶Žš•<C5A1><E280A2>î•ñ<E280A2>B
Returns: ȵ<E2809A>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE void NNS_G2dFontSetDefaultCharWidths(
NNSG2dFont* pFont, NNSG2dCharWidths cw)
{
NNS_G2D_FONT_ASSERT(pFont);
pFont->pRes->defaultWidth = cw;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontSetAlternateGlyphIndex
Description: ƒtƒHƒ“ƒgÌãÖ•¶ŽšƒOƒŠƒtƒCƒ“ƒfƒbƒNƒXð<E2809A>ÝèµÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
idx: <20>Vµ¢ãÖ•¶ŽšƒOƒŠƒtƒCƒ“ƒfƒbƒNƒX<C692>B
Returns: ȵ<E2809A>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE void NNS_G2dFontSetAlternateGlyphIndex( NNSG2dFont* pFont, u16 idx )
{
NNS_G2D_FONT_ASSERT(pFont);
NNS_G2D_ASSERT( idx < NNS_G2D_FONT_MAX_GLYPH_INDEX(pFont) );
pFont->pRes->alterCharIndex = idx;
}
//*****************************************************************************
// inline function
//*****************************************************************************
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetGlyphIndex
Description: •¶ŽšƒR<C692>[ƒh©çƒOƒŠƒtƒCƒ“ƒfƒbƒNƒXðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
c: •¶ŽšƒR<C692>[ƒh<C692>B
Returns: ƒOƒŠƒtƒCƒ“ƒfƒbƒNƒX<C692>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE u16 NNS_G2dFontGetGlyphIndex( const NNSG2dFont* pFont, u16 c )
{
const u16 idx = NNS_G2dFontFindGlyphIndex(pFont, c);
return (idx != NNS_G2D_GLYPH_INDEX_NOT_FOUND) ?
idx :
pFont->pRes->alterCharIndex ;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetGlyphFromIndex
Description: ƒOƒŠƒtƒCƒ“ƒfƒbƒNƒX©çƒOƒŠƒtðŽæ“¾µÜ·<E2809A>B
Arguments: pGlyph: ƒOƒŠƒtðŠi”[·éƒoƒbƒtƒ@‚ւ̃|ƒCƒ“ƒ^<5E>B
pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
idx: Žæ“¾·éƒOƒŠƒt̃OƒŠƒtƒCƒ“ƒfƒbƒNƒX<C692>B
Returns: ƒOƒŠƒtÖ̃|ƒCƒ“ƒ^<5E>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE void NNS_G2dFontGetGlyphFromIndex(
NNSG2dGlyph* pGlyph, const NNSG2dFont* pFont, u16 idx )
{
NNS_G2D_FONT_ASSERT( pFont );
NNS_G2D_POINTER_ASSERT( pGlyph );
pGlyph->pWidths = NNS_G2dFontGetCharWidthsFromIndex(pFont, idx);
pGlyph->image = NNS_G2dFontGetGlyphImageFromIndex(pFont, idx);
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetCharWidths
Description: •¶ŽšƒR<C692>[ƒh©ç•¶Žš•<C5A1><E280A2>î•ñðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
c: •¶Žš•<C5A1><E280A2>î•ñðŽæ“¾·é•¶ŽšÌ•¶ŽšƒR<C692>[ƒh
Returns: •¶Žš•<C5A1><E280A2>î•ñ<E280A2>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE const NNSG2dCharWidths* NNS_G2dFontGetCharWidths(
const NNSG2dFont* pFont, u16 c )
{
u16 iGlyph;
NNS_G2D_FONT_ASSERT( pFont );
iGlyph = NNS_G2dFontGetGlyphIndex( pFont, c );
return NNS_G2dFontGetCharWidthsFromIndex( pFont, iGlyph );
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetCharWidth
Description: •¶ŽšƒR<C692>[ƒh©ç•¶Žš•<C5A1>ðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
c: •¶Žš•<C5A1>ðŽæ“¾·é•¶ŽšÌ•¶ŽšƒR<C692>[ƒh
Returns: ƒsƒNƒZƒPˆÊÌ•¶Žš•<C5A1><E280A2>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE int NNS_G2dFontGetCharWidth( const NNSG2dFont* pFont, u16 c )
{
const NNSG2dCharWidths* pWidths;
NNS_G2D_FONT_ASSERT( pFont );
pWidths = NNS_G2dFontGetCharWidths(pFont, c);
return pWidths->charWidth;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetCharWidthFromIndex
Description: ƒOƒŠƒtƒCƒ“ƒfƒbƒNƒX©ç•¶Žš•<C5A1>ðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
idx: •¶Žš•<C5A1>ðŽæ“¾·é•¶ŽšÌƒOƒŠƒtƒCƒ“ƒfƒbƒNƒX
Returns: ƒsƒNƒZƒPˆÊÌ•¶Žš•<C5A1><E280A2>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE int NNS_G2dFontGetCharWidthFromIndex( const NNSG2dFont* pFont, u16 idx )
{
const NNSG2dCharWidths* pWidths;
NNS_G2D_FONT_ASSERT( pFont );
pWidths = NNS_G2dFontGetCharWidthsFromIndex(pFont, idx);
return pWidths->charWidth;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetGlyphImage
Description: •¶ŽšƒR<C692>[ƒh©çƒOƒŠƒtƒCƒ<43><C692>[ƒWðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
Returns: ƒOƒŠƒtƒCƒ<43><C692>[ƒWÖ̃|ƒCƒ“ƒ^<5E>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE const u8* NNS_G2dFontGetGlyphImage( const NNSG2dFont* pFont, u16 c )
{
u16 iGlyph;
NNS_G2D_FONT_ASSERT( pFont );
iGlyph = NNS_G2dFontGetGlyphIndex( pFont, c );
return NNS_G2dFontGetGlyphImageFromIndex( pFont, iGlyph );
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetGlyph
Description: •¶ŽšƒR<C692>[ƒh©çƒOƒŠƒtðŽæ“¾µÜ·<E2809A>B
Arguments: pGlyph: ƒOƒŠƒtðŠi”[·éƒoƒbƒtƒ@‚ւ̃|ƒCƒ“ƒ^<5E>B
pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
ccode: ƒOƒŠƒtðŽæ“¾·é•¶ŽšÌ•¶ŽšƒR<C692>[ƒh
Returns: ƒOƒŠƒtÖ̃|ƒCƒ“ƒ^<5E>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE void NNS_G2dFontGetGlyph(
NNSG2dGlyph* pGlyph, const NNSG2dFont* pFont, u16 ccode )
{
u16 iGlyph;
NNS_G2D_FONT_ASSERT( pFont );
NNS_G2D_POINTER_ASSERT( pGlyph );
iGlyph = NNS_G2dFontGetGlyphIndex(pFont, ccode);
NNS_G2dFontGetGlyphFromIndex(pGlyph, pFont, iGlyph);
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontSetAlternateChar
Description: ãÖ•¶ŽšðŽwèµ½•¶ŽšƒR<C692>[ƒhÌ•¶ŽšÉu«Š·¦Ü·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
c: <20>Vµ¢ãÖ•¶ŽšÌ•¶ŽšƒR<C692>[ƒh<C692>B
Returns: ãÖ•¶ŽšÌu«Š·¦É<E2809A>¬Œ÷·êÎ TRUE<55>B
ƒtƒHƒ“ƒg“àÉ c ÉΉž·é•¶Žšª<E28098>ݵȢ<E2809A>ê<EFBFBD>ÉŽ¸”sµÜ·<E2809A>B
*---------------------------------------------------------------------------*/
NNS_G2D_INLINE BOOL NNS_G2dFontSetAlternateChar( NNSG2dFont* pFont, u16 c )
{
u16 iGlyph;
NNS_G2D_FONT_ASSERT(pFont);
iGlyph = NNS_G2dFontFindGlyphIndex(pFont, c);
if( iGlyph == NNS_G2D_GLYPH_INDEX_NOT_FOUND )
{
return FALSE;
}
pFont->pRes->alterCharIndex = iGlyph;
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: NNS_G2dFontGetCharWidthFromIndex
Description: ãÖ•¶ŽšðŽwèµ½•¶ŽšƒR<C692>[ƒhÌ•¶ŽšÉu«Š·¦Ü·<E2809A>B
Arguments: pFont: ƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
c: <20>Vµ¢ãÖ•¶ŽšÌ•¶ŽšƒR<C692>[ƒh<C692>B
Returns: ãÖ•¶ŽšÌu«Š·¦É<E2809A>¬Œ÷·êÎ TRUE<55>B
ƒtƒHƒ“ƒg“àÉ c ÉΉž·é•¶Žšª<E28098>ݵȢ<E2809A>ê<EFBFBD>ÉŽ¸”sµÜ·<E2809A>B
*---------------------------------------------------------------------------*/
//*****************************************************************************
// inline function
//*****************************************************************************
/*---------------------------------------------------------------------------*
Name: NNSi_G2dFontGetStringWidth
Description: Žwè³ê½<E2809A>ðŒ<C3B0>Å•¶Žš—ñð1<C3B0>s•`‰æµ½<E2809A>ê<EFBFBD>Ì•<C38C>ð<C3B0>ßÜ·<E2809A>B
“¯ŽžÉ<E2809A>sÌ<E2809A>I[ˆÊũ|ƒCƒ“ƒ^ðŽæ“¾µÜ·<E2809A>B
Arguments: pFont: •¶Žš—ñ•<C3B1>ÌŒvŽZÉ—p¢éƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
hSpace: ƒsƒNƒZƒPˆÊÌ•¶ŽšÆ•¶ŽšÌŠÔŠu<C5A0>B
str: •¶Žš—ñ•<C3B1>ð<C3B0>ßé•¶Žš—ñÖ̃|ƒCƒ“ƒ^<5E>B
pPos: <20>s<EFBFBD>I[ˆÊuÖ̃|ƒCƒ“ƒ^ðŽó¯Žæéƒoƒbƒtƒ@‚ւ̃|ƒCƒ“ƒ^<5E>B
NULLŽwè‰Â<E280B0>B
Returns: str ©ç1<C3A7>s•ªÌ•¶Žš—ñð•`‰æµ½<E2809A>ê<EFBFBD>̃sƒNƒZƒPˆÊÅÌ•<C38C><E280A2>B
*---------------------------------------------------------------------------*/
int NNSi_G2dFontGetStringWidth(
const NNSG2dFont* pFont,
int hSpace,
const void* str,
const void** pPos
);
/*---------------------------------------------------------------------------*
Name: NNSi_G2dFontGetTextHeight
Description: Žwè³ê½<E2809A>ðŒ<C3B0>Å•¶Žš—ñð•`‰æµ½<E2809A>ê<EFBFBD>Ì<E2809A>³ð<C3B0>ßÜ·<E2809A>B
Arguments: pFont: •¶Žš—ñ•<C3B1>ÌŒvŽZÉ—p¢éƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
vSpace: ƒsƒNƒZƒPˆÊÌ<E2809A>sÆ<E2809A>sÌŠÔŠu<C5A0>B
txt: •¶Žš—ñ•<C3B1>ð<C3B0>ßé•¶Žš—ñÖ̃|ƒCƒ“ƒ^<5E>B
Returns: •¶Žš—ñ‚ð•`‰æµ½<E2809A>ê<EFBFBD>̃sƒNƒZƒPˆÊÅÌ<E2809A>³<E2809A>B
*---------------------------------------------------------------------------*/
int NNSi_G2dFontGetTextHeight(
const NNSG2dFont* pFont,
int vSpace,
const void* txt
);
/*---------------------------------------------------------------------------*
Name: NNSi_G2dFontGetTextWidth
Description: Žwè³ê½<E2809A>ðŒ<C3B0>Å•¶Žš—ñð•`‰æµ½<E2809A>ê<EFBFBD>Ì•<C38C>ð<C3B0>ßÜ·<E2809A>B
Arguments: pFont: •¶Žš—ñ•<C3B1>ÌŒvŽZÉ—p¢éƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
hSpace: ƒsƒNƒZƒPˆÊÌ•¶ŽšÆ•¶ŽšÌŠÔŠu<C5A0>B
txt: •¶Žš—ñ•<C3B1>ð<C3B0>ßé•¶Žš—ñÖ̃|ƒCƒ“ƒ^<5E>B
Returns: •¶Žš—ñ‚ð•`‰æµ½<E2809A>ê<EFBFBD>̃sƒNƒZƒPˆÊÅÌ•<C38C><E280A2>B
±êÍŠe<C5A0>sÌ•<C38C>̤¿<E2809A>ÅåÌàÌðˆÓ¡µÜ·<E2809A>B
*---------------------------------------------------------------------------*/
int NNSi_G2dFontGetTextWidth(
const NNSG2dFont* pFont,
int hSpace,
const void* txt
);
/*---------------------------------------------------------------------------*
Name: NNSi_G2dFontGetTextRect
Description: Žwè³ê½<E2809A>ðŒ<C3B0>Å•¶Žš—ñð•`‰æµ½<E2809A>ê<EFBFBD>Ì•<C38C>Æ<E2809A>³ð<C3B0>ßÜ·<E2809A>B
Arguments: pFont: •¶Žš—ñ•<C3B1>ÌŒvŽZÉ—p¢éƒtƒHƒ“ƒgÖ̃|ƒCƒ“ƒ^<5E>B
hSpace: ƒsƒNƒZƒPˆÊÌ•¶ŽšÆ•¶ŽšÌŠÔŠu<C5A0>B
vSpace: ƒsƒNƒZƒPˆÊÌ<E2809A>sÆ<E2809A>sÌŠÔŠu<C5A0>B
txt: •¶Žš—ñ•<C3B1>ð<C3B0>ßé•¶Žš—ñÖ̃|ƒCƒ“ƒ^<5E>B
Returns: •¶Žš—ñ‚ð•`‰æµ½<E2809A>ê<EFBFBD>̃sƒNƒZƒPˆÊÅÌ•<C38C>Æ<E2809A>³ðŠi”[‚µ‚½
<20>\¢Ì<E28098>B
*---------------------------------------------------------------------------*/
NNSG2dTextRect NNSi_G2dFontGetTextRect(
const NNSG2dFont* pFont,
int hSpace,
int vSpace,
const void* txt
);
//---------------------------------------------------------------------
NNS_G2D_INLINE int NNS_G2dFontGetStringWidth( const NNSG2dFont* pFont, int hSpace, const NNSG2dChar* str, const NNSG2dChar** pPos )
{ return NNSi_G2dFontGetStringWidth(pFont, hSpace, str, (const void**)pPos); }
NNS_G2D_INLINE int NNS_G2dFontGetTextHeight( const NNSG2dFont* pFont, int vSpace, const NNSG2dChar* txt )
{ return NNSi_G2dFontGetTextHeight(pFont, vSpace, txt); }
NNS_G2D_INLINE int NNS_G2dFontGetTextWidth( const NNSG2dFont* pFont, int hSpace, const NNSG2dChar* txt )
{ return NNSi_G2dFontGetTextWidth(pFont, hSpace, txt); }
NNS_G2D_INLINE NNSG2dTextRect NNS_G2dFontGetTextRect( const NNSG2dFont* pFont, int hSpace, int vSpace, const NNSG2dChar* txt )
{ return NNSi_G2dFontGetTextRect(pFont, hSpace, vSpace, txt); }
//---------------------------------------------------------------------
//---------------------------------------------------------------------
#ifdef __cplusplus
}/* extern "C" */
#endif
#endif // G2D_FONT_H_