相关网址
0 C7 W& I. C5 X% |5 Xhttp://www.frictionalgames.com/forum/forum-27.html 1 S( z# h* _% `0 D f
: ?# H. ?1 W9 ~9 w/ e! e, Y) Z8 s5 Q
----------------------------------) O2 K( d( }$ e$ w- R6 \
2010.10.7 更新2 o" @4 p0 ]" G& E6 J5 ~- d
研究了一下这个游戏的源代码,在\sources\resources\FontManager.cpp里,我发现这个游戏还可以支持ttf字体文件。
0 ^/ P1 X4 }; K, O* Z5 {& F方法很简单,只要在fonts目录下放上和.fnt文件同名的.ttf文件,然后把.fnt文件移走即可。
& d. ?' u6 ^& `) Q) R相关代码如下
. y6 B( E1 @3 q0 c p4 tiFontData* cFontManager::CreateFontData(const tString& asName, int alSize,unsigned short alFirstChar,
% K7 r7 `1 L3 G! m unsigned short alLastChar)% F7 i) n+ R" y8 q' P
{3 ^9 i; L# `+ I- o
tString sPath;+ }$ Y" ^0 e: v7 @ ~0 ?1 w
iFontData* pFont;
9 D0 K- `) [9 u; D tString asNewName = cString::ToLowerCase(asName);
8 d. Q4 n0 M3 z- c BeginLoad(asName);
4 c2 P# m: j* x# h
, l+ r; ]4 w- [7 I$ B7 [/ { //asNewName = cString::SetFileExt(asName,"ttf");
3 h h# G. D1 n9 G( @* `/ a6 C pFont = static_cast<iFontData*>(this->FindLoadedResource(asNewName,sPath));
0 w( P5 H9 s+ M4 r& X; r if(pFont==NULL && sPath!="")
5 Q; D+ ~7 E$ o% `7 v {! x- Q5 v1 w3 g* q
pFont = mpGraphics->GetLowLevel()->CreateFontData(asNewName);
$ x# | K4 n i" a2 h pFont->SetUp(mpGraphics->GetDrawer(),mpLowLevelResources,mpGui);1 F& P3 t F7 _ E: u
: c, H4 _) r/ R5 j! Y tString sExt = cString::ToLowerCase(cString::GetFileExt(asName));: n1 M+ P* F; E3 k
//True Type Font9 c" g m/ Q" n! A3 l1 @! n6 k6 ^
if(sExt == "ttf")
, T$ @$ V! E; H. v7 X8 N {' k) I i/ k% t, Q7 k
if(pFont->CreateFromFontFile(sPath,alSize,alFirstChar,alLastChar)==false){. B8 [) @4 S- _$ F% v7 x. V
hplDelete(pFont);8 {2 e3 m* g8 D! [) ?2 A2 i. E
EndLoad();1 M2 f3 l# Z# e( C
return NULL;
4 k. n& G% K7 J' F& u }- C ?; N9 I- Y3 a0 I( J+ V
}
% K. K9 e! n2 y //Angel code font type6 J# f# W, B% ^" _. S
else if(sExt == "fnt")
/ z. j; |3 h: z: U) a {
5 a- H: q% q1 \% ^8 m if(pFont->CreateFromBitmapFile(sPath)==false){
5 L1 b, Z* V) L1 m. L hplDelete(pFont);1 Q% r& M. c0 s
EndLoad();
( U* B* B; s$ @* C } return NULL;
- ?$ U7 M* v' ~! {" \ }
3 Q3 I7 C% l5 u) x; D }( \& n7 J9 {* [# o* h! G: O5 j
else8 ]) u: g& v* ]; x, ~) F
{
6 \& j: b: ]. a5 a Error("Font '%s' has an unkown extension!\n",asName.c_str());" ?, v/ R- l& Y6 G+ @" {5 ~
hplDelete(pFont);
0 s+ @# u+ [' Y M$ P EndLoad();9 s$ F. D0 d d6 i j6 a
return NULL;
+ E P2 g5 {- n* W& y9 A* @9 U; z7 Q4 J }
6 m5 T B: ~- q# l" \. d0 ]; j! q f; @; T, u4 Z. `' P0 D
//mpResources->GetImageManager()->FlushAll();0 l6 [1 f& C8 W% t b% F
AddResource(pFont);
/ k, q& C1 Q$ {# D/ s: R }
& Q) @/ t/ N, p9 I3 J if(pFont)pFont->IncUserCount();
' U7 Q1 f# s* c5 @7 ]) `# l5 h else Error("Couldn't create font '%s'\n",asNewName.c_str());. Z" i0 B) k, _- r% {7 w
. b+ M3 w' a+ O( g* I! H EndLoad();
' e" N2 g9 p& P' r9 c( g% G' l0 l return pFont;& l& V& d: C6 {' D
} |