相关网址
, l" D! m B- E9 ~2 b1 ]http://www.frictionalgames.com/forum/forum-27.html
8 g5 G8 i: t/ E/ k( F7 P+ v z" t/ R* i" d$ ^1 E) f* q0 u0 `. ^- o
----------------------------------
R/ t# ]/ v- }9 l5 J- o# ~! n* Z2010.10.7 更新5 N) }0 P q! y1 ~
研究了一下这个游戏的源代码,在\sources\resources\FontManager.cpp里,我发现这个游戏还可以支持ttf字体文件。* m& x6 |9 x( ]& H! Y; C& w
方法很简单,只要在fonts目录下放上和.fnt文件同名的.ttf文件,然后把.fnt文件移走即可。
8 s! t3 y1 O/ w相关代码如下 q8 I0 f3 i9 e/ e2 W+ s6 Z# Z2 p8 x$ W
iFontData* cFontManager::CreateFontData(const tString& asName, int alSize,unsigned short alFirstChar,
" e7 |: c0 h* C! [ unsigned short alLastChar)
. s* F4 _" E, G {" `2 D" E2 z- ^
tString sPath;
+ X5 |$ v# n2 H2 _% `: E0 D iFontData* pFont;
" f4 y/ g+ P" @7 q9 R4 J1 o) z tString asNewName = cString::ToLowerCase(asName);
2 F5 @' O! M. O: e BeginLoad(asName);6 [5 J" d9 j+ p5 g% x
# h( s3 d; o, j/ E- \0 g //asNewName = cString::SetFileExt(asName,"ttf");) k1 r8 z4 X8 Z- f2 I
pFont = static_cast<iFontData*>(this->FindLoadedResource(asNewName,sPath));* f8 K) C4 F6 U% ? `. B
if(pFont==NULL && sPath!=""). E$ A) `# ]/ I( d0 L$ C7 g
{/ D% n4 c5 J# I; ~1 g* A
pFont = mpGraphics->GetLowLevel()->CreateFontData(asNewName);
5 O) j( K6 r- z$ d. \ pFont->SetUp(mpGraphics->GetDrawer(),mpLowLevelResources,mpGui);, _) n& O0 [# u% d0 D
: \5 Y, F( w, C( t7 C7 x3 r
tString sExt = cString::ToLowerCase(cString::GetFileExt(asName));! d5 K. n( }9 i2 r, \) z* E) A8 F
//True Type Font
8 p$ d* E8 ~# L) b* [ if(sExt == "ttf")3 U) Q: s5 p T% ~
{
# D; B# U6 c1 u1 Z if(pFont->CreateFromFontFile(sPath,alSize,alFirstChar,alLastChar)==false){" v" c1 z) t2 k. ^6 T
hplDelete(pFont);
& |1 P; y' T4 L! Y EndLoad();0 U3 o# [' s9 p$ ^6 {2 C
return NULL;
$ u4 A# j$ E9 u% I! R6 g }& T" i& `- N* H% `) d, ?
}7 O! u4 `- Y; o1 x& X) |
//Angel code font type
% ?& l6 p1 R& m- |) U. G* f6 a8 c else if(sExt == "fnt")
) u" H: H. b; U; B {% ]* [/ ^7 o1 F/ X4 Q1 w6 Q
if(pFont->CreateFromBitmapFile(sPath)==false){; R4 z' L* i8 D9 ^1 f
hplDelete(pFont);' P$ Z) P3 Z2 W: t- k9 [; u& t
EndLoad();
- y: P- \8 J( F. j. J4 W8 } return NULL;
8 R" }* D6 i; z; ~8 s; R _ }
( z$ j4 B" {3 b, ]2 Z5 s4 d$ B }
0 @/ R* n# M3 q9 h. \2 e$ T else3 i" Z, U/ t" f
{
& B9 ]& W; ]' D Error("Font '%s' has an unkown extension!\n",asName.c_str());5 a( b" S1 l% {
hplDelete(pFont);
, u" f2 x4 c* E EndLoad();! l1 x9 r; C% _: E1 e2 J- v& i
return NULL;
8 H5 z- h& d9 S% z& M2 x4 t }
6 w& C& M1 q# ]
0 U# I8 @8 s5 U" q+ I2 G //mpResources->GetImageManager()->FlushAll();9 S+ | A5 S E8 K: @
AddResource(pFont);$ @) E! |' A) c5 _$ Q; z
}! k, C9 I5 i& M( K3 J" o1 _
if(pFont)pFont->IncUserCount();
) p: [8 k7 w, e7 `& R# { else Error("Couldn't create font '%s'\n",asNewName.c_str());
& V/ ?2 h" v6 J, @( c8 _" Q. m
P# d/ x4 G2 F) o7 V" p2 w EndLoad();
5 I c. u6 q/ K3 z return pFont;
9 ^. K9 Q0 T0 {# k5 P+ l } |