相关网址 6 J Z! D) Z3 ?
http://www.frictionalgames.com/forum/forum-27.html
" [7 \! U5 g0 m G, c. M" R+ L: K2 s, N) H
----------------------------------! m. T& T0 ]: d/ z* r: `+ [7 h
2010.10.7 更新! w) Q- l v/ ?6 U
研究了一下这个游戏的源代码,在\sources\resources\FontManager.cpp里,我发现这个游戏还可以支持ttf字体文件。0 L4 \! h8 Z Y9 ~5 t$ K
方法很简单,只要在fonts目录下放上和.fnt文件同名的.ttf文件,然后把.fnt文件移走即可。
/ L, a! x8 I& j2 Q$ n, {相关代码如下3 A5 L# U4 Y6 [1 G, Y
iFontData* cFontManager::CreateFontData(const tString& asName, int alSize,unsigned short alFirstChar,
# a5 P9 w6 c; T7 i. }. V9 `1 c unsigned short alLastChar)
% _8 w/ u$ E ?( v; R3 Y& } {! J4 b! Y3 ^. I" k9 l
tString sPath;
& ~0 y$ i! ?- W; [6 S iFontData* pFont; f* T6 k8 Q9 X. O1 w; Y
tString asNewName = cString::ToLowerCase(asName);
0 j) E, s A2 Z+ ] | _ BeginLoad(asName);1 Z7 y0 |# A. f$ |
3 F) f! E, f* }) `. ` Y0 N4 m" y
//asNewName = cString::SetFileExt(asName,"ttf");5 [1 f$ \' q. {( S) ] V
pFont = static_cast<iFontData*>(this->FindLoadedResource(asNewName,sPath));
8 `& n: E) p( w- L* |# { if(pFont==NULL && sPath!="")
. D, c# E2 W- H# @! N0 o {
) n% V; G( X4 G4 q3 l- j pFont = mpGraphics->GetLowLevel()->CreateFontData(asNewName); H. b( x6 `8 g# s/ Q
pFont->SetUp(mpGraphics->GetDrawer(),mpLowLevelResources,mpGui);9 ^( Z* ~9 T% t/ H
" M1 X: G }# A# | tString sExt = cString::ToLowerCase(cString::GetFileExt(asName));
# [, _8 W) [5 U- S8 n //True Type Font8 y) p4 m: L; ^' S3 }" N
if(sExt == "ttf")
. x& G. k$ t2 l' k# K6 H {3 N. a ]/ m/ Q: q0 m2 M; D
if(pFont->CreateFromFontFile(sPath,alSize,alFirstChar,alLastChar)==false){' E+ u, [' m# m* G- i
hplDelete(pFont);/ w2 P: [# W; A5 s* @& i+ o, S A
EndLoad();1 G9 }# L- F2 c; K) @! A1 ^* ^2 y
return NULL;4 ~7 c6 o% N* m* x7 j3 R
}
) B& w! l2 R: Y# z6 Z/ w/ v, E }8 L3 K7 x1 G& x# X6 e9 }
//Angel code font type7 F- g e3 s B* R1 p( b. @$ R
else if(sExt == "fnt"): c/ a$ p. W0 B8 O. i' z. i
{- _/ L6 I/ d6 u+ _6 I; s
if(pFont->CreateFromBitmapFile(sPath)==false){5 Y: d( R1 `* M0 j0 O6 `1 `
hplDelete(pFont);* c' `5 k$ _6 F- d' I( S* H1 a
EndLoad();, d+ d* O8 E+ @3 j0 @. `, R
return NULL;
6 u# P0 V" {9 c }
, j' b; @- v% z' G. v2 g/ x8 J }) g/ I! o; J# _) |$ D
else
w# B/ i% ]9 W4 p' v1 v {. r7 `7 s: ?) a6 Z( W
Error("Font '%s' has an unkown extension!\n",asName.c_str());
7 ^3 ^7 @: ?3 I3 X2 C$ I0 z/ ]$ c hplDelete(pFont);- r2 T* b0 Z0 q' W7 f$ S' \5 K. a
EndLoad();
) G, n9 |# e8 H0 T2 ]! k4 E return NULL;
2 K6 F/ S2 ]$ ^* X& J }
6 N0 C" C0 A3 m# O 7 ^* ?9 ^# p( b8 N+ a4 Y
//mpResources->GetImageManager()->FlushAll();
& w% D, i" s: |% R AddResource(pFont);/ J5 e M& i% {
}$ e& A8 X6 m) q+ k
if(pFont)pFont->IncUserCount();
7 y5 g- k* t8 y4 ? else Error("Couldn't create font '%s'\n",asNewName.c_str());! y- p4 K: \3 s$ v+ m' l# t
, l: L3 c3 p4 G" C
EndLoad();
( e% M! e- s: t6 C1 w# d5 O# @ return pFont;/ o6 G5 L% R |/ [5 W, i, e' ~6 z
} |