0
\$\begingroup\$

I'm currently working on a font-rendering system for my OpenGL based engine. I sure got something to work, but the only thing I still have problems with, is the horizontal advance!

example

This is what it spits out, obviously not correct. If I understood correct from the documentation and some other threads, this is the procedure to draw a string:

  1. set current drawing position to (0, 0)
  2. draw first character
  3. move drawing position in the x for advance.x
  4. draw second character
  5. move drawing position in the x for next face->glyph->advance.x
  6. ... repeat

Is that correct? If not, what am I doing wrong? I think its worth to say that I render every character as a texture!

\$\endgroup\$
  • \$\begingroup\$ It looks like you when you draw a letter, you then move the x by the next letter's width instead of the one you just drawn \$\endgroup\$ – Bálint Aug 16 '17 at 8:30
  • \$\begingroup\$ Well that did it kind of. I should move my cursor after drawing the current one. Thanks! \$\endgroup\$ – Kiryu144 Aug 16 '17 at 10:28
1
\$\begingroup\$

As Bálint stated, the advance is for the next char. So just moving the cursor after drawing the current one solved it!

\$\endgroup\$
  • \$\begingroup\$ You should accept this answer. \$\endgroup\$ – HolyBlackCat Feb 4 '18 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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