#region License /* FNA - XNA4 Reimplementation for Desktop Platforms * Copyright 2009-2016 Ethan Lee and the MonoGame Team * * Released under the Microsoft Public License. * See LICENSE for details. */ /* Derived from code by the Mono.Xna Team (Copyright 2006). * Released under the MIT License. See monoxna.LICENSE for details. */ #endregion #region Using Statements using System.Collections.Generic; using Microsoft.Xna.Framework.Graphics; #endregion namespace Microsoft.Xna.Framework.Content { internal class SpriteFontReader : ContentTypeReader { #region Internal Constructor internal SpriteFontReader() { } #endregion #region Protected Read Method protected internal override SpriteFont Read( ContentReader input, SpriteFont existingInstance ) { if (existingInstance != null) { // Read the texture into the existing texture instance input.ReadObject(existingInstance.textureValue); /* Discard the rest of the SpriteFont data as we are only * reloading GPU resources for now */ input.ReadObject>(); input.ReadObject>(); input.ReadObject>(); input.ReadInt32(); input.ReadSingle(); input.ReadObject>(); if (input.ReadBoolean()) { input.ReadChar(); } return existingInstance; } else { // Create a fresh SpriteFont instance Texture2D texture = input.ReadObject(); List glyphs = input.ReadObject>(); List cropping = input.ReadObject>(); List charMap = input.ReadObject>(); int lineSpacing = input.ReadInt32(); float spacing = input.ReadSingle(); List kerning = input.ReadObject>(); char? defaultCharacter = null; if (input.ReadBoolean()) { defaultCharacter = new char?(input.ReadChar()); } return new SpriteFont( texture, glyphs, cropping, charMap, lineSpacing, spacing, kerning, defaultCharacter ); } } #endregion } }