Esempio n. 1
0
        /// <summary>
        /// Returns the width of the specified text for the specified font size.
        /// </summary>
        /// <param name="text">The text to measure.</param>
        /// <param name="fontSize">The font size (in pt).</param>
        /// <param name="isBold">The flag indicating if the text is in bold or regular weight.</param>
        /// <returns>The text's width (in mm).</returns>
        public double TextWidth(string text, int fontSize, bool isBold)
        {
            if (isBold)
            {
                return(_boldMetrics.TextWidth(text, fontSize, false));
            }

            double width = 0;
            int    len   = text.Length;

            for (int i = 0; i < len; i++)
            {
                width += CharWidth(text[i]);
            }

            return(width * fontSize / 1000 * PtToMm);
        }
 public double TextWidth(string text, int fontSize, bool isBold)
 {
     return(FontMetrics.TextWidth(text, fontSize, isBold));
 }