View Full Version : Center Alignment of Text

04-26-2011, 03:43 AM
I noticed the TextRender and TextBoxRender components support an "alignment" variable, but it doesn't seem to work. Is that TBD? Any hints on getting multiline centered text beyond hard-spacing it in the string?

04-27-2011, 10:10 AM
Well - how it works I believe is the text wrapping is applied, then the centering is applied to the overall rectangle that the resulting text is.

So you can center the block of text, but you can't have each line be centered independently.

//from TextRenderComponent's Init:
m_pAlignment = &GetParent()->GetVar("alignment")->GetUINT32();

The "alignment" var they use is the parent entity's, not at the component level, so to see it work make sure you set it for the containing entity itself.

An optional helper function exists to do it:

SetAlignmentEntity(pSomeEntity, ALIGNMENT_CENTER);