SetGlyphTexCoords() private method

private SetGlyphTexCoords ( UInt32 c, Real u1, Real v1, Real u2, Real v2 ) : void
c System.UInt32
u1 Real
v1 Real
u2 Real
v2 Real
return void
        /// <summary>
        ///    Parses an attribute of the font definitions.
        /// </summary>
        /// <param name="line"></param>
        /// <param name="font"></param>
        private void ParseAttribute(string line, Font font)
        {
            string[] parms = line.Split(new char[] {' ', '\t'});
            string attrib = parms[0].ToLower();

            switch(attrib) {
                case "type":
                    if(parms.Length != 2) {
                        ParseHelper.LogParserError(attrib, font.Name, "Invalid number of params for glyph ");
                        return;
                    }
                    else {
                        if(parms[0].ToLower() == "truetype") {
                            font.Type = FontType.TrueType;
                        }
                        else {
                            font.Type = FontType.Image;
                        }
                    }
                    break;

                case "source":
                    if(parms.Length != 2) {
                        ParseHelper.LogParserError("source", font.Name, "Invalid number of params.");
                        return;
                    }

                    // set the source of the font
                    font.Source = parms[1];

                    break;

                case "glyph":
                    if(parms.Length != 6) {
                        ParseHelper.LogParserError("glyph", font.Name, "Invalid number of params.");
                        return;
                    }

                    char glyph = parms[1][0];

                    // set the texcoords for this glyph
                    font.SetGlyphTexCoords(
                        glyph,
                        StringConverter.ParseFloat(parms[2]),
                        StringConverter.ParseFloat(parms[3]),
                        StringConverter.ParseFloat(parms[4]),
                        StringConverter.ParseFloat(parms[5]));

                    break;

                case "size":
                    if(parms.Length != 2) {
                        ParseHelper.LogParserError("size", font.Name, "Invalid number of params.");
                        return;
                    }

                    font.TrueTypeSize = int.Parse(parms[1]);

                    break;

                case "resolution":
                    if(parms.Length != 2) {
                        ParseHelper.LogParserError("resolution", font.Name, "Invalid number of params.");
                        return;
                    }

                    font.TrueTypeResolution = int.Parse(parms[1]);

                    break;

                case "antialias_colour":
                    if(parms.Length != 2) {
                        ParseHelper.LogParserError("antialias_colour", font.Name, "Invalid number of params.");
                        return;
                    }

                    font.AntialiasColor = bool.Parse(parms[1]);

                    break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///    Parses an attribute of the font definitions.
        /// </summary>
        /// <param name="line"></param>
        /// <param name="font"></param>
        private void ParseAttribute(string line, Font font)
        {
            string[] parms  = line.Split(new char[] { ' ', '\t' });
            string   attrib = parms[0].ToLower();

            switch (attrib)
            {
            case "type":
                if (parms.Length != 2)
                {
                    ParseHelper.LogParserError(attrib, font.Name, "Invalid number of params for glyph ");
                    return;
                }
                else
                {
                    if (parms[0].ToLower() == "truetype")
                    {
                        font.Type = FontType.TrueType;
                    }
                    else
                    {
                        font.Type = FontType.Image;
                    }
                }
                break;

            case "source":
                if (parms.Length != 2)
                {
                    ParseHelper.LogParserError("source", font.Name, "Invalid number of params.");
                    return;
                }

                // set the source of the font
                font.Source = parms[1];

                break;

            case "glyph":
                if (parms.Length != 6)
                {
                    ParseHelper.LogParserError("glyph", font.Name, "Invalid number of params.");
                    return;
                }

                char glyph = parms[1][0];

                // set the texcoords for this glyph
                font.SetGlyphTexCoords(
                    glyph,
                    StringConverter.ParseFloat(parms[2]),
                    StringConverter.ParseFloat(parms[3]),
                    StringConverter.ParseFloat(parms[4]),
                    StringConverter.ParseFloat(parms[5]));

                break;

            case "size":
                if (parms.Length != 2)
                {
                    ParseHelper.LogParserError("size", font.Name, "Invalid number of params.");
                    return;
                }

                font.TrueTypeSize = int.Parse(parms[1]);

                break;

            case "resolution":
                if (parms.Length != 2)
                {
                    ParseHelper.LogParserError("resolution", font.Name, "Invalid number of params.");
                    return;
                }

                font.TrueTypeResolution = int.Parse(parms[1]);

                break;

            case "antialias_colour":
                if (parms.Length != 2)
                {
                    ParseHelper.LogParserError("antialias_colour", font.Name, "Invalid number of params.");
                    return;
                }

                font.AntialiasColor = bool.Parse(parms[1]);

                break;
            }
        }