• 15
• 15
• 11
• 9
• 10

# Making a D3DXFont font class - noob problems

This topic is 2511 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi,

I am trying to make a font class that usses D3DxFont to write stuff on screen. And I didn't get far.
Problem is that I don't know which type my "fontname" and "text" parameters need to be so that it can be used to call D3DX methods to set the font type and to write text.

First problem is my class with which I set the type and size of the font. I tried to send the name of the font like a std::string, but it doesn't compile. It says it cannnot convert string to CHAR.

font->setFont("Elephant",50);

void AR_Font::setFont( [enter type here] fontname, int size) { this->font_size = size; D3DXFONT_DESC FontDesc={ size, 0, 400, 0, false, DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_PITCH, fontname }; D3DXCreateFontIndirect(g_engine->getDevice(),&FontDesc,&this->dx_font); }

Second problem is that I don't know which type my parameters need to be to be able to read ostringstream.

I want to do this:

ostringstream blabla;
blabla<< "some text " << some_variable << " , " << other_variable << " ]";
font->write_text(blabla.str(),0,500,0xFFFF0000);

 void AR_Font::write_text( [enter type here] text, double x, double y , D3DCOLOR color) { RECT position = { (int)x, (int)y, (int)g_engine->getScreenWidth(), (int)g_engine->getScreenHeight() }; this->dx_font->DrawText(NULL,text,-1,&position,DT_CENTER,color); }