예제 #1
0
        /// <summary>
        /// Initialize all manangers and informations.
        /// </summary>
        protected override void Initialize()
        {
            //  Creates debug font
            debugFont = FontManager.CreateFont("DebugFont", "Font/SmallArial");

            //  Initialize input manager
            InputManager.Initialize();

            //  Initialize viewer
            Viewer.Initialize();

            //  Initialize text manager
            TextManager.Initialize();

            //  Initialize FPS counter
            FpsCounter.Initialize();

            //  Add FPS info
            Vector2 pos = new Vector2(0, 0);

            pos = ClampSafeArea(pos);

            textFPS = TextManager.AddText(debugFont,
                                          string.Format("FPS : {0}", FrameworkCore.FpsCounter.Fps.ToString()),
                                          (int)pos.X, (int)pos.Y, Color.White);
#if DEBUG
            textFPS.Visible = true;
#else
            textFPS.Visible = false;
#endif

            base.Initialize();

            System.Diagnostics.Debug.WriteLine("Framework Initialize OK...");
        }
예제 #2
0
        //[Ignore("For some reason the font isn't loading correctly. Can't figure it out right now.")]
        public void FontUtilTest()
        {
            using (var mgr = new FontManager())
            {
                mgr.RegisterFont(My.Resources.Drift);
                var fontName = "Drift Wood";
                var fontSize = 40;

                var fam = mgr.GetFamily(fontName);
                Assert.AreEqual(fontName, fam.Name);
                Assert.IsTrue(fam.IsStyleAvailable(FontStyle.Regular));

                using (var myfont = mgr.CreateFont(fontName, fontSize, FontStyle.Regular, GraphicsUnit.Point))
                    //using (var myfont = new  Font(fam, fontSize, FontStyle.Regular, GraphicsUnit.Point))
                    using (var bmp = new Bitmap(500, 500))
                        using (var g = Graphics.FromImage(bmp))
                        {
                            Assert.AreEqual(fontSize, myfont.Size);
                            Assert.AreEqual(fontName, myfont.Name);

                            g.FillRectangle(Brushes.White, 0, 0, bmp.Width, bmp.Height);

                            // Make sure we can use the font.
                            g.DrawString("Hello World!", myfont, Brushes.Black, 10, 10);

                            // Uncomment the following line to visually confirm if the font was used or not.
                            // Do not check this line in since there is nobody to look at the generated file on the test servers
                            // and it might fail.
                            //var path = bmp.Save();
                            //Console.WriteLine(path);
                        }
            }
        }