相关网址 & s; u% D# Z1 W" J: B$ F
http://www.frictionalgames.com/forum/forum-27.html
* L* q* b, q- L# C1 }" g* e+ w" S& D* e8 D& W
----------------------------------
0 b. ^2 ]8 a, J; Y' {9 Q3 _2010.10.7 更新
% i$ X' ~! O3 j& \( p研究了一下这个游戏的源代码,在\sources\resources\FontManager.cpp里,我发现这个游戏还可以支持ttf字体文件。
2 l; J/ |2 |0 _2 a0 ~, ?方法很简单,只要在fonts目录下放上和.fnt文件同名的.ttf文件,然后把.fnt文件移走即可。# _, T! G- q# Y8 k
相关代码如下
- }/ ?. c( G4 x/ A% y0 D& d; hiFontData* cFontManager::CreateFontData(const tString& asName, int alSize,unsigned short alFirstChar,
: k2 V7 v c1 G unsigned short alLastChar)
; ]: K3 |8 x# M& B0 b' F7 @- h {
# e# e3 h4 G ?6 S; G/ ] tString sPath;
" _# W- ^# V$ B, H9 c @ iFontData* pFont;
1 B- _8 O" z( ? tString asNewName = cString::ToLowerCase(asName);/ |3 g2 s, q$ J) a% C
BeginLoad(asName);; |" ^; b1 A/ e5 [4 A3 m
8 E2 m4 W' L ` //asNewName = cString::SetFileExt(asName,"ttf");0 o/ c. H4 V& ^( Q
pFont = static_cast<iFontData*>(this->FindLoadedResource(asNewName,sPath));9 z/ _6 K1 f1 _
if(pFont==NULL && sPath!="")
" H- ]9 b6 H7 t' `% ] {
4 K. z# B3 r1 d- v2 y# p pFont = mpGraphics->GetLowLevel()->CreateFontData(asNewName);$ L6 q$ ^9 v3 F7 y: J! s
pFont->SetUp(mpGraphics->GetDrawer(),mpLowLevelResources,mpGui);& F! R. \4 k! o6 v; m
6 N' K( s- s$ ]* O tString sExt = cString::ToLowerCase(cString::GetFileExt(asName));
/ n' H" @3 n3 ]/ n3 Y //True Type Font" e( E# i8 B/ L5 g! u
if(sExt == "ttf")
! ]# x( H+ `7 G l' K* b {7 K4 L7 \& L+ c% U% u
if(pFont->CreateFromFontFile(sPath,alSize,alFirstChar,alLastChar)==false){
; d5 R1 `) V9 c; m, W$ E hplDelete(pFont);1 L* x* `- v' j
EndLoad();2 W1 x# c- `+ e' {! L
return NULL;
5 M- ]2 T0 g( M/ U4 V9 t; G0 F }4 {0 f( n: y1 t, ~% M" w9 t* F
}% q. S1 R& s. _: [1 b$ w/ I
//Angel code font type* h9 Q# I& Q$ d
else if(sExt == "fnt")$ e! g8 N- W- U, i( {6 l5 Y
{
& K) g) j) N" L% @: J* ^ if(pFont->CreateFromBitmapFile(sPath)==false){
. p: ^9 b* ^: p hplDelete(pFont);! ^3 ~! i5 `, Z1 C. I8 S% G( v
EndLoad();8 L- Z6 ~; \+ L. c0 m
return NULL;
1 P0 M& A" U4 F; z" I" g7 [- [) w }# M2 M( t8 @$ \5 v" u/ x
}
. x! j/ c8 v! _$ }* D7 B5 U9 M else
4 T: ?; l) O; Q5 E {
! t$ A- @" x2 ]. e Error("Font '%s' has an unkown extension!\n",asName.c_str());
' i/ X: x2 k& S hplDelete(pFont);4 n2 a/ S+ ^, v g( f
EndLoad();& i) J1 L6 Y3 l7 N& \
return NULL;
( q. a9 j2 _! i2 _% k }, G' I S& {0 L: I* @: h7 W
4 j9 o; K7 I/ D* y. w2 w* c% P) i
//mpResources->GetImageManager()->FlushAll();/ D* n& r$ U1 t5 Q$ I5 e5 Q
AddResource(pFont);' b }9 i3 A/ E5 Q7 b+ H% {8 K
} B2 J1 T7 e3 _ z; t
if(pFont)pFont->IncUserCount();
, o" [; K4 g4 H% W0 Q0 ]5 _) J else Error("Couldn't create font '%s'\n",asNewName.c_str());4 l+ b% @: \ ?; O; T4 [, l6 r
% v; A& O e2 t D EndLoad();5 B1 X e/ C1 s; h, V
return pFont;
j) S& T' X. S' } } |