Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

Problem with drawing only a part of text

As you can see, the Button "Click here" is being drawn properly, but I can't do the same with "Click here" text.

share|improve this question
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
up vote 3 down vote accepted

Perhaps you could try scissor testing the window when drawing text?

glScissor(windowX, windowY, windowSizeX, windowSizeY);
CFontManager::Instance().renderWrappedText(font, lineLength, position, text);

You can also apply this to everything within the window as a single, unified solution.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.