private GetCharacterData ( string text, int offset, |
||
text | string | The string containing the codepoint. |
offset | int | The offset at which to read the codepoint. For surrogate pairs, two characters are read, and one otherwise. |
texture | Receives the texture that contains the codepoint. | |
data | OpenGlFontChar | Receives the data that describes the codepoint. |
Résultat | int |
internal int GetCharacterData(string text, int offset, out Textures.Texture texture, out OpenGlFontChar data) {
int value = char.ConvertToUtf32(text, offset);
int hi = value >> 8;
int lo = value & 0xFF;
if (this.Tables[hi] == null || this.Tables[hi].Texture == null)
{
this.Tables[hi] = new OpenGlFontTable(this.Font, hi << 8);
}
texture = this.Tables[hi].Texture;
data = this.Tables[hi].Characters[lo];
return value >= 0x10000 ? 2 : 1;
}
Fonts.OpenGlFont::GetCharacterData ( string text, int offset, int &texture, OpenGlFontChar &data ) : int |
// --- functions --- /// <summary>Measures the size of a string as it would be rendered using the specified font.</summary> /// <param name="font">The font to use.</param> /// <param name="text">The string to render.</param> /// <returns>The size of the string.</returns> internal static Size MeasureString(Fonts.OpenGlFont font, string text) { int width = 0; int height = 0; if (text != null && font != null) { for (int i = 0; i < text.Length; i++) { Textures.Texture texture; Fonts.OpenGlFontChar data; i += font.GetCharacterData(text, i, out texture, out data) - 1; width += data.TypographicSize.Width; if (data.TypographicSize.Height > height) { height = data.TypographicSize.Height; } } } return(new Size(width, height)); }