2

All is in the title. I try to create my own OpenGL font system, and I need to get the size of each character I want to include in a Sprite texture. All works well and accurately, except for the character "&" (ascii 38). Even if I change the font, this character always return zero for the width. Height is good.

The strangest thing is that, if I try to measure the concatenation of "&&" (Chr(38) & Chr(38)), the result seems good ! I haven't check to see if the same code point in another range of the same font product the same error, so I don't know if the workaround "if char is "38" test the size on "38+38" will always work.

EDIT: Sorry,I'm so stupid. I completely forgotten to say I'm under VB.Net (but can understand C#) and I use OpenGL with OpenTK for the binding. TextRenderer is a class of GDi+. I use this to create my font texture. This is really not an OpenGL issue.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Norris
  • 31
  • 2

1 Answers1

5

The & is used in control text to declare the next character is a shortcut key. For example, having a control with the text "E&xit" displays "Exit" with the "x" underlined and will activate when the user presses Alt+X.

To include ampersands in your measurement, use:

TextRenderer.MeasureText(text, font, Size.Empty, TextFormatFlags.NoPrefix)
Hand-E-Food
  • 12,368
  • 8
  • 45
  • 80