相关网址 & l* ?4 `6 S9 n, e. I$ @" i
http://www.frictionalgames.com/forum/forum-27.html
: E2 I' T; h' Q3 u3 \! G9 S t& n5 [* a U- I5 k" g
----------------------------------$ ^% r+ o% T1 @' p; `' a0 f
2010.10.7 更新
9 ]) t& x7 G9 }# a- D( E研究了一下这个游戏的源代码,在\sources\resources\FontManager.cpp里,我发现这个游戏还可以支持ttf字体文件。
0 d2 Y3 f, s# Z; S$ }' x' [3 U( i方法很简单,只要在fonts目录下放上和.fnt文件同名的.ttf文件,然后把.fnt文件移走即可。+ b6 P! Z9 j( P. W- ^8 o
相关代码如下1 j1 Y- W2 A9 a1 B9 M, Y
iFontData* cFontManager::CreateFontData(const tString& asName, int alSize,unsigned short alFirstChar,8 |9 j/ J6 b$ y
unsigned short alLastChar)- {$ N5 N2 r4 q1 s
{
" f% ~5 S( v/ P. P tString sPath;
* b- r% \+ ^! f iFontData* pFont;
1 @& _' W! N9 c; g7 ~9 Z' k" O0 D tString asNewName = cString::ToLowerCase(asName);# c9 w/ X6 o. C7 T- c- V
BeginLoad(asName);, K8 L& H' Q6 x& M" [' j/ Q
1 s+ s a' m7 y E2 v2 D" @' t7 g //asNewName = cString::SetFileExt(asName,"ttf");
% K8 [8 _, v; a: v+ m! c pFont = static_cast<iFontData*>(this->FindLoadedResource(asNewName,sPath));; ^0 d8 ~5 A6 |9 T) C+ _
if(pFont==NULL && sPath!="")
6 p7 G5 Z# f; F! _8 j Q {+ B7 J* U9 B/ i- @5 K
pFont = mpGraphics->GetLowLevel()->CreateFontData(asNewName);5 z3 J8 u; X% t( e6 ^
pFont->SetUp(mpGraphics->GetDrawer(),mpLowLevelResources,mpGui);: z+ B; M* k& z
3 ~4 ^; F/ H! M, ?
tString sExt = cString::ToLowerCase(cString::GetFileExt(asName));
$ Z$ j9 w9 p/ _6 ?' d //True Type Font
) [7 E5 c9 B+ H. J y if(sExt == "ttf")( i' H; ^5 \/ I
{
& _1 o) C+ |5 w6 C if(pFont->CreateFromFontFile(sPath,alSize,alFirstChar,alLastChar)==false){2 n5 F. g+ @ P9 I# v
hplDelete(pFont);0 {% t! G' E, K' V
EndLoad();1 k. k$ v! f$ ]7 d( t
return NULL;
# y" ?* M0 P9 o/ ]6 |( b' B' B( ]. G }3 U0 v8 O2 W6 }2 Z, b
}. d6 j+ u* l& Q$ [$ a/ n
//Angel code font type+ G1 o% m$ \7 G2 j0 m
else if(sExt == "fnt")1 U4 T/ Z& T: g& c; c4 t; C) {
{
, }: M+ N3 b8 t# v" k/ I if(pFont->CreateFromBitmapFile(sPath)==false){& Q6 o" P8 a, y4 F. W* f% P
hplDelete(pFont);
/ S" \/ g" _! w5 J0 v EndLoad();! N* p2 b& W2 x' k6 I
return NULL;9 q2 }& @8 A2 [
}; m; n( Z* s. s2 { R" @
}
+ r/ k* f) L. w else
' @8 a% Q) J2 }' Q {8 R: w/ }; Z& [+ y5 Z
Error("Font '%s' has an unkown extension!\n",asName.c_str());6 Q+ _' b6 g+ q
hplDelete(pFont);
0 h! v( `% K# m( M7 f# M EndLoad();" C) k# I2 [' \* T* @+ |+ J3 K
return NULL;# \1 }# _, E3 e/ d! ]
}5 X' t& z2 D" f7 D) R
! D, @! O$ a6 k/ l; p" b //mpResources->GetImageManager()->FlushAll();1 n3 h0 G" K0 M/ e
AddResource(pFont);7 m0 O- m0 d7 L: |1 b: s! e* u# q
}+ V* P4 z% @& w" k0 T8 w
if(pFont)pFont->IncUserCount();) [' X5 I0 L0 D5 F0 x! H- U
else Error("Couldn't create font '%s'\n",asNewName.c_str());& ^. T7 Q% z2 t
1 G+ O0 @9 ]" w! b( E1 S3 P- Z EndLoad();
0 ?* T7 @6 K, R% C A return pFont;5 Q( D, g7 x4 A, g& G4 C
} |