-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDxFontLinux.cpp
More file actions
297 lines (241 loc) · 8.95 KB
/
DxFontLinux.cpp
File metadata and controls
297 lines (241 loc) · 8.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
//-----------------------------------------------------------------------------
//
// DXライブラリ Linux用フォント関係プログラム
//
// Ver 3.24f
//
//-----------------------------------------------------------------------------
// DXライブラリ作成時用定義
#define DX_MAKE
#include "../DxCompileConfig.h"
#ifndef DX_NON_FONT
// インクルード ---------------------------------------------------------------
#include "DxFontLinux.h"
#include "DxBaseFuncLinux.h"
#include "DxSystemLinux.h"
#include "../DxFont.h"
#include "../DxMemory.h"
#include "../DxBaseFunc.h"
#include "../DxSystem.h"
#include "../DxArchive_.h"
#include "../DxLog.h"
#ifndef DX_NON_NAMESPACE
namespace DxLib
{
#endif // DX_NON_NAMESPACE
// マクロ定義 -----------------------------------------------------------------
// 構造体宣言 -----------------------------------------------------------------
struct DXLIB_LINUX_FONTINFO
{
void*/*CGColorSpaceRef*/ ColorSpace ;
void*/*CGContextRef*/ BitmapContext ;
void*/*CGMutablePathRef*/ RectPath ;
void*/*CTFontRef*/ Font ;
float FontAscent ;
float FontDescent ;
float FontLeading ;
float FontUnderlinePosition ;
float FontUnderlineThickness ;
float FontCapHeight ;
float FontXHeight ;
void * ImageData ;
int ImageWidth ;
int ImagePitch ;
int ImageHeight ;
int ImageSizeX ;
int ImageSizeY ;
int ImageDrawX ;
int ImageDrawY ;
int ImageAddX ;
} ;
// データ定義 -----------------------------------------------------------------
FONTSYSTEM_LINUX FontSystemLinux ;
// 関数宣言 -------------------------------------------------------------------
void * GetDxLinuxFontImage( void *FontData, int *ImageDrawX, int *ImageDrawY, int *ImageSizeX, int *ImageSizeY, int *ImagePitch, int *ImageAddX )
{
DXLIB_LINUX_FONTINFO *Font = ( DXLIB_LINUX_FONTINFO * )FontData ;
if( ImageDrawX ) *ImageDrawX = Font->ImageDrawX ;
if( ImageDrawY ) *ImageDrawY = Font->ImageDrawY ;
if( ImageSizeX ) *ImageSizeX = Font->ImageSizeX ;
if( ImageSizeY ) *ImageSizeY = Font->ImageSizeY ;
if( ImagePitch ) *ImagePitch = Font->ImagePitch ;
if( ImageAddX ) *ImageAddX = Font->ImageAddX ;
return Font->ImageData ;
}
// プログラム -----------------------------------------------------------------
// フォントデータの作成
void * CreateDxLinuxFontData( const char *FontName, int FontSize )
{
return NULL; // TODO
}
// フォントデータの削除
int DeleteDxLinuxFontData( void *FontData )
{
return -1 ; // TODO
}
// フォントデータの基本情報を取得
void GetDxLinuxFontBaseInfo( void *FontData, int *ImageWidth, int *ImageHeight, int *ImagePitch, float *FontAscent, float *FontDescent, float *FontLeading, float *FontUnderlinePosition, float *FontUnderlineThickness, float *FontCapHeight, float *FontXHeight )
{
DXLIB_LINUX_FONTINFO *Font = ( DXLIB_LINUX_FONTINFO * )FontData ;
if( ImageWidth ) *ImageWidth = Font->ImageWidth ;
if( ImageHeight ) *ImageHeight = Font->ImageHeight ;
if( ImagePitch ) *ImagePitch = Font->ImagePitch ;
if( FontAscent ) *FontAscent = Font->FontAscent ;
if( FontDescent ) *FontDescent = Font->FontDescent ;
if( FontLeading ) *FontLeading = Font->FontLeading ;
if( FontUnderlinePosition ) *FontUnderlinePosition = Font->FontUnderlinePosition ;
if( FontUnderlineThickness ) *FontUnderlineThickness = Font->FontUnderlineThickness ;
if( FontCapHeight ) *FontCapHeight = Font->FontCapHeight ;
if( FontXHeight ) *FontXHeight = Font->FontXHeight ;
}
// フォントデータを下に文字画像のセットアップ
int SetupDxLinuxFontImage( void *FontData, const char *Chara )
{
return -1 ; // TODO
}
// InitFontManage の環境依存処理を行う関数
extern int InitFontManage_PF( void )
{
// 特に何もしない
return 0 ;
}
// TermFontManage の環境依存処理を行う関数
extern int TermFontManage_PF( void )
{
// 特に何もしない
return 0 ;
}
// CreateFontToHandle の環境依存処理を行う関数
extern int CreateFontToHandle_PF( CREATEFONTTOHANDLE_GPARAM *GParam, FONTMANAGE *ManageData, int DefaultCharSet )
{
// フォントデータファイルを使用する場合は何もせずに終了
if( ManageData->UseFontDataFile )
{
return 0 ;
}
return -1; // TODO
}
// CreateFontToHandle の環境依存エラー処理を行う関数
extern int CreateFontToHandle_Error_PF( FONTMANAGE * ManageData )
{
// フォントデータの解放
if( ManageData->PF->FontData != NULL )
{
DeleteDxLinuxFontData( ManageData->PF->FontData ) ;
ManageData->PF->FontData = NULL ;
}
// 終了
return 0 ;
}
// TerminateFontHandle の環境依存処理を行う関数
extern int TerminateFontHandle_PF( FONTMANAGE *ManageData )
{
// フォントデータの解放
if( ManageData->PF->FontData != NULL )
{
DeleteDxLinuxFontData( ManageData->PF->FontData ) ;
ManageData->PF->FontData = NULL ;
}
// 終了
return 0 ;
}
// SetupFontCache の環境依存処理を行う関数
extern int SetupFontCache_PF( CREATEFONTTOHANDLE_GPARAM * /* GParam */, FONTMANAGE * /* ManageData */, int /* ASyncThread */ )
{
// 特に何もしない
return 0 ;
}
// FontCacheCharaAddToHandleの環境依存処理を行う関数( 実行箇所区別 0 )
extern int FontCacheCharAddToHandle_Timing0_PF( FONTMANAGE *ManageData )
{
// とくにすること無し
return 0 ;
}
// FontCacheCharaAddToHandleの環境依存処理を行う関数( 実行箇所区別 1 )
extern int FontCacheCharAddToHandle_Timing1_PF( FONTMANAGE *ManageData, FONTCHARDATA *CharData, DWORD CharCode, DWORD IVSCode, int TextureCacheUpdate )
{
char UTF8CharCode[ 32 ] ;
wchar_t WCharCode[ 8 ] ;
int CharNum ;
int Space ;
void *ImageData ;
int ImageDrawX, ImageDrawY, ImageSizeX, ImageSizeY, ImagePitch, ImageAddX ;
// UTF8文字列に変換する
CharNum = PutCharCode( CharCode, LINUX_WCHAR_CHARCODEFORMAT, ( char * )WCharCode, sizeof( WCharCode ) ) / sizeof( wchar_t ) ;
ConvString( ( char * )WCharCode, CharNum, LINUX_WCHAR_CHARCODEFORMAT, UTF8CharCode, sizeof( UTF8CharCode ), DX_CHARCODEFORMAT_UTF8 ) ;
// 文字のセットアップを行う
SetupDxLinuxFontImage( ManageData->PF->FontData, UTF8CharCode ) ;
// スペースかどうかを取得しておく
Space = CharCode == L' ' ? 1 : ( CharCode == FSYS.DoubleByteSpaceCharCode ? 2 : 0 ) ;
// 情報を取得
ImageData = GetDxLinuxFontImage( ManageData->PF->FontData, &ImageDrawX, &ImageDrawY, &ImageSizeX, &ImageSizeY, &ImagePitch, &ImageAddX ) ;
// スペース文字だった場合
if( Space != 0 )
{
FontCacheCharImageBltToHandle(
ManageData,
CharData,
CharCode,
IVSCode,
TRUE,
DX_FONT_SRCIMAGETYPE_8BIT_MAX255,
NULL,
0,
0,
0,
0,
0,
Space * ManageData->BaseInfo.FontSize / 2,
FALSE
) ;
}
else
{
int ImageWidth, ImageHeight, ImagePitch ;
int UnitHeight ;
float FontAscent, FontDescent, FontLeading, FontUnderlinePosition, FontUnderlineThickness, FontCapHeight, FontXHeight ;
GetDxLinuxFontBaseInfo( ManageData->PF->FontData, &ImageWidth, &ImageHeight, &ImagePitch, &FontAscent, &FontDescent, &FontLeading, &FontUnderlinePosition, &FontUnderlineThickness, &FontCapHeight, &FontXHeight ) ;
UnitHeight = ( int )( FontAscent + FontDescent ) ;
UnitHeight = UnitHeight + UnitHeight / 4 ;
if( UnitHeight > ImageHeight - ImageDrawY )
{
UnitHeight = ImageHeight - ImageDrawY ;
}
// イメージを転送
FontCacheCharImageBltToHandle(
ManageData,
CharData,
CharCode,
IVSCode,
FALSE,
DX_FONT_SRCIMAGETYPE_8BIT_MAX255,
( BYTE * )ImageData + ImageDrawX + ImageDrawY * ImagePitch,
ImageSizeX,
UnitHeight,
ImagePitch,
ImageDrawX,
ImageDrawY,
ImageAddX,
TextureCacheUpdate
) ;
}
END :
// 戻り値を返す
return 0 ;
}
// FontCacheCharaAddToHandleの環境依存処理を行う関数( 実行箇所区別 2 )
extern int FontCacheCharAddToHandle_Timing2_PF( FONTMANAGE *ManageData )
{
// 特に何もしない
return 0 ;
}
// EnumFontName の環境依存処理を行う関数
extern int EnumFontName_PF( ENUMFONTDATA *EnumFontData, int IsEx, int CharSet )
{
// 正常終了
return 0 ;
}
#ifndef DX_NON_NAMESPACE
}
#endif // DX_NON_NAMESPACE
#endif // DX_NON_FONT