Beispiel #1
0
        public void Font_GetTextExtent(string family, float size, int width, int height)
        {
            using Font font = new Font(family, size);
            if (font.Name != family)
            {
                // Not installed on this machine
                return;
            }

            using WindowsFont windowsFont = WindowsFont.FromFont(font, Gdi32.QUALITY.CLEARTYPE);
            WindowsGraphics graphics = WindowsGraphicsCacheManager.MeasurementGraphics;
            Size            extent   = graphics.GetTextExtent("Whizzo Butter", windowsFont);

            Assert.Equal(width, extent.Width);
            Assert.Equal(height, extent.Height);
        }