TrueType font Support by FreeType Library
TrueType font Support by FreeType Library
Hi,
I made Class CGUITTFonts. Subclass of IGUIFont that supports TrueType font.
Can Render TrueType Font and AntiAlias font supported.
and Can Render Asian MultiBytes fonts.
OPENGL,DirectX and Software Renderer ready.
Here is ScreenShot
And Here is Sample(Source and Win32 bin and Sample Japanese TTFont)
http://www.zgock-lab.net/IrrFreeType.zip
Under DirectX8,9 with AntiAlias seems slow .
Cos DirectX Driver cannot Render 32bit A8R8G8B8 Texture with Draw2DImage().
(Under OpenGL,It is fast enough )
Anyone has any Idea about it?
///////////////////////////////////////////////////////////////////
Zgock
Irrlicht A GoGo - Irrlicht Tutorial in Japanese http://www.zgock-lab.net/irrlicht/
I made Class CGUITTFonts. Subclass of IGUIFont that supports TrueType font.
Can Render TrueType Font and AntiAlias font supported.
and Can Render Asian MultiBytes fonts.
OPENGL,DirectX and Software Renderer ready.
Here is ScreenShot
And Here is Sample(Source and Win32 bin and Sample Japanese TTFont)
http://www.zgock-lab.net/IrrFreeType.zip
Under DirectX8,9 with AntiAlias seems slow .
Cos DirectX Driver cannot Render 32bit A8R8G8B8 Texture with Draw2DImage().
(Under OpenGL,It is fast enough )
Anyone has any Idea about it?
///////////////////////////////////////////////////////////////////
Zgock
Irrlicht A GoGo - Irrlicht Tutorial in Japanese http://www.zgock-lab.net/irrlicht/
-
- Posts: 237
- Joined: Thu May 27, 2004 3:18 pm
- Location: Canada
I tested it, great work!
the result:
1- the japanese font (with and without anti-aliasing) works perfectly (I think... in fact I don't know if it's ok because I'm not able to read it but it looks good)
2- the english font look bad when there is no anti-aliasing, for me it's worse that the bal's screenshots. With anti-alias I don't get those stange lines though.
Can you use another font for english (like arial or times new roman) so I could check if it fix the problems?
BTW, I think that it should be posted in the "project announcements" forum...
the result:
1- the japanese font (with and without anti-aliasing) works perfectly (I think... in fact I don't know if it's ok because I'm not able to read it but it looks good)
2- the english font look bad when there is no anti-aliasing, for me it's worse that the bal's screenshots. With anti-alias I don't get those stange lines though.
Can you use another font for english (like arial or times new roman) so I could check if it fix the problems?
BTW, I think that it should be posted in the "project announcements" forum...
Modified Source and Example. plz test with this.
My PC cannot occur that ploblem.
( Pentium-M 1.6G/RADEON 9000 Mobility/Catalyst 4.8 )
this example depends on Windows. cos loading english font from Windows System Directory.
http://www.zgock-lab.net/IrrFreeType.zip
My PC cannot occur that ploblem.
( Pentium-M 1.6G/RADEON 9000 Mobility/Catalyst 4.8 )
this example depends on Windows. cos loading english font from Windows System Directory.
http://www.zgock-lab.net/IrrFreeType.zip
Fixed DirectX Problem. Even fast as OPENGL
(I was idiot, I forgot setTextureCreationFlag() )
http://www.zgock-lab.net/IrrFreeType.zip
On My PC (Pentium-M 1.6G/RADEON9000) these are FPS on sample.
OPENGL 950-1050 FPS
DirectX8 900-950 FPS
DirectX9 600-700 FPS
Software 90-150 FPS
(I was idiot, I forgot setTextureCreationFlag() )
http://www.zgock-lab.net/IrrFreeType.zip
On My PC (Pentium-M 1.6G/RADEON9000) these are FPS on sample.
OPENGL 950-1050 FPS
DirectX8 900-950 FPS
DirectX9 600-700 FPS
Software 90-150 FPS
-
- Posts: 41
- Joined: Sun Nov 09, 2003 10:12 am
- Location: UK
- Contact:
I tried this out under Linux, linking to my system freetype libraries but when it gets to the font.attach() bit, it crashes
http://www.darkliquid.net - Blog, art, poetry
-
- Posts: 41
- Joined: Sun Nov 09, 2003 10:12 am
- Location: UK
- Contact:
right, i built the demo you made, and that worked fine with whatever fonts I threw at it, loaded from the current directory.
Now I have another problem.
I have the exact same thing setup in my main app I'm writing, but when I call the font->draw(blah, blah, blah) it dies. I traced the fault down to when it calls 'FT_Get_Char_Index' in the 'getGlyphByChar' function.
I don't know why this is happening though. Here is the code for the class that has it in:
CDemoIntro.h
and CDemoIntro.cpp
Now I have another problem.
I have the exact same thing setup in my main app I'm writing, but when I call the font->draw(blah, blah, blah) it dies. I traced the fault down to when it calls 'FT_Get_Char_Index' in the 'getGlyphByChar' function.
I don't know why this is happening though. Here is the code for the class that has it in:
CDemoIntro.h
Code: Select all
#include <CDemoStage.h>
#include <irrlicht.h>
#include <CGUITTFont.h>
class CDemoIntroEvents;
class CDemoIntro : public CDemoStage {
public:
CDemoIntro(IrrlichtDevice * device);
~CDemoIntro();
// Methods
int run();
void quit();
virtual bool OnEvent(irr::SEvent event);
private:
gui::CGUITTFont * font;
video::ITexture* irrlichtLogo;
video::ITexture* darkliquid;
scene::IMesh * mesh;
scene::IAnimatedMesh * hillplane;
};
Code: Select all
#include <CDemoIntro.h>
#include <CGUITTFont.h>
#include <irrlicht.h>
#include <iostream>
using namespace irr;
CDemoIntro::CDemoIntro(IrrlichtDevice * device)
{
//Initialise all the variables
driver = device->getVideoDriver();
timer = device->getTimer();
smgr = device->getSceneManager();
gui = device->getGUIEnvironment();
fader = device->getGUIEnvironment()->addInOutFader(); // must come after gui init
running=0; // tell the main app that the demo is now running (0 = true, 1 = false)
quitting=false;
scene::ISceneNode * root = smgr->getRootSceneNode();
// Add a camera
smgr->addCameraSceneNode(0,core::vector3df(-250,200,-250),core::vector3df(0,-400,0));
// Load font
//font = gui->getFont("../media/fonthaettenschweiler.bmp");
font = new gui::CGUITTFont(driver);
gui::CGUITTFace face;
if(face.load("../media/battle3.ttf"))
std::cout << "Loaded font face..." << std::endl;
font->attach(&face,24);
//font->TransParency=true;
//font->AntiAlias=true;
std::cout << "Attached font face..." << std::endl;
// Set start time for demo
sceneStartTime = timer->getTime();
timeForThisStage = 14000;
// Load the textures
irrlichtLogo = driver->getTexture("../media/irrlichtlogo.bmp");
darkliquid = driver->getTexture("../media/darkliquid.bmp");
driver->makeColorKeyTexture(darkliquid,core::position2d<int>(0,0));
// Scene manager fancy stuff
std::cout << "mesh..." << std::endl;
hillplane = smgr->addHillPlaneMesh("myHill",
core::dimension2d<f32>(20,20),
core::dimension2d<s32>(40,40), 0, 0,
core::dimension2d<f32>(0,0),
core::dimension2d<f32>(10,10));
std::cout << "mesh2..." << std::endl;
mesh = smgr->getMesh("myHill")->getMesh(0);
std::cout << "node..." << std::endl;
scene::ISceneNode * node = smgr->addWaterSurfaceSceneNode(mesh, 3.0f, 300.0f, 30.0f,root);
node->setPosition(core::vector3df(0,0,0));
node->setMaterialTexture(0,driver->getTexture("../media/water.jpg"));
node->setMaterialTexture(1,driver->getTexture("../media/stones.jpg"));
node->setMaterialType(video::EMT_REFLECTION_2_LAYER);
std::cout << "node2..." << std::endl;
scene::ISceneNode * lightnode = smgr->addLightSceneNode(root,core::vector3df(0,0,0),video::SColorf(1.0f,0.6f,0.7f,1.0f),600.0f);
scene::ISceneNodeAnimator* anim=0;
anim=smgr->createFlyCircleAnimator(core::vector3df(0,150,0),200.0f);
lightnode->addAnimator(anim);
anim->drop();
// Setup the InOutFader
fader->setColor(video::SColor(0,0,0,0));
fader->fadeIn(2000);
}
CDemoIntro::~CDemoIntro()
{
// TODO: put destructor code here
std::cout << "Deallocating resources..." << std::endl;
smgr->getRootSceneNode()->removeAll();
font->drop();
fader->remove();
irrlichtLogo->drop();
darkliquid->drop();
driver->removeAllTextures();
}
int CDemoIntro::run() {
if(((timer->getTime()-sceneStartTime)>timeForThisStage) && timeForThisStage != -1 || quitting) {
quit();
}
smgr->drawAll();
driver->draw2DRectangle(video::SColor(128,255,255,255),core::rect<s32>(0,375,640,425));
driver->draw2DImage(irrlichtLogo,core::position2d<int>(10,10));
font->draw(L"Hello TrueType",core::rect<s32>(0,240,640,240),video::SColor(128,255,64,64),true);
//driver->draw2DImage(darkliquid,core::position2d<int>(280,340),core::rect<s32>(0,0,360,140),0,video::SColor(128,32,255,32),false);
gui->drawAll();
return running;
}
void CDemoIntro::quit() {
if(!quitting && fader->isReady()) {
fader->fadeOut(2000);
quitting=true;
}
if (fader->isReady()) {
std::cout << "End of demo..." << std::endl;
running=1;
}
}
bool CDemoIntro::OnEvent(SEvent event) {
if (event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_ESCAPE &&
event.KeyInput.PressedDown == false)
{
// user wants to quit.
quit();
}
return false;
}
http://www.darkliquid.net - Blog, art, poetry
-
- Posts: 41
- Joined: Sun Nov 09, 2003 10:12 am
- Location: UK
- Contact:
This is what GDB says, if it helps:
Code: Select all
Program received signal SIGSEGV, Segmentation fault.
0x40209bd3 in FT_Get_Char_Index (face=0x8195d50, charcode=72) at ftobjs.c:2302
2302 ftobjs.c: No such file or directory.
in ftobjs.c
#0 0x40209bd3 in FT_Get_Char_Index (face=0x8195ff8, charcode=72) at ftobjs.c:2302
#1 0x0804e264 in irr::gui::CGUITTFont::getGlyphByChar (this=0x81991b0, c=72) at CGUITTFont.cpp:207
#2 0x0804ec24 in irr::gui::CGUITTFont::getWidthFromCharacter (this=0x81991b0, c=72) at CGUITTFont.cpp:229
#3 0x0804e334 in irr::gui::CGUITTFont::getDimension (this=0x81991b0, text=0x80e6160) at CGUITTFont.cpp:220
#4 0x0804e455 in irr::gui::CGUITTFont::draw (this=0x81991b0, text=0x80e6160, position=@0xbffff980, color={color = -2130755520}, hcenter=true,
vcenter=false, clip=0x0) at CGUITTFont.cpp:264
#5 0x0804d0be in CDemoIntro::run (this=0x8198ee8) at CDemoIntro.cc:98
#6 0x0804b5d4 in CDemo::runDemo (this=0x810e590) at CDemo.cc:66
#7 0x0804af1a in main () at main.cc:13
http://www.darkliquid.net - Blog, art, poetry