OROCHI
 
Loading...
Searching...
No Matches
GxSysFont.h
Go to the documentation of this file.
1//===========================================================================
9//===========================================================================
10#pragma once
11
12GX_CORE_NAMESPACE_BEGIN()
13
14//===========================================================================
16//===========================================================================
30#if GX_DEVELOP
32GX_ENUM_BEGIN(FONT_LAYOUT)
33 GX_ENUM_VALUE("左上", FONT_LAYOUT::LEFT_TOP),
34 GX_ENUM_VALUE("左中", FONT_LAYOUT::LEFT_MIDDLE),
35 GX_ENUM_VALUE("左下", FONT_LAYOUT::LEFT_BOTTOM),
36 GX_ENUM_VALUE("中上", FONT_LAYOUT::MIDDLE_TOP),
37 GX_ENUM_VALUE("中心", FONT_LAYOUT::MIDDLE_MIDDLE),
38 GX_ENUM_VALUE("中下", FONT_LAYOUT::MIDDLE_BOTTOM),
39 GX_ENUM_VALUE("右上", FONT_LAYOUT::RIGHT_TOP),
40 GX_ENUM_VALUE("右中", FONT_LAYOUT::RIGHT_MIDDLE),
41 GX_ENUM_VALUE("右下", FONT_LAYOUT::RIGHT_BOTTOM),
42GX_ENUM_END()
43#endif //GX_DEVELOP
44
45//===========================================================================
47//===========================================================================
49{
50 //-------------------------------------------------------------
52 //-------------------------------------------------------------
54public:
55 // RTTI宣言
57 // 禁止宣言
59
60
61 static constexpr u32 FONT_NUM_MAX = GxMath::VALUE_16;
62
64 //-------------------------------------------------------------
66 //-------------------------------------------------------------
68
71 : _systemFontType( 0 )
72 {
73 for( u32 i = 0; i < FONT_NUM_MAX; i ++ )
74 {
76 }
77 }
78
80 //-------------------------------------------------------------
82 //-------------------------------------------------------------
84
86 void loadJson( const GxJson::GxJsonNode& jsonNode );
87
89 //-------------------------------------------------------------
91 //-------------------------------------------------------------
93
96
98};
99
100//===========================================================================
102//===========================================================================
103class GxSysFont : public GxSysBase, public SingletonBase<GxSysFont>
104{
105 //-------------------------------------------------------------
107 //-------------------------------------------------------------
109public:
110 // RTTI
111 GX_RTTI_ABSTRACT_CLASS( GxSysFont, GxSysBase )
112 // ClassBase継承クラス用禁止宣言
114
115
117 {
118 //-------------------------------------------------------------
120 //-------------------------------------------------------------
122
124 void terminate(void);
125
127 //-------------------------------------------------------------
129 //-------------------------------------------------------------
131
133 GX_FORCE_INLINE b32 isNeedCalculationPrePosition(void) const { return _layout != FONT_LAYOUT::LEFT_TOP && _lineWidthArray.getCount() <= 0; }
135 void updatePreLineBreak(f32 addOffsetY, GxVector2& prePosition);
137 void updateLineBreak(const GxSize& size, f32 addOffsetY, GxVector2& offsetPosition);
139 void calculationOffsetPosition(const GxSize& size, u32 renderLine, GxVector2& position);
140
142 //-------------------------------------------------------------
144 //-------------------------------------------------------------
146#if defined(_PS4) || defined(_PS5)
147 GxNativeFontSurface _renderSurface;
148#elif defined(_WINDOWS)
149 LOGFONTA _fontParameter;
150#endif // _WINDOWS
151
153 s32 _index;
154 f32 _size;
155#if defined(_XBOX_XS)
156 f32 _sizeScale;
157#endif // _XBOX_XS
162 f32 _x;
163 f32 _y;
164
168
170 };
171
172private:
174 struct GxFontInformation
175 {
176#if defined(_PS4) || defined(_PS5)
177 GxNativeFontHandle _handle;
178#elif defined(_NX64)
179 GxNativeFontEngine* _pFontEngine;
180 void* _pFontEngineWorkBuffer;
181 void* _pMemoryBuffer;
182#elif defined(_XBOX_XS)
183 std::unique_ptr<DirectX::SpriteBatch> _pBatch;
184 std::unique_ptr<DirectX::SpriteFont> _pFont;
185 std::unique_ptr<DirectX::DescriptorHeap> _pHeap;
186#elif defined(_WINDOWS)
187 GxString _filePath;
188 GxString _identificationName;
189 HFONT _handle;
190#endif // _WINDOWS
191 };
192
193private:
195 static const u32 DEFAULT_FONT_SIZE = 16;
196
197#if defined(_XBOX_XS)
199 struct GxRenderFontPacket
200 {
201 GxMatrixAffine _worldMatrix;
202 GxColorHDR _color;
203 GxFontInformation* _pInformation;
204 GxFontRenderInformation* _pRenderInformation;
205 GxStringW _baseText;
206 GxStringW _renderText;
207 GxSize _fontBufferSize;
208 f32 _rotate;
209 };
211 static constexpr u32 FONT_PACKET_MAX = 256;
212#endif //_XBOX_XS
213
215 //-------------------------------------------------------------
217 //-------------------------------------------------------------
219public:
220
222 GxSysFont( void );
224 ~GxSysFont( void ) override {}
225
227 b32 initialize( const GxClassBase* pInitialInformation ) override;
229 void terminate( void ) override;
230
232 //-------------------------------------------------------------
234 //-------------------------------------------------------------
236public:
237
239 void update(void) override;
240
242 void initializeRenderFont( GxFontRenderInformation* pRenderInformation, s32 fontIndex, f32 lineSpace, f32 size, b32 isBorder, f32 borderSize, FONT_LAYOUT layout, const GxSize& bufferSize, s32 renderTexturePitchSize, void* pFontBuffer, GxRenderTexture* pRenderTexture );
244 void copyRenderFont( GxFontRenderInformation* pRenderInformation, b32 isEndText, GX_CSTR baseText, GX_CSTR renderText, const GxSize& fontBufferSize, s32 renderTexturePitchSize, void* pFontBuffer, GxRenderTexture* pRenderTexture );
245
246public:
247#if defined(_XBOX_XS)
249 void renderFont( GxFontRenderInformation* pRenderInformation, GX_CWSTR baseText, GX_CWSTR renderText, const GxSize& fontBufferSize, const GxColorHDR& color, f32 rotate, const GxMatrixAffine& worldMatrix );
250#endif //_XBOX_XS
251
252private:
253#if defined(_XBOX_XS)
255 s32 renderCallback(void* pSource, void* pArgument);
256#endif //_XBOX_XS
257
259 b32 loadModule( void );
261 void unloadModule( void );
262
264 b32 registerMemory( void );
265
267 b32 initializeFont( const GxFontInitialInformation* pInitialInformation );
269 void terminateFont( void );
270
272 void copyFontData( void* pFontBuffer, GxRenderTexture* pRenderTexture );
273
274#if defined(_WINDOWS)
276 static int CALLBACK searchFontCallback( const LOGFONTA* pFont, const TEXTMETRICA* pMetric, DWORD fontType, LPARAM lParam );
277#elif defined(_PS4) || defined(_PS5)
279 static void* alloc( void* pObject, u32 size );
281 static void free( void* pObject, void* pAddress );
283 static void* realloc( void* pObject, void* pAddress, u32 size );
285 static void* calloc( void* pObject, u32 n, u32 size );
287 static void destroyMemoryCallback(GxNativeFontMemory* pMemory, void* pObject, void* pArgument);
288#endif // _PS4 || _PS5
289
291 //-------------------------------------------------------------
293 //-------------------------------------------------------------
295public:
297 constexpr u32 getUserFontCount( void ) const { return _userFontHandleArray.getCount(); }
298
300 //-------------------------------------------------------------
302 //-------------------------------------------------------------
304private:
305 GxArray _userFontHandleArray;
306
307#if defined(_WINDOWS)
308 b32 _isPreSearch;
309 GxArray _addFontNameArray;
310#elif defined(_PS4) || defined(_PS5)
311 GxNativeFontLibrary _fontLibrary;
312 GxNativeFontRenderer _fontRender;
313 GxNativeFontMemory* _pFontMemory;
314 GxNativeFontHandle _systemFontHandle;
315#elif defined(_XBOX_XS)
316 GxRenderFontPacket _renderFontPackets[RENDER_BUFFER_COUNT_MAX][FONT_PACKET_MAX];
317 u32 _renderFontPacketCounts[RENDER_BUFFER_COUNT_MAX];
318 std::unique_ptr<DirectX::GraphicsMemory> _pGraphicsMemory;
319#endif // _XBOX_XS
320
322};
323
324// アクセスインターフェース
325GX_FORCE_INLINE GxSysFont* getGxSysFont(void){ return GxSysFont::getSingletonPointer(); }
326
327GX_CORE_NAMESPACE_END()
#define GX_PROHIBIT_CLASS_BASE(__CLASS__)
GxClassBase継承の禁止宣言
Definition GxBase.h:240
@ RENDER_BUFFER_COUNT_MAX
トリプルバッファリング
Definition GxRender.h:20
FONT_LAYOUT
フォントレイアウト
Definition GxSysFont.h:18
@ RIGHT_TOP
右上
@ RIGHT_BOTTOM
右下
@ MAX
定義数
@ LEFT_BOTTOM
左下
@ LEFT_TOP
左上
@ MIDDLE_MIDDLE
中心
@ MIDDLE_BOTTOM
中下
@ MIDDLE_TOP
中上
@ LEFT_MIDDLE
左中
@ RIGHT_MIDDLE
右中
配列クラス
Definition GxArray.h:18
constexpr u32 getCount(void) const
配列数を取得
Definition GxArray.h:132
オブジェクト基底クラス
Definition GxBase.h:88
初期化クラス
Definition GxSysFont.h:49
u32 _systemFontType
システムフォントタイプ
Definition GxSysFont.h:94
GxString _userFontResourcePathArray[FONT_NUM_MAX]
ユーザフォントリソースパス配列
Definition GxSysFont.h:95
static constexpr u32 FONT_NUM_MAX
フォント最大数
Definition GxSysFont.h:61
void loadJson(const GxJson::GxJsonNode &jsonNode)
JSONから読み込み
Definition GxSysFont.cpp:29
JSON解析用ノード
Definition GxJson.h:108
算術演算クラス
Definition GxMath.h:84
テクスチャクラス
Definition GxRenderTexture.h:19
システム基底クラス
Definition GxSysBase.h:18
フォントシステム基礎クラス
Definition GxSysFont.h:104
void update(void) override
更新
Definition GxSysFont.cpp:159
void initializeRenderFont(GxFontRenderInformation *pRenderInformation, s32 fontIndex, f32 lineSpace, f32 size, b32 isBorder, f32 borderSize, FONT_LAYOUT layout, const GxSize &bufferSize, s32 renderTexturePitchSize, void *pFontBuffer, GxRenderTexture *pRenderTexture)
フォント描画初期化
Definition GxSysFont.cpp:182
constexpr u32 getUserFontCount(void) const
ユーザフォント数を取得
Definition GxSysFont.h:297
~GxSysFont(void) override
デストラクタ
Definition GxSysFont.h:224
void terminate(void) override
終了処理
Definition GxSysFont.cpp:146
GxSysFont(void)
コンストラクタ
Definition GxSysFont.cpp:55
b32 initialize(const GxClassBase *pInitialInformation) override
初期化
Definition GxSysFont.cpp:77
void copyRenderFont(GxFontRenderInformation *pRenderInformation, b32 isEndText, GX_CSTR baseText, GX_CSTR renderText, const GxSize &fontBufferSize, s32 renderTexturePitchSize, void *pFontBuffer, GxRenderTexture *pRenderTexture)
フォント描画コピー
Definition GxSysFont.cpp:316
シングルトン基礎クラス
Definition GxSingleton.h:19
static constexpr GxSysFont * getSingletonPointer(void)
Definition GxSingleton.h:59
色(HDR)
Definition GxColor.h:241
アフィン変換行列(行優先)
Definition GxMatrix.h:330
サイズ
Definition GxStruct.h:730
文字列型クラス
Definition GxString.h:18
ワイド文字列型クラス(UTF-16用)
Definition GxString.h:430
フォント描画情報構造体
Definition GxSysFont.h:117
FONT_LAYOUT _layout
レイアウト
Definition GxSysFont.h:165
GxArray _lineWidthArray
行幅配列
Definition GxSysFont.h:166
b32 _isBorder
縁判定
Definition GxSysFont.h:160
u32 _currentLine
現在の行
Definition GxSysFont.h:167
f32 _size
サイズ
Definition GxSysFont.h:154
f32 _x
X座標
Definition GxSysFont.h:162
b32 _isEnd
終了判定
Definition GxSysFont.h:152
f32 _borderSize
縁サイズ
Definition GxSysFont.h:161
f32 _lineSpace
行間隔
Definition GxSysFont.h:159
f32 _lineHeight
行高さ
Definition GxSysFont.h:158
GX_FORCE_INLINE b32 isNeedCalculationPrePosition(void) const
事前座標計算が必要か調べる
Definition GxSysFont.h:133
f32 _y
Y座標
Definition GxSysFont.h:163
s32 _index
Index.
Definition GxSysFont.h:153
2次元ベクトル
Definition GxVector.h:34
32bitブーリアン
Definition GxDefine.h:173