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

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

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

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

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

图片字库制作利器SDFont

原文; w* k0 V, |8 D, N" x$ l
http://www.gamedev.net/community/forums/topic.asp?topic_id=491938% L+ [8 ~4 }- P+ F$ s
, U6 K$ C  c4 g6 l3 o/ m+ x
用法. Z' }3 f0 Y6 w  j- Q
How to use:
+ Q2 \1 {, ?8 r' L) _* drag font files onto the exe5 f) X2 g, ?5 m* ?5 {
* the app asks for a texture size (256 will yield a 256x256 texture for each input font file)( j( @& G) L% ?6 ~$ H4 m8 f
* the app will render all valid glyphs in the ANSI range [0..255]) t% _% g( e) ?" W4 q, D
* 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 earlier
  i8 ]$ l) C2 K, B0 O# ]' P" l* the app packs the rendered Signed Distance Field glyphs into a single texture! x. F7 h9 x3 D: M! [
* look at the output PNG and TXT file (in the same directory as the font file)
& y3 L) N: }0 p! Z' r- l" j1 |  u. m9 M" L$ E
Credits:
$ h' d0 D* @3 }0 k6 E- P* FreeType2 for font rendering
3 W6 \8 u/ d& |* J" ~6 [, M0 b4 S* LodePNG for saving the resultant file
% h7 M* O3 G0 q% B* BinPacker code from GameDev's own jyk!! b: u0 B* C6 S5 z" g7 y

! G! _$ }* V0 A: d! PPlease 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):
) _7 `* m" ]- h3 o. w$ }
& O) _# \' X- g* 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
. W3 R5 d9 n4 C- N  K3 @+ J. @, t& S$ s. o- 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>)  Y: N3 Q  M( ~
, N- B  ?9 Q- G- e
* I want to allow an image for input, where a Signed Distance Field would then be computed from that into a lower resolution texture( a9 ?( O2 K0 Y/ {& O8 N4 h% R5 R" j8 W

- n9 U) I9 k0 {" p4 {So, 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.)4 o( z) E+ Q; E" s

4 m' p* u* r2 w& h-----------------------------------------------------------------------------------------------------------5 g& y. w# `: w6 S6 J
I've updated the zip (same link). The changes:1 C3 O% i6 c# ^9 ?

% u6 {& u( q" O, s* after dragging fonts onto the exe, you specify texture size and the highest Unicode character number (only characters with glyphs will be rendered).4 ]' v* L% G6 R6 T

+ ~6 ?$ X4 ^, K  d* 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)
, l; _6 ^# l8 \( x7 n$ a: u
* G" {. S  _) c/ u* There is a bit more text describing the requested inputs% l2 ]( @( w$ q8 y0 v; f# H& q6 c
& N: m: `3 }; W1 R8 q( T( b
* there is much better error checking (e.g. dragging non-font files onto the exe)
# ]( o& u& d8 ?8 u  B) u
, b3 p# y9 l6 @6 g9 a- d* 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)
7 C, @2 f, ~' f" X4 ]; [) z5 Z$ J" r

2 p' D9 n# m  g4 S) w5 p@AndyPandyV2: thanks for the kind words, you're welcome for the app [8^)4 h% `0 P0 O9 A+ }2 I
$ d2 g1 J0 f- b
@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 p( m! J6 z. f; k; C; M: Z- \

9 V- W; z) `. V2 z8 h8 KHere 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日,是全球华人共同的冒险解谜类游戏家园。我们致力于提供各类冒险游戏资讯供大家学习交流。本站所有资源均不用于商业用途。

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