相关网址
4 U& E5 |- k5 l$ `# q; V+ ?http://www.frictionalgames.com/forum/forum-27.html
$ e4 h; |' r$ W
( Z6 K3 _& v) A0 D----------------------------------
3 ~& J3 T6 W: S5 C- [* P1 b2010.10.7 更新- y3 J/ p7 h, E& L7 I
研究了一下这个游戏的源代码,在\sources\resources\FontManager.cpp里,我发现这个游戏还可以支持ttf字体文件。' G3 b1 F2 r6 V0 z% i% R, S2 A9 ~; J
方法很简单,只要在fonts目录下放上和.fnt文件同名的.ttf文件,然后把.fnt文件移走即可。% S: b" N/ V A
相关代码如下
" K/ ^' J' }' A0 FiFontData* cFontManager::CreateFontData(const tString& asName, int alSize,unsigned short alFirstChar,
# Y" I; `. T: @ _" L" D" S unsigned short alLastChar)8 O# b6 v9 j4 R! T9 j
{
E7 V- E7 m) o* P' z& Q tString sPath;
# R6 m' U. S6 \8 a iFontData* pFont;# o# L5 y8 ^; u$ ]2 z# N- ]
tString asNewName = cString::ToLowerCase(asName);4 F, L0 ]2 `, g; P' _9 Q
BeginLoad(asName);
P) g- B9 t( X* F
b! v3 M" t, L0 F! b2 w //asNewName = cString::SetFileExt(asName,"ttf");
4 J2 m- _% p2 F5 i& i7 T [5 c pFont = static_cast<iFontData*>(this->FindLoadedResource(asNewName,sPath));
. g6 U( X5 d2 e/ l5 g if(pFont==NULL && sPath!=""). O( F. |. K, z- e- g" T
{
3 b9 e- ?7 ?; g7 V4 b. B/ n+ ? pFont = mpGraphics->GetLowLevel()->CreateFontData(asNewName);
" V& [- E+ I0 n6 f4 M- {( |$ q pFont->SetUp(mpGraphics->GetDrawer(),mpLowLevelResources,mpGui);( F9 w, Q0 K5 t1 I( U
1 I3 H: t" V7 d% h. i3 z- @ tString sExt = cString::ToLowerCase(cString::GetFileExt(asName));( w: a, p6 e+ G
//True Type Font
. ~$ x& M! u& g a if(sExt == "ttf")
8 F8 i" T. R% b8 y! f1 O) J {1 Z# E& a/ g; @5 v6 g$ s' b- [# a2 `
if(pFont->CreateFromFontFile(sPath,alSize,alFirstChar,alLastChar)==false){
; k: B% a" g L/ ] hplDelete(pFont);
) s2 u1 ?/ k' s2 O6 e9 w: ? EndLoad();
@4 S" N1 A, t/ c return NULL;
6 Z6 b* ?4 m0 x5 P G# M, \6 o* f }
7 ]+ e# V$ @4 ] }
% U6 n1 i/ p+ U. Z; N4 s //Angel code font type- q* t) p' ^: `
else if(sExt == "fnt")
& F4 {; v. s4 _( K) y3 t1 l9 B& t {3 d9 j" X! W4 n* K
if(pFont->CreateFromBitmapFile(sPath)==false){
: Z. C' n( [6 g d" c* x T hplDelete(pFont);
/ Q% D) r$ @& i6 J2 i5 {; F EndLoad();
: J; Y; J1 ~ n: {( V. k4 j* I return NULL;
* B, z. e* q3 N/ o& ] }7 X3 v" a5 U8 C1 R2 }
}
2 B) y0 \; n5 X2 B$ O else
/ X+ n/ ]6 \4 o( G) B {/ K( i+ y$ }! u. `9 a
Error("Font '%s' has an unkown extension!\n",asName.c_str());
6 I- C) C6 g8 b8 N* F' {* ]4 h7 M hplDelete(pFont);
& H# H& [6 [) K EndLoad();4 v: S/ l& {3 S: j/ G- \5 n. g
return NULL;
$ {5 g( T. P# d4 P$ o }
; v# _+ W! \+ H4 \9 w
# x, R" s' z8 X8 L' E2 `5 w8 n. o //mpResources->GetImageManager()->FlushAll();
3 a4 ?; c6 D5 ] AddResource(pFont);- i4 |$ I) P D. d: O
}
; o2 ]# m; c( L/ d if(pFont)pFont->IncUserCount();
% o: V5 a9 W8 Q( {3 `& L, S else Error("Couldn't create font '%s'\n",asNewName.c_str());
x1 z; y( p6 U% S
# Z8 e7 R7 e8 s: h7 ]: ?. e# s EndLoad();+ N$ f7 N. U# T p& t
return pFont;
0 `! @) F2 t* |0 i" s } |