コード例 #1
0
ファイル: Class1.cs プロジェクト: KevinEdelmann/HideOut
        public FontRenderer (FontFile fontFile, Texture2D fontTexture)
        {
                _fontFile = fontFile;
                _texture = fontTexture;
                _characterMap = new Dictionary<char, FontChar>();

                foreach(var fontCharacter in _fontFile.Chars)
                {
                        char c = (char)fontCharacter.ID;
                        _characterMap.Add(c, fontCharacter);
                }
        }
コード例 #2
0
ファイル: Font.cs プロジェクト: Zoxive/TrueCraft
        /// <summary>
        /// 
        /// </summary>
        /// <param name="contentManager"></param>
        private void LoadContent(ContentManager contentManager)
        {
            var definitionPath = string.Format("{0}_{1}.fnt", Name, Style);
            using (var contents = File.OpenRead(Path.Combine(contentManager.RootDirectory, definitionPath)))
                _definition = FontLoader.Load(contents);

            if (_textures != null)
            {
                for (int i = 0; i < _textures.Length; i++)
                {
                    _textures[i].Dispose();
                }
            }

            // We need to support multiple texture pages for more than plain ASCII text.
            _textures = new Texture2D[_definition.Pages.Count];
            for (int i = 0; i < _definition.Pages.Count; i++)
            {
                var texturePath = string.Format("{0}_{1}_{2}.png", Name, Style, i);
                _textures[i] = contentManager.Load<Texture2D>(texturePath);
            }
        }
コード例 #3
0
ファイル: SpriteFont.BMFont.cs プロジェクト: temik911/audio
 public static void Save( Stream stream, FontFile file )
 {
     XmlSerializer serializer = new XmlSerializer( typeof( FontFile ) );
     StreamWriter textWriter = new StreamWriter( stream );
     serializer.Serialize( textWriter, file );
     textWriter.Close();
 }
コード例 #4
0
			public static string SaveToString ( FontFile file )
			{
				XmlSerializer serializer = new XmlSerializer( typeof( FontFile ) );
				var sb = new StringBuilder();
				TextWriter textWriter = new StringWriter( sb );
				serializer.Serialize( textWriter, file );
				return sb.ToString();
				//textWriter.Close();
			}