Esempio n. 1
0
        public override Dictionary <char, BMPFontCharacter> GetCharacters()
        {
            TextLine line = reader.ReadLine();

            if (line.Id != "chars")
            {
                throw new Exception("Failed to load angel bmp file, unexpected block '" + line.Id + "'");
            }

            uint numChars = line.GetUInt("count") ?? 0;
            Dictionary <char, BMPFontCharacter> chars = new Dictionary <char, BMPFontCharacter>();

            for (int i = 0; i < numChars; i++)
            {
                TextLine cline = reader.ReadLine();
                if (cline.Id != "char")
                {
                    throw new Exception("Failed to load angel bmp file, unexpected block '" + cline.Id + "'");
                }

                uint charId   = cline.GetUInt("id") ?? '\0';
                uint x        = cline.GetUInt("x") ?? 0;
                uint y        = cline.GetUInt("y") ?? 0;
                uint width    = cline.GetUInt("width") ?? 0;
                uint height   = cline.GetUInt("height") ?? 0;
                int  xOffset  = cline.GetInt("xoffset") ?? 0;
                int  yOffset  = cline.GetInt("yoffset") ?? 0;
                int  xAdvance = cline.GetInt("xadvance") ?? 0;
                uint page     = cline.GetUInt("page") ?? 0;
                byte channel  = cline.GetByte("chnl") ?? 0;

                BMPFontCharacter c = new BMPFontCharacter(charId, x, y, width, height,
                                                          xOffset, yOffset, xAdvance, page, channel);

                chars.Add(c.Character, c);
            }

            return(chars);
        }