相关网址 / T! g/ D j1 a. u3 O6 ]' A' p/ Z
http://www.frictionalgames.com/forum/forum-27.html
8 C* h! y" |% g. u- c6 }; \( w9 j' D) P! A7 U
----------------------------------* r" w$ h1 a/ N) V9 V+ g
2010.10.7 更新
+ L- h# }1 c2 N6 I: y! C+ g/ ^研究了一下这个游戏的源代码,在\sources\resources\FontManager.cpp里,我发现这个游戏还可以支持ttf字体文件。! J W" S9 j6 a, i5 ^
方法很简单,只要在fonts目录下放上和.fnt文件同名的.ttf文件,然后把.fnt文件移走即可。' }0 u" `% r) ?# X+ v) o8 j" b6 w/ v6 H
相关代码如下& M* A7 E1 j2 p, I3 L
iFontData* cFontManager::CreateFontData(const tString& asName, int alSize,unsigned short alFirstChar,
/ N# U! U. q2 _1 Z, b( b unsigned short alLastChar)
7 P7 s0 | X3 X5 |, [: u {
) }/ H1 C1 p* t r tString sPath;
; X) _9 |. G6 y- J: g+ | iFontData* pFont;; z2 i9 j8 c- C
tString asNewName = cString::ToLowerCase(asName);& e; n& e8 B5 _. V
BeginLoad(asName);
$ Z$ w# E: b% s4 K) c" K 4 t! y# m5 @2 f$ s! V& Z; B/ o
//asNewName = cString::SetFileExt(asName,"ttf");
3 i+ \6 \% ]* _ pFont = static_cast<iFontData*>(this->FindLoadedResource(asNewName,sPath));+ o* o( {2 Z4 D
if(pFont==NULL && sPath!="")
3 m& D/ S; e: { {
6 n0 i2 C+ ]/ Z6 |5 |# C0 J( } pFont = mpGraphics->GetLowLevel()->CreateFontData(asNewName);( J% L+ F7 P6 L% X
pFont->SetUp(mpGraphics->GetDrawer(),mpLowLevelResources,mpGui);; @( u9 m% m5 q! \7 ~
" B2 v/ Y- I$ h) A
tString sExt = cString::ToLowerCase(cString::GetFileExt(asName));
- u4 h* V2 V9 K# T( D' |$ p //True Type Font8 i' ~( [/ W1 G
if(sExt == "ttf")* V: z) N$ \7 Q* Y1 A
{
) J- Y# _) w8 P+ c* |, M- u7 X if(pFont->CreateFromFontFile(sPath,alSize,alFirstChar,alLastChar)==false){$ p& l' R8 x: L: O
hplDelete(pFont);: @1 o4 C0 ^( N
EndLoad();
; j% D1 K( Z+ Q$ J( N1 Z1 R6 Z return NULL;
4 R) W) U- @; s }- y2 O; P) B. p* V+ `$ [
}
- ^' ~8 E% V- P, z1 {. ~ //Angel code font type: b0 i. s& u. o# b/ N/ m
else if(sExt == "fnt"): h1 S0 R& f! y1 L8 ?1 e* V
{
- v* N9 ^6 O& [' v if(pFont->CreateFromBitmapFile(sPath)==false){- e. X9 S% ~ m# m7 L' v- }
hplDelete(pFont);
! M9 M q! n. @ G/ Z% r EndLoad();
, o+ D M! X0 B/ L5 l- y return NULL;0 X% Z" X( L' R1 Z
}. |$ v; C' p9 X
}+ z2 m0 P$ X p7 R+ G7 [
else
+ c$ L6 U* f0 B: n4 a: Q6 P {: y/ h8 Z! ?4 L9 P) v8 l' h
Error("Font '%s' has an unkown extension!\n",asName.c_str());1 d( S) B% R" I
hplDelete(pFont);2 q7 ~7 O0 a) |8 |5 Y9 P
EndLoad();
* J/ D w. J: M% F3 u% a O return NULL;
. k! L% _% q* V& J6 m L- x0 F }
$ F2 O' {( h! t, Q( F$ E1 h * A. v1 [3 m8 {5 H S O6 {1 a
//mpResources->GetImageManager()->FlushAll();
+ S! ^. b% s/ G) F _5 R' f AddResource(pFont);5 k; L! n9 K9 T) E+ u$ }
}+ k. N ?; w) V* q6 Q9 o, U
if(pFont)pFont->IncUserCount();
0 L0 F, U- q Q2 A+ ? else Error("Couldn't create font '%s'\n",asNewName.c_str());( b3 c$ e% Q6 g9 F# ~2 S5 ^
2 |5 j4 j$ ~& |# E0 E% J$ t2 H
EndLoad();
9 p3 _* B0 h, a0 b4 r% P return pFont;& C/ J1 j( L3 I: C! e7 i. [
} |