相关网址
X b3 W8 h; E& B; K% Vhttp://www.frictionalgames.com/forum/forum-27.html
2 K$ ~' X' m8 [" Z. t0 y" ^
. @: p7 R6 H% y$ y+ e----------------------------------
_* S/ L8 {3 ?9 |3 h+ ?8 o, _2010.10.7 更新
) W5 |; D) v1 e5 w4 N0 K4 F* W研究了一下这个游戏的源代码,在\sources\resources\FontManager.cpp里,我发现这个游戏还可以支持ttf字体文件。* f$ w9 Z4 Y; `7 c, s+ |( ~# A3 b
方法很简单,只要在fonts目录下放上和.fnt文件同名的.ttf文件,然后把.fnt文件移走即可。- T$ w. e3 T/ f a0 \3 f
相关代码如下9 N& B; R) }5 r% o) v b- Q
iFontData* cFontManager::CreateFontData(const tString& asName, int alSize,unsigned short alFirstChar,
+ r8 t0 F) s c/ ?; k4 B unsigned short alLastChar)
1 Y" G. W" f" n: o$ H: _ {
- g8 ]: u% \8 i tString sPath;0 J% q+ q, v& l% Y0 h# t
iFontData* pFont;% L$ v4 I' V, D9 l2 B1 \
tString asNewName = cString::ToLowerCase(asName);
- w# Q' j/ q- ~8 h! b [, W BeginLoad(asName);
: I0 r1 Y9 i( w3 L# e! i6 Z % c# O- w+ A- f' T
//asNewName = cString::SetFileExt(asName,"ttf");
. S x* o$ h# n+ T) c pFont = static_cast<iFontData*>(this->FindLoadedResource(asNewName,sPath));# c1 E% \- @+ j7 U/ S
if(pFont==NULL && sPath!="")! q6 Q( y$ ]( w% J5 A8 u) u
{' ^+ U1 H# K' R3 [
pFont = mpGraphics->GetLowLevel()->CreateFontData(asNewName);4 |$ n$ C' O0 u! K
pFont->SetUp(mpGraphics->GetDrawer(),mpLowLevelResources,mpGui);: w2 x% G; a" u' R5 E
: @0 Q# a% l4 l7 Z3 T/ G tString sExt = cString::ToLowerCase(cString::GetFileExt(asName));( q9 U2 z. g4 a: c, v- a# S/ c
//True Type Font
0 w8 F' t( y: G7 [& k3 w8 Q if(sExt == "ttf")# f: Z D/ {5 c4 T8 b& u8 H+ @
{ o! c, Q8 a" {7 c& V
if(pFont->CreateFromFontFile(sPath,alSize,alFirstChar,alLastChar)==false){# b* ]5 @3 B1 W3 r7 e1 F
hplDelete(pFont);* N3 d0 I, w, Z5 ?* i! N
EndLoad();
# E( U. g! q6 {' Y1 X return NULL;+ R( i4 g6 s$ n/ m# h7 O- x
}! w- K* n& A7 s v: V
}; e7 v! K+ ?1 `# T, t, G$ j1 c
//Angel code font type
' {, f3 t1 o; Y$ T" K' A else if(sExt == "fnt")( k7 `0 f3 M( \" M+ S- v4 I
{
$ {( V4 }9 k/ W1 j* `) A% s if(pFont->CreateFromBitmapFile(sPath)==false){3 Q$ M( b8 B% P2 E$ Z; E
hplDelete(pFont);
9 t7 r( [/ l P# d0 m. N, U+ a EndLoad();
" m, w4 M; J+ @; q return NULL;7 L! m. X1 s# B9 o9 k* T" D
}! S6 x' N! T, v; A0 a0 T3 _& P- `
}
) q! \0 t8 z0 \0 f' V9 Z5 z' Y else
: }+ N' J3 Z7 [: J4 q {
1 G* u. j; V8 G Error("Font '%s' has an unkown extension!\n",asName.c_str());4 i. R/ b& H% ^1 Q/ a
hplDelete(pFont);
" E% [6 `! X+ N EndLoad();
3 X5 { P6 ]+ t( O4 z return NULL;
0 @; r8 e- _- _ }
6 A- h4 [8 V& }( d4 f; `
& }2 h. A7 \1 o& C! E% s, R //mpResources->GetImageManager()->FlushAll();; t( T4 P: q) b: ~8 L
AddResource(pFont);
! Q* a& q# D" O }0 h) k7 ?; p0 s0 J; [% }! D
if(pFont)pFont->IncUserCount();
8 G$ Y- _7 | i3 ~1 @/ P else Error("Couldn't create font '%s'\n",asNewName.c_str());. ^" J* t. I i: N
7 K) C% z- t# `4 f5 i' E EndLoad();
( L8 p; N$ U% h6 K1 Q return pFont;
1 M# |1 f9 F- l2 X! c } |