Use GenericDefault instead of GenericTypographic for MeasureCharacterRanges, in order to correctly calculate the bounding boxes of glyphs and strings.

This commit is contained in:
the_fiddler 2008-06-28 17:44:24 +00:00
parent a20b8407a2
commit c230cfa3b2

View file

@ -33,7 +33,7 @@ namespace OpenTK.Graphics
static int texture; static int texture;
static TexturePacker<Glyph> pack; static TexturePacker<Glyph> pack;
static int texture_width, texture_height; static int texture_width, texture_height;
static StringFormat default_string_format = StringFormat.GenericTypographic; static StringFormat default_string_format = StringFormat.GenericDefault;
static SizeF maximum_graphics_size; static SizeF maximum_graphics_size;
int[] data = new int[256]; // Used to upload the glyph buffer to the OpenGL texture. int[] data = new int[256]; // Used to upload the glyph buffer to the OpenGL texture.
@ -287,7 +287,7 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
/// <param name="text">The string to measure.</param> /// <param name="text">The string to measure.</param>
/// <param name="bounds">A SizeF structure containing the maximum desired width and height of the text. Pass SizeF.Empty to disable wrapping calculations. A width or height of 0 disables the relevant calculation.</param> /// <param name="bounds">A SizeF structure containing the maximum desired width and height of the text. Pass SizeF.Empty to disable wrapping calculations. A width or height of 0 disables the relevant calculation.</param>
/// <param name="format">A StringFormat object which specifies the measurement format of the string. Pass null to use the default StringFormat (StringFormat.GenericTypographic).</param> /// <param name="format">A StringFormat object which specifies the measurement format of the string. Pass null to use the default StringFormat (StringFormat.GenericDefault).</param>
/// <returns>A RectangleF containing the bounding box for the specified text.</returns> /// <returns>A RectangleF containing the bounding box for the specified text.</returns>
public RectangleF MeasureText(string text, SizeF bounds, StringFormat format) public RectangleF MeasureText(string text, SizeF bounds, StringFormat format)
{ {
@ -303,7 +303,7 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
/// <param name="text">The string to measure.</param> /// <param name="text">The string to measure.</param>
/// <param name="bounds">A SizeF structure containing the maximum desired width and height of the text. Pass SizeF.Empty to disable wrapping calculations. A width or height of 0 disables the relevant calculation.</param> /// <param name="bounds">A SizeF structure containing the maximum desired width and height of the text. Pass SizeF.Empty to disable wrapping calculations. A width or height of 0 disables the relevant calculation.</param>
/// <param name="format">A StringFormat object which specifies the measurement format of the string. Pass null to use the default StringFormat (StringFormat.GenericTypographic).</param> /// <param name="format">A StringFormat object which specifies the measurement format of the string. Pass null to use the default StringFormat (StringFormat.GenericDefault).</param>
/// <param name="ranges">Fills the specified IList of RectangleF structures with position information for individual characters. If this argument is null, these calculations are skipped.</param> /// <param name="ranges">Fills the specified IList of RectangleF structures with position information for individual characters. If this argument is null, these calculations are skipped.</param>
/// <returns>A RectangleF containing the bounding box for the specified text.</returns> /// <returns>A RectangleF containing the bounding box for the specified text.</returns>
public RectangleF MeasureText(string text, SizeF bounds, StringFormat format, IList<RectangleF> ranges) public RectangleF MeasureText(string text, SizeF bounds, StringFormat format, IList<RectangleF> ranges)