1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     font_PairFont.h
4 
5   Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc.  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   $Revision: 25674 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_FONT_FONT_PAIR_FONT_H_
17 #define NN_FONT_FONT_PAIR_FONT_H_
18 
19 #include <nn/types.h>
20 #include <nn/font/font_Font.h>
21 
22 
23 namespace nn {
24 namespace font {
25 
26 
27 //---------------------------------------------------------------------------
28 //! @brief        内部に2つのフォントを保持し、1つのフォントのように扱います。
29 //---------------------------------------------------------------------------
30 class PairFont
31     : public Font
32 {
33 public:
34     /* ------------------------------------------------------------------------
35             関数
36        ------------------------------------------------------------------------ */
37 
38     //! @name コンストラクタ / デストラクタ
39     //@{
40 
41     //! @brief      コンストラクタです。
42     //!
43     //! @param[in]  primary    フォントへのポインタ。
44     //! @param[in]  secondary  フォントへのポインタ。
45     //!
46                                 PairFont(
47                                     Font*   primary,
48                                     Font*   secondary);
49 
50     //! デストラクタです。
51     virtual                     ~PairFont();
52 
53     //@}
54 
55     //---- フォント全体情報アクセサ
56     virtual int                 GetWidth() const;
57     virtual int                 GetHeight() const;
58     virtual int                 GetAscent() const;
59     virtual int                 GetDescent() const;
60     virtual int                 GetBaselinePos() const;
61     virtual int                 GetCellHeight() const;
62     virtual int                 GetCellWidth() const;
63     virtual int                 GetMaxCharWidth() const;
64     virtual Type                GetType() const;
65     virtual TexFmt              GetTextureFormat() const;
66     virtual int                 GetLineFeed() const;
67     virtual const CharWidths    GetDefaultCharWidths() const;
68 
69     virtual void                SetDefaultCharWidths(
70                                     const CharWidths& widths        // 新しいデフォルト幅
71                                 );
72 
73     virtual bool                SetAlternateChar(
74                                     CharCode c );                   // 新しい代替文字
75 
76     virtual void                SetLineFeed(
77                                     int linefeed );                 // 新しい改行幅
78 
79     //---- 文字単体情報アクセサ
80     virtual int                 GetCharWidth(
81                                     CharCode c                      // 幅を求める文字
82                                 ) const;
83 
84     virtual const CharWidths    GetCharWidths(
85                                     CharCode c                      // 幅を求める文字
86                                 ) const;
87 
88     virtual void                GetGlyph(
89                                     Glyph*      glyph,              // グリフ情報を受け取るバッファ
90                                     CharCode    c                   // グリフ情報を取得する文字
91                                 ) const;
92     virtual bool                HasGlyph(
93                                     CharCode    c                   // グリフ情報の有無を取得する文字
94                                 ) const;
95 
96     //---- 文字ストリーム処理
97     virtual CharacterCode       GetCharacterCode() const;
98 
99 
100 private:
101     /* ------------------------------------------------------------------------
102             変数
103        ------------------------------------------------------------------------ */
104     // フォントの実体へのポインタ
105     Font*                       mPrimary;
106     Font*                       mSecondary;
107     // 代替文字を1つ目のフォントから取得するかどうか
108     bool                        mAlternateWithPrimary;
109     u8                          mPadding[3];
110 };
111 
112 
113 
114 
115 }   // namespace font
116 }   // namespace nn
117 #endif //  NN_FONT_FONT_PAIR_FONT_H_
118