Exemple #1
0
 protected internal override SpriteFont Read(ContentReader input, SpriteFont existingInstance)
 {
     if (existingInstance != null)
     {
         input.ReadObject <Texture2D>(existingInstance._texture);
         input.ReadObject <List <Rectangle> >();
         input.ReadObject <List <Rectangle> >();
         input.ReadObject <List <char> >();
         input.ReadInt32();
         double num1 = (double)input.ReadSingle();
         input.ReadObject <List <Vector3> >();
         if (input.ReadBoolean())
         {
             int num2 = (int)input.ReadChar();
         }
         return(existingInstance);
     }
     else
     {
         Texture2D        texture        = input.ReadObject <Texture2D>();
         List <Rectangle> glyphBounds    = input.ReadObject <List <Rectangle> >();
         List <Rectangle> cropping       = input.ReadObject <List <Rectangle> >();
         List <char>      characters     = input.ReadObject <List <char> >();
         int            lineSpacing      = input.ReadInt32();
         float          spacing          = input.ReadSingle();
         List <Vector3> kerning          = input.ReadObject <List <Vector3> >();
         char?          defaultCharacter = new char?();
         if (input.ReadBoolean())
         {
             defaultCharacter = new char?(input.ReadChar());
         }
         return(new SpriteFont(texture, glyphBounds, cropping, characters, lineSpacing, spacing, kerning, defaultCharacter));
     }
 }
        protected internal override SpriteFont Read(
            ContentReader input,
            SpriteFont existingInstance
            )
        {
            if (existingInstance != null)
            {
                // Read the texture into the existing texture instance
                input.ReadObject <Texture2D>(existingInstance.textureValue);

                /* Discard the rest of the SpriteFont data as we are only
                 * reloading GPU resources for now
                 */
                input.ReadObject <List <Rectangle> >();
                input.ReadObject <List <Rectangle> >();
                input.ReadObject <List <char> >();
                input.ReadInt32();
                input.ReadSingle();
                input.ReadObject <List <Vector3> >();
                if (input.ReadBoolean())
                {
                    input.ReadChar();
                }
                return(existingInstance);
            }
            else
            {
                // Create a fresh SpriteFont instance
                Texture2D        texture        = input.ReadObject <Texture2D>();
                List <Rectangle> glyphs         = input.ReadObject <List <Rectangle> >();
                List <Rectangle> cropping       = input.ReadObject <List <Rectangle> >();
                List <char>      charMap        = input.ReadObject <List <char> >();
                int            lineSpacing      = input.ReadInt32();
                float          spacing          = input.ReadSingle();
                List <Vector3> kerning          = input.ReadObject <List <Vector3> >();
                char?          defaultCharacter = null;
                if (input.ReadBoolean())
                {
                    defaultCharacter = new char?(input.ReadChar());
                }
                return(new SpriteFont(
                           texture,
                           glyphs,
                           cropping,
                           charMap,
                           lineSpacing,
                           spacing,
                           kerning,
                           defaultCharacter
                           ));
            }
        }
Exemple #3
0
        public static VGFontData Deserialize(ContentReader reader)
        {
            var data = new VGFontData
            {
                FillRule = (VGFillRule)reader.ReadByte(),
                EmSquareSize = reader.ReadSingle(),
                LeadingSize = reader.ReadSingle(),
                Extents = reader.ReadVector4(),
                Vertices = new StencilVertex[reader.ReadInt32()],
                Glyphs = new VGFontData.GlyphInfo[reader.ReadInt32()]
            };

            for (int i = 0; i < data.Vertices.Length; i++)
                data.Vertices[i] = StencilVertex.Deserialize(reader);

            for (int i = 0; i < data.Glyphs.Length; i++)
                data.Glyphs[i] = new VGFontData.GlyphInfo
                {
                    Character = reader.ReadChar(),
                    Offset = reader.ReadInt32(),
                    Triangles = reader.ReadInt32(),
                    Escape = new Vector2
                    {
                        X = reader.ReadSingle(),
                        Y = reader.ReadSingle()
                    }
                };

            data.Kerning = VGKerningTable.Deserialize(reader);
            return data;
        }
Exemple #4
0
        protected internal override SpriteFont Read(ContentReader input, SpriteFont existingInstance)
        {
            Texture2D texture = input.ReadObject <Texture2D>();

            texture.IsSpriteFontTexture = true;
            List <Rectangle> glyphs         = input.ReadObject <List <Rectangle> >();
            List <Rectangle> cropping       = input.ReadObject <List <Rectangle> >();
            List <char>      charMap        = input.ReadObject <List <char> >();
            int            lineSpacing      = input.ReadInt32();
            float          spacing          = input.ReadSingle();
            List <Vector3> kerning          = input.ReadObject <List <Vector3> >();
            char?          defaultCharacter = null;

            if (input.ReadBoolean())
            {
                defaultCharacter = new char?(input.ReadChar());
            }
            return(new SpriteFont(texture, glyphs, cropping, charMap, lineSpacing, spacing, kerning, defaultCharacter));
        }
Exemple #5
0
 protected internal override char Read(ContentReader input, char existingInstance)
 {
     return(input.ReadChar());
 }