# Is There Any Way To Clip Text Using Id3Dxfont?

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

## Recommended Posts

I'm trying to create scrolling debug output in my game. Is there any way that I can clip the text that comes [font="'Segoe UI"]from drawing using ID3DXFont?[/font]

##### Share on other sites
I don't know if there's any way to make ID3DXFont clip it itself...but you could definitely do it by setting a scissor rectangle.

##### Share on other sites

I'm trying to create scrolling debug output in my game. Is there any way that I can clip the text that comes [font="Segoe UI"]from drawing using ID3DXFont?[/font]

There is a pRect parameter on the DrawText() function, that should clip the text to draw only within that rectangle, if you don't specify the DT_NOCLIP format option.

##### Share on other sites
Okay so I am trying to set up a Scissor Rectangle. The text I'm rendering clearly is not inside the rectangle however, is still being rendererd. Any help?
Also... I'm using SlimDX and C# however the code should be similar to dx/c++

 device.ScissorRect = new Rectangle(new Point(0, 0), new Size(10, 10)); device.SetRenderState(RenderState.ScissorTestEnable, true); renderer.DrawText("Hello World", new Point(75, 75)); // Clearly not inside the rect!! device.SetRenderState(RenderState.ScissorTestEnable, false); 

##### Share on other sites

I'm trying to create scrolling debug output in my game. Is there any way that I can clip the text that comes [font="Segoe UI"]from drawing using ID3DXFont?[/font]

Typically, you need to draw your UI in layers to cut off the text. For example, Draw the background of your window, then the text, then some sort of border around the text area big enough that it will cut the text off giving the appearance you are seeking. If you have a transparent background for your text, then i dunno

##### Share on other sites

Typically, you need to draw your UI in layers to cut off the text. For example, Draw the background of your window, then the text, then some sort of border around the text area big enough that it will cut the text off giving the appearance you are seeking. If you have a transparent background for your text, then i dunno

You need to pass in the Rectangle to the SlimDX DrawString function specifying the bounding area you want it to be in. I imagine its overriding the device state that you are setting (so that it can render the text properly itself).

public int DrawString( Sprite sprite, string text, Rectangle rectangle, DrawTextFormat format, Color4 color)

• 35
• 12
• 10
• 9
• 9
• ### Forum Statistics

• Total Topics
631355
• Total Posts
2999521
×