Example #1
0
        public SizeF MeasureText(String text, Font font)
        {
            // If string is empty, give it some height.
            if (text == String.Empty)
            {
                text = "I";
            }

            SizeF textSize;

            using (Image dummyImage = new Bitmap(1, 1))
            {
                _graphicsWrapper.CreateDrawingSurface(dummyImage, Color.White, Color.Black);
                textSize = _graphicsWrapper.MeasureString(text, font);
            }

            if (DEBUG)
            {
                Console.WriteLine($"TapeMeasure: Text '{text}' is {textSize} pixels long.");
            }

            return(textSize);
        }