Newer
Older
ClosedXML / ClosedXML / Utils / GraphicsUtils.cs
@Francois Botha Francois Botha on 30 May 2017 769 bytes Unknown changes - something to do with line endings?
using System;
using System.Drawing;

namespace ClosedXML.Utils
{
    internal static class GraphicsUtils
    {
        [ThreadStatic]
        private static Graphics threadLocalGraphics;
        internal static Graphics Graphics
        {
            get
            {
                if (threadLocalGraphics == null)
                {
                    var image = new Bitmap(1, 1);
                    threadLocalGraphics = Graphics.FromImage(image);
                }
                return threadLocalGraphics;
            }
        }

        public static SizeF MeasureString(string s, Font font)
        {
            SizeF result = Graphics.MeasureString(s, font, Int32.MaxValue, StringFormat.GenericTypographic);
            return result;
        }
    }
}