HGE中文解决方案hgeTTF
来源:互联网 发布:淘宝二手电脑怎么检测 编辑:程序博客网 时间:2024/05/01 12:45
这是一个比较好的解决方案,直接用字体来,不用png图片渲染。
下面是下载来的hgeTTF里附带的demo(我自己稍微修改了下):
- #include <Windows.h>
- #include <hge.h>
- #include "hgeTTF/FontManager.h"
- #include "hgeTTF/Font.h"
- #include <cassert>
- static const int ScreenWidth = 800;
- static const int ScreenHeight = 600;
- static const unsigned char ScreenBpp = 32;
- static const char* WindowTitle = "hgeTTF Test";
- static const char* LogFile = "Log.txt";
- HGE* hge = hgeCreate(HGE_VERSION);
- hgeTTF::FontManager FontMgr;
- hgeTTF::Font* Font = NULL;
- float Rotation = 0;
- bool Update();
- bool Render();
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
- {
- hge->System_SetState(HGE_FRAMEFUNC, Update);
- hge->System_SetState(HGE_RENDERFUNC, Render);
- hge->System_SetState(HGE_WINDOWED, true);
- hge->System_SetState(HGE_SCREENWIDTH, ScreenWidth);
- hge->System_SetState(HGE_SCREENHEIGHT, ScreenHeight);
- hge->System_SetState(HGE_SCREENBPP, ScreenBpp);
- hge->System_SetState(HGE_TITLE, WindowTitle);
- hge->System_SetState(HGE_SHOWSPLASH, false);
- hge->System_SetState(HGE_LOGFILE, LogFile);
- hge->System_SetState(HGE_USESOUND, false);
- hge->System_SetState(HGE_HIDEMOUSE, false);
- hge->System_SetState(HGE_FPS, HGEFPS_UNLIMITED);
- if (!hge->System_Initiate())
- return false;
- if (!FontMgr.Initialize())
- return 1;
- if (!FontMgr.loadFont("monafont-ttf-2.90/mona.ttf"))
- return 2;
- Font = FontMgr.getFont("monafont-ttf-2.90/mona.ttf");
- Font->setSize(32);
- if (!Font->cacheChars('a', 'z'))
- return 3;
- if (!Font->cacheChars(L"ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
- return 4;
- hge->System_Start();
- hge->Release();
- return 0;
- }
- bool Update()
- {
- hgeInputEvent Event;
- while (hge->Input_GetEvent(&Event))
- {
- switch (Event.type)
- {
- case INPUT_KEYDOWN:
- switch (Event.key)
- {
- case HGEK_ESCAPE:
- return true;
- case HGEK_K:
- //Toggle kerning
- Font->useKerning(!Font->usingKerning());
- break;
- }
- break;
- }
- }
- Rotation += 5.0f * hge->Timer_GetDelta();
- return false;
- }
- bool Render()
- {
- hge->Gfx_BeginScene();
- hge->Gfx_Clear(0);
- Font->setRotation(0.0f);
- Font->setColor(0xffffffff);
- Font->setSize(22);
- Font->printf(5, 30, L"FPS: %d", hge->Timer_GetFPS());
- float mouseX = 0.0f, mouseY = 0.0f;
- hge->Input_GetMousePos(&mouseX, &mouseY);
- Font->printf(5, 60, L"%d x %d", (int)mouseX, (int)mouseY);
- Font->setColor(0xffffff00);
- Font->setSize(42);
- Font->drawString(L"一个好的解决方案", 400, 200);
- hge->Gfx_RenderLine(400, 210, 400 + Font->getStringWidth(L"一个好的解决方案"), 210);
- Font->setSize(22);
- Font->printf(300, 50, L"%s", L"printf");
- hge->Gfx_RenderLine(300, 55, 300 + Font->getStringWidth(L"printf"), 55);
- Font->setColor(0xffcc0000);
- Font->drawString(L"Multi/nLine", 150, 200);
- Font->setColor(0xffff0000, 1);
- Font->setColor(0xffff0000, 2);
- Font->setColor(0xff00ff00, 3);
- Font->setColor(0xff00ff00, 4);
- Font->drawString(L"Horizontal/t Tab", 50, 400);
- Font->drawString(L"Vertical/v Tab", 50, 450);
- Font->setSize(32);
- Font->setColor(0xff00ff00);
- Font->setRotation(Rotation);
- Font->drawString(L"Rotation", 500, 400);
- hge->Gfx_EndScene();
- return false;
- }
- HGE中文解决方案hgeTTF
- HGE的中文显示解决方案
- HGE的中文显示解决方案 .
- HGE中文显示的一个解决方案
- HGE中文文档
- 让HGE支持中文(1) - HGE中文显示
- 让HGE支持中文(2) - HGE中文输入
- 让HGE支持中文(1) - HGE中文显示
- 让HGE支持中文(2) - HGE中文输入
- 让HGE支持中文(3) - HGE字符串处理
- 让HGE支持中文(3) - HGE字符串处理
- HGE中文显示最新修改 - 070717
- HGE使用free type实现中文输出
- HGE中文显示最新修改 - 070717
- HGE下汉字显示的两种解决方案
- 让HGE支持中文(4) - 编辑框的实现
- HGE 丢失hge.dll
- 本方案是为解决在HGE的项目中支持中文的显示
- 实验七 二极管包络检波实验
- 大型网站设计经验分享 技术交流讲座
- 我们的脚印
- 兄弟连PHP学习套装,2010年限期促销!
- [夜校]Web开发网络课堂第六讲:PHP的语言结构[11月24/25日]
- HGE中文解决方案hgeTTF
- C++对象工厂模式:ObjectFactory学习笔记
- 什么叫精通C++
- 软件教育随想
- java程序员的10项基本技能
- 图
- java选择题
- 梦想需要坚持
- 生活是不公平的,学会去适应!