Example #1
0
        /// <summary>
        /// Method to draw a string on a <see cref="GraphicsPath"/> of a string
        /// </summary>
        /// <param name="graphics">The <see cref="Graphics"/> object to use</param>
        /// <param name="s">The string to measure</param>
        /// <param name="font">The <see cref="Font"/> to use</param>
        /// <param name="brush">The <see cref="Brush"/> to use</param>
        /// <param name="textPathAlign">The horizontal position on the <paramref name="graphicsPath"/></param>
        /// <param name="textPathPosition">The vertical position on the <paramref name="graphicsPath"/></param>
        /// <param name="letterSpace">A value controlling the spacing between letters</param>
        /// <param name="rotateDegree">A value controlling the rotation of <paramref name="s"/></param>
        /// <param name="graphicsPath">The <see cref="GraphicsPath"/> along which to render.</param>
        /// <param name="angles">A list of angle values (in degrees), one for each letter</param>
        /// <param name="pointsText">A list of positions, one for each letter</param>
        /// <param name="pointsUp">A list of points (don't know what for)</param>
        public static RectangleF[] MeasureString(IGraphics graphics, string s, Font font, Brush brush,
                                                 TextPathAlign textPathAlign, TextPathPosition textPathPosition,
                                                 int letterSpace, float rotateDegree, GraphicsPath graphicsPath,
                                                 ref List <float> angles, ref List <PointF> pointsText,
                                                 ref List <Point> pointsUp)
        {
            TextOnPath top = TextOnPath.TextOnPathInstance;

            top.Text                  = s;
            top.Font                  = font;
            top.FillColorTop          = brush;
            top.TextPathPathPosition  = textPathPosition;
            top.TextPathAlignTop      = textPathAlign;
            top.PathDataTop           = graphicsPath.PathData;
            top.LetterSpacePercentage = letterSpace;
            top.Graphics              = graphics;
            top.GraphicsPath          = graphicsPath;
            top.MeasureString         = true;
            top.RotateDegree          = rotateDegree;
            top.DrawTextOnPath();
            angles     = top.Angles;
            pointsText = top.PointsText;
            pointsUp   = top.PointsTextUp;
            return(top.RegionList.ToArray());
        }