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

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

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

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

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

图片字库制作利器SDFont

原文" z5 m& s9 K6 D0 `2 ^
http://www.gamedev.net/community/forums/topic.asp?topic_id=4919388 w: t' N7 `. Z- ?# v

* c5 A- r8 Q  t" _3 a用法. _# I, G; f" q" `: H
How to use:/ _, J# p/ ]9 W* F4 F& _" h( F
* drag font files onto the exe
3 t; |7 y+ |9 @/ U8 d* the app asks for a texture size (256 will yield a 256x256 texture for each input font file)
! K6 T( u% i$ E6 E" q3 H6 B9 P* the app will render all valid glyphs in the ANSI range [0..255]. n4 M! f8 i- }
* 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
4 ^! A% ~* T9 Y" b. z. M/ B" G: e8 Q9 S% f* the app packs the rendered Signed Distance Field glyphs into a single texture8 C, M9 z1 ^0 s- v' E$ X% W
* look at the output PNG and TXT file (in the same directory as the font file)
, W" C2 u! H- {- m4 R# c) @# ]8 N' O% S$ {+ c: r  p
Credits:$ {' g6 _( s  W, u: p
* FreeType2 for font rendering
  O+ u+ w( P- w2 w% u* LodePNG for saving the resultant file& t& C, w& D; R" B, v
* BinPacker code from GameDev's own jyk!6 w5 E& z5 Z/ {' {
8 U; W& c# U* {; U% y' k3 @  h
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):# f- `* Z# t0 ?& o. B5 O# j$ P( K$ |

8 `& y6 @/ l/ f; ?" V* 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
1 K: f2 ?' Z) U) X% a. L% w/ c5 z
, w6 K7 o. |. ?, G. Q  g* 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>)
/ ]6 e) P1 b! W
1 M5 h# S, L, g* B. v0 n. f* I want to allow an image for input, where a Signed Distance Field would then be computed from that into a lower resolution texture, ?3 T# j7 t6 J3 L$ H: m9 n3 h# N
5 i6 X$ S- q! X5 A$ m1 s
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.). Z5 Z2 M0 n. J& R: Z6 l4 e/ @

5 d9 n1 Y5 {1 G* D. K" ^* g$ V; M-----------------------------------------------------------------------------------------------------------
: U* F+ J3 Q) j; LI've updated the zip (same link). The changes:2 h* U" n7 d- W1 ^( R9 r: @9 T
% h7 q& n# F8 D/ }5 C2 V7 M1 p4 ]5 r
* after dragging fonts onto the exe, you specify texture size and the highest Unicode character number (only characters with glyphs will be rendered).7 [7 x6 x* [( [% {  w
2 E# P1 T& j; q5 |7 @
* 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)
+ u. C2 |; W, l/ r" a  W* q! y/ M' _' k
* There is a bit more text describing the requested inputs
$ h" e: p; S* ]% n  E. e
9 ?6 ^$ Q  `$ u( v. Y# @! n  ^* \* there is much better error checking (e.g. dragging non-font files onto the exe)( t3 K+ h% M( U+ u; F! `

& q  r; L& s1 _! o) z1 k* 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)
, b6 Z, |' n( ?0 h
; K8 i7 D8 P" i- I" {' f- @6 g6 L/ h. _4 }( D+ X. G
@AndyPandyV2: thanks for the kind words, you're welcome for the app [8^)
+ r2 U3 z! n  T1 d
7 J$ S/ X3 \. Q+ S@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^)
1 w' e- c4 C! l0 N1 P9 q* w8 j. p* K! Q: K: r' @
Here 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日,是全球华人共同的冒险解谜类游戏家园。我们致力于提供各类冒险游戏资讯供大家学习交流。本站所有资源均不用于商业用途。

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