设为首页收藏本站官方微博

汉化工具 图片字库制作利器SDFont

[复制链接]
查看: 3513|回复: 1
打印 上一主题 下一主题

[汉化工具] 图片字库制作利器SDFont

跳转到指定楼层
楼主
发表于 2010-1-18 23:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

图片字库制作利器SDFont

原文
. C7 X2 B4 p/ V' p5 t8 Jhttp://www.gamedev.net/community/forums/topic.asp?topic_id=491938' E/ |! i/ x% h/ {5 Y% ]- x

6 F8 F" z; ~+ a! D4 E. L& N0 U  g用法
, G  [! r5 E% P* C4 V8 kHow to use:3 t, P# P) I1 T- i
* drag font files onto the exe8 N! Q1 o' g/ i; ^% n; n2 R* i' E) k+ ?2 d
* the app asks for a texture size (256 will yield a 256x256 texture for each input font file)6 O& Q+ w$ k2 h- T; y2 C/ e
* the app will render all valid glyphs in the ANSI range [0..255]1 j( q- u. i! Y0 ]* Z
* the app will automatically search for the largest rendering size (integer pixels only, so hinting works with a greater range of TrueType fonts) where it can pack the output into the texture you specified earlier9 c1 L; v5 ^* I
* the app packs the rendered Signed Distance Field glyphs into a single texture
( S8 z0 S/ z( C" q! E6 a* look at the output PNG and TXT file (in the same directory as the font file)$ |3 U4 b0 s7 A& B
8 Q2 }% u+ |3 p$ x" K: t3 N3 _: {
Credits:9 T+ i, g6 X9 c) h( y7 V
* FreeType2 for font rendering, {! D$ n/ d: s3 J8 ?
* LodePNG for saving the resultant file
9 O- f: k' H2 ]8 E. q$ p  l0 e* m, x* BinPacker code from GameDev's own jyk!
$ r& t/ E3 ?, j& A+ b0 l& I8 Q" @  b, M2 H3 r( U% k
Please try it out and let me know what you think. Here are my ideas for where I'm going after this (please give any feedback or feature requests):
8 _% [% {- ^. ~5 \0 B& Q
0 m9 q- h& V' V/ R$ ?8 p* I want to output a text file compliant with AngelCode's BMFont spec so existing loaders can use this output without changing anything other than the alpha threshold$ @6 r; K8 z1 D# j& Y" I- U

. z. Q5 {0 `* ^2 S, A* I want an XML file for configuration so you can specify specific unicode characters (I'm thinking <range>A B</range> and <chars>A B C...ZY ZZ</chars>)) J& X& V/ m; s4 }1 k3 A+ @, T7 p

! f$ k; S  \, j' P/ j/ m* I want to allow an image for input, where a Signed Distance Field would then be computed from that into a lower resolution texture3 j' w8 H9 r6 ^( P/ ~, n

1 V' a2 P+ Z! }, gSo, what do you think? The source will be released (MIT) when I'm a bit closer to done. (Note, the RGB and A channels all share the same signed distance data, so there is a bit of a border to each glyph...I could just use all white for the color, but I think this looks pretty good.)
9 \. ^$ y4 P2 G& b; ~% i2 J7 ]/ {  `2 k+ G5 g' [
-----------------------------------------------------------------------------------------------------------  w* `0 L' ^8 B* B4 }( j7 {/ }
I've updated the zip (same link). The changes:
3 i! h6 K! B3 O( f, Y% ^3 N4 s2 I& {1 K
* after dragging fonts onto the exe, you specify texture size and the highest Unicode character number (only characters with glyphs will be rendered).# ?. l% I0 l/ C
7 f* V) g- {3 \; x
* the output text file now has the offset and advance information, so you can finally render text properly (I hope!) I appended "page=0 chnl=0" to the end of each line to mirror the AngelCode BMFont tool. Note that this info is not integer data, and the offsets may be negative (both functions of the same thing...the actual glyph has border texels to help define the Signed Distance Field)
3 `! \* _8 s# i: t% b3 L: `( R
0 ^$ W5 E% R6 g, H' y3 G, y: W8 I* There is a bit more text describing the requested inputs) q0 k3 X! u9 U7 M

, C$ ?' X- }! c* t( E9 u; [* there is much better error checking (e.g. dragging non-font files onto the exe)
6 X( x$ [% v' ]6 [- ~( q3 j; T1 h; j8 ^
* the zip now includes all my source code, ugly as it is (it also has the LodePNG and BinPacker code...you'll need to get and compile FreeType2 yourself)
6 |8 H4 E0 M( m  o' i9 g, p% c9 n# e6 q& u/ v) H

! L+ G/ k5 J& R4 w@AndyPandyV2: thanks for the kind words, you're welcome for the app [8^)
9 {" c2 e# I  I. w. u% ^8 n. Q) J3 v3 f; o4 Q9 X( S1 X
@OrangyTang & Kylotan: thanks for the feedback/input. As a simple hack you can now input the range of characters to be rendered. I think I like the XML approach as it would be slightly easier for me to implement than the UTF-8 file with all needed characters for 3 reasons: easier to parse as I already use an XML lib, I could see the UTF-8 file getting huge, and there is no guarantee of the glyph order after the packing (though the attendant text file would be in the specified order). Would the XML file be an OK solution for your needs? Or even the current incarnation? (note that rendering the entire Microsoft Arial font into a 4096x4096 took > 20 minutes, so I could see the use of limited sub-ranges! [8^)
2 @& `9 S1 Q2 E- R
! Y+ Z+ W( a+ yHere is some sample output, as I forgot to include this last time:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 很美好很美好 很差劲很差劲
回复

使用道具 举报

沙发
发表于 2010-1-18 23:54 | 只看该作者
这会是个转折吗 [s:45]
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

冒险解谜游戏中文网 ChinaAVG

官方微博官方微信号小黑屋 微信玩家群  

(C) ChinaAVG 2004 - 2019 All Right Reserved. Powered by Discuz! X3.2
辽ICP备11008827号 | 桂公网安备 45010702000051号

冒险,与你同在。 冒险解谜游戏中文网ChinaAVG诞生于2004年9月9日,是全球华人共同的冒险解谜类游戏家园。我们致力于提供各类冒险游戏资讯供大家学习交流。本站所有资源均不用于商业用途。

快速回复 返回顶部 返回列表