﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Game？Life？-文章分类-guichan</title><link>http://www.cppblog.com/sureandrew/category/13146.html</link><description>Love Family &amp;&amp; Love Career = Love Life</description><language>zh-cn</language><lastBuildDate>Sun, 28 Feb 2010 07:27:07 GMT</lastBuildDate><pubDate>Sun, 28 Feb 2010 07:27:07 GMT</pubDate><ttl>60</ttl><item><title>guichan+hge中文显示支持</title><link>http://www.cppblog.com/sureandrew/articles/108604.html</link><dc:creator>阿炳</dc:creator><author>阿炳</author><pubDate>Sun, 28 Feb 2010 06:08:00 GMT</pubDate><guid>http://www.cppblog.com/sureandrew/articles/108604.html</guid><wfw:comment>http://www.cppblog.com/sureandrew/comments/108604.html</wfw:comment><comments>http://www.cppblog.com/sureandrew/articles/108604.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/sureandrew/comments/commentRss/108604.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sureandrew/services/trackbacks/108604.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp; 最近打算用guichan作为hge的UI库，来做开发。如果用它做UI库，首先要解决的问题就是中文的显示和中文的输入。但是我google了几天，也没找到相关的资料，所以打算自己从hge开始为guichan添加中文支持。<br>&nbsp;&nbsp;&nbsp; 我的中文显示方案是微妙的平衡在他blog上公布的方案，其中还包含了Kevin Lynx的freetype方案，这个就不用多说了都有现成的demo，关键是把guichan接受的中文文本通过hge渲染出来，kevin lynx已经将guichan整合到hge中了，而这个中间层的几个类中，有一个关于字体HGEImageFont类，这个类中用于字体渲染的成员变量mHGEFont是hgeFont（即hge的默认字体类）的实例，将这个成员变量换成FontSprite的，这个字体类是支持中文现实的，然后HGEImageFont的函数做相应修改。最后就是字符的转换，guichan接受的是std::string参数，但是在FontSprite接受的参数是wchar_t,所以这里需要做一个std::string到std::wstring的字符转换，这样汉字才能正常渲染。<br>以下为截图：<br><img alt=""  src="http://www.cppblog.com/images/cppblog_com/sureandrew/hge1.jpg" height="510" width="646"><br><img alt=""  src="http://www.cppblog.com/images/cppblog_com/sureandrew/hge2.jpg" height="513" width="647"><br><img alt=""  src="http://www.cppblog.com/images/cppblog_com/sureandrew/hge3.jpg" height="516" width="647"><br><br><img src ="http://www.cppblog.com/sureandrew/aggbug/108604.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sureandrew/" target="_blank">阿炳</a> 2010-02-28 14:08 <a href="http://www.cppblog.com/sureandrew/articles/108604.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>