# Rendering only a part of text FTGL, OpenGL

I'm using FTGL library to render text in my C++ project.

I can easily render text by using:

CFontManager::Instance().renderWrappedText(font, lineLength, position, text);


Unfortunately there is a situation in which this Button which displays text, is partly hidden because of resizing container in which it is situated. I'm able without any problem to draw Button's background to fit the container, but I've got a problem with doing the same with a text. Is it possible to somehow draw only text for given width and the rest just ignore?

This is a screen which presents my problem:

• I think you'd have to figure out the width of your text string based on font size beforehand somehow, and then only print what would fit based on that. I don't know if FTGL has a way to do that or not. – Eric B Nov 26 '12 at 12:55
• @EricB That's what I was afraid of... I think FTGL doesn't have such possibility. But even though if I achieve this, I would be able only to cut off specific number of letters. What if I'd like to cut one letter (for example 'k' on sample screenshot I gave) in a half? Is it impossible? – Piotr Chojnacki Nov 26 '12 at 13:03
• nothing's impossible, but to do that you would certainly have to use standard freetype and then manipulate the bitmaps it gives you yourself, messing with the texture coordinates and so on. So... what you're looking for CAN be done, but not quickly or easily. – Eric B Nov 26 '12 at 13:15
• @Mosquito: Please stop cross-posting questions. – Nicol Bolas Nov 26 '12 at 23:09

glEnable(GL_SCISSOR_TEST);