Example #1
0
        internal static Graphics.Size MeasureText(DrawingContext dc, string text, string fontName, float fontSize, Drawing.Text.FontStyles style)
        {
            ResourcePoolManager resManager = dc.Renderer.ResourcePoolManager;

            var font = resManager.GetFont(fontName, fontSize, ToWFFontStyle(style));

            if (font == null)
            {
                return(Graphics.Size.Zero);
            }

            var g = ResourcePoolManager.CachedGDIGraphics;

            lock (g)
            {
                lock (sf)
                {
                    var size = ResourcePoolManager.CachedGDIGraphics.MeasureString(text, font, 99999999, sf);

                    size.Width  += 2;
                    size.Height += 2;

                    return(size);
                }
            }
        }