Question

Is TextRenderer.DrawText() capable to draw the end of a text when destination rectangle is too small?

TextFormatFlags.Bottom didn't helped me.

In others words: how to clip text on its top edge?

Was it helpful?

Solution

Create an in memory bitmap that is the size of the "overflow area". Draw your text string to this overflow area with a -Y coord that so that it draws off the top of the image that lines up with the area you want to clip to. You now have the overflow text in an image that you can paint where you want it.

For example, if you want to draw text that is 100 pixel high in an area that can only show 75 pixels, create a 25 pixel high image, and draw your text to that image at y=-75.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top