OpenBve.Fonts.OpenGlFont.GetCharacterData C# (CSharp) Méthode

GetCharacterData() private méthode

Gets data associated with the specified codepoint.
private GetCharacterData ( string text, int offset, Textures &texture, OpenGlFontChar &data ) : int
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 Textures 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;
			}

Same methods

Fonts.OpenGlFont::GetCharacterData ( string text, int offset, int &texture, OpenGlFontChar &data ) : int

Usage Example

        // --- 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));
        }
All Usage Examples Of OpenBve.Fonts.OpenGlFont::GetCharacterData