Use StringFormat.GenericDefault when loading glyphs, to account for overhangs (especially visible in e.g. italics).

Remove an unused variable in MeasureText.
This commit is contained in:
the_fiddler 2008-07-01 18:50:49 +00:00
parent ee34df5b16
commit 486a3cf645

View file

@ -33,7 +33,8 @@ 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 readonly StringFormat default_string_format = StringFormat.GenericTypographic; // Check the constructor, too, for additional flags.
static readonly StringFormat load_glyph_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.
@ -69,6 +70,8 @@ namespace OpenTK.Graphics
gfx.TextRenderingHint = TextRenderingHint.AntiAlias; gfx.TextRenderingHint = TextRenderingHint.AntiAlias;
//gfx.TextContrast = 0; //gfx.TextContrast = 0;
} }
default_string_format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
} }
/// <summary> /// <summary>
@ -310,8 +313,6 @@ namespace OpenTK.Graphics
{ {
int status = 0; int status = 0;
RectangleF bounding_box = new RectangleF();
if (String.IsNullOrEmpty(text)) if (String.IsNullOrEmpty(text))
return RectangleF.Empty; return RectangleF.Empty;
@ -425,7 +426,7 @@ namespace OpenTK.Graphics
if (pack == null) if (pack == null)
PrepareTexturePacker(); PrepareTexturePacker();
RectangleF glyph_rect = MeasureText(c.ToString(), SizeF.Empty, default_string_format); RectangleF glyph_rect = MeasureText(c.ToString(), SizeF.Empty, load_glyph_string_format);
SizeF glyph_size = new SizeF(glyph_rect.Right, glyph_rect.Bottom); // We need to do this, since the origin might not be (0, 0) SizeF glyph_size = new SizeF(glyph_rect.Right, glyph_rect.Bottom); // We need to do this, since the origin might not be (0, 0)
Glyph g = new Glyph(c, font, glyph_size); Glyph g = new Glyph(c, font, glyph_size);
Rectangle rect; Rectangle rect;