相关网址 # e/ _! o2 ~2 B' X+ V f
http://www.frictionalgames.com/forum/forum-27.html ! q2 P! Q; C5 V
0 n6 [. B& Q, I----------------------------------4 J8 P8 B5 L; F: L* C' t* m5 }
2010.10.7 更新
/ F& v! U/ O- u: [研究了一下这个游戏的源代码,在\sources\resources\FontManager.cpp里,我发现这个游戏还可以支持ttf字体文件。$ l2 D+ M: K. {
方法很简单,只要在fonts目录下放上和.fnt文件同名的.ttf文件,然后把.fnt文件移走即可。. b3 M$ e5 ?1 d& Y, T
相关代码如下
0 t9 I7 g7 W3 yiFontData* cFontManager::CreateFontData(const tString& asName, int alSize,unsigned short alFirstChar,0 V" R) X9 Q7 e+ \, B" n# w1 S+ O! }
unsigned short alLastChar)
9 j& f% h+ ?; I {
* s6 |5 o' Z" L$ }: e tString sPath;6 N+ ~5 W S2 V
iFontData* pFont;
7 `" M4 ^, e" q/ Q7 C tString asNewName = cString::ToLowerCase(asName);
% h! [" k+ O; i: B BeginLoad(asName);
; g& w$ l& y3 v6 F/ L0 a
! x* q$ u3 D/ d Y$ l //asNewName = cString::SetFileExt(asName,"ttf");
% g( b9 m" R8 t6 [" t' ?: y5 x pFont = static_cast<iFontData*>(this->FindLoadedResource(asNewName,sPath));
! T) V* c4 \" C) ` if(pFont==NULL && sPath!="")$ ]3 V+ K/ o9 i) w0 O1 v
{
2 d, g4 @% a, R: N pFont = mpGraphics->GetLowLevel()->CreateFontData(asNewName);
. @4 k1 p3 {8 C pFont->SetUp(mpGraphics->GetDrawer(),mpLowLevelResources,mpGui);
1 @5 S9 ~4 R+ V) R1 J ] % x# `, A8 _ E! J
tString sExt = cString::ToLowerCase(cString::GetFileExt(asName));3 @# w. J2 g0 {3 Y! U0 r
//True Type Font$ {6 K' W; [; A2 {* e. e7 U) \
if(sExt == "ttf"), H' Y5 j% C0 f8 T) [
{, l Q8 V$ m8 s
if(pFont->CreateFromFontFile(sPath,alSize,alFirstChar,alLastChar)==false){3 U& n+ `) z* F. v; _& J
hplDelete(pFont);: I) y6 \8 ]4 w7 b8 H
EndLoad();
. g: X% J( \2 W; l4 Q8 k8 G' } return NULL;* p$ \' x: J$ C3 w6 b$ z
}2 A0 q3 R8 W: Z& N: }
}- M" ^ ^& U/ i- g/ v. f2 c
//Angel code font type
, k M1 _: w" M$ c( ^$ |, M/ X else if(sExt == "fnt")
" y/ O- T E. q2 r/ _6 \% z5 {. x {
8 x$ J" G% r; w5 `+ p& i- ?. I: c if(pFont->CreateFromBitmapFile(sPath)==false){
( Y+ E) R' i+ N6 M hplDelete(pFont);/ K8 d) o4 ~) ^% U
EndLoad();. m4 T( t$ v: N ?' p
return NULL;
% p+ i$ e0 l# z% I3 p }
- \1 \, _# F2 J' B2 j: t U }9 T% D) z, k% |) l
else1 F1 o3 v1 D! r+ k
{
3 s# G7 I' S& D* q, u5 {1 ^# U Error("Font '%s' has an unkown extension!\n",asName.c_str());
P1 x1 \7 `6 I" d9 l5 U$ V hplDelete(pFont);
6 O$ M5 ~; |* ^+ P- `6 N4 @* Z EndLoad();3 d$ }* u) j% a# v* z
return NULL; p5 G; ^" E' b' M* Y2 A5 \
}* ?% h: A5 g3 u8 c L
0 z# ^$ a0 K) ~8 N
//mpResources->GetImageManager()->FlushAll();
! r7 Z7 R! t, E: |- N. z AddResource(pFont);
) v) y, s. A9 Y3 o% Y S) y8 i* ` }6 s4 L& |; t- n0 f9 Z7 b4 A
if(pFont)pFont->IncUserCount();
: j' y& ~- Y0 T1 V5 T/ t- ^7 m else Error("Couldn't create font '%s'\n",asNewName.c_str());
% ?0 y7 ~7 D7 B7 B
y/ d8 J w$ C8 G% | EndLoad();; v; |$ w. E! S% L
return pFont;
6 m( \: |4 F7 q5 h } |