예제 #1
0
        private static bool isNextInLine(CoordinateText ct, CoordinateText ctNext)
        {
            if (ct.Coordinate.Y != ctNext.Coordinate.Y)
            {
                if (ctNext.Coordinate.X < ct.Coordinate.X)
                {
                    return(false);
                }
                else
                {
                    if (ct.Coordinate.Y - ct.TextHeight / 2 < ctNext.Coordinate.Y)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
예제 #2
0
        private static int mergeString(CoordinateText ct, CoordinateText ctNext)
        {
            if (ct.TextWidth > ctNext.TextWidth)
            {
                int indexCt     = (int)((float)Math.Abs(ctNext.Coordinate.X - ct.Coordinate.X) * ct.Text.Length / ct.TextWidth);
                int indexCtNext = 0;

                if (Math.Abs(ct.Coordinate.X - ctNext.Coordinate.X) < eps())
                {
                    indexCt = 0;
                }

                for (; indexCt < ct.Text.Length && indexCtNext < ctNext.Text.Length; ++indexCt, ++indexCtNext)
                {
                    if (!isSpace(ctNext.Text[indexCtNext]))
                    {
                        ct.Text[indexCt] = ctNext.Text[indexCtNext];
                    }
                }
                for (; indexCtNext < ctNext.Text.Length; ++indexCtNext)
                {
                    ct.Text.Append(ctNext.Text[indexCtNext]);
                }
                if (ctNext.Coordinate.X + ctNext.TextWidth > ct.Coordinate.X + ct.TextWidth)
                {
                    ct.TextWidth += ctNext.Coordinate.X + ctNext.TextWidth - (ct.Coordinate.X + ct.TextWidth);
                }
                return(0);
            }
            else if (ct.TextWidth < ctNext.TextWidth)
            {
                int indexCt     = (int)((float)Math.Abs(ctNext.Coordinate.X - ct.Coordinate.X) * ct.Text.Length / ct.TextWidth);
                int indexCtNext = 0;

                if (Math.Abs(ct.Coordinate.X - ctNext.Coordinate.X) < eps())
                {
                    indexCt = 0;
                }

                for (; indexCt < ct.Text.Length && indexCtNext < ctNext.Text.Length; ++indexCt, ++indexCtNext)
                {
                    if (!isSpace(ct.Text[indexCt]))
                    {
                        ctNext.Text[indexCtNext] = ct.Text[indexCt];
                    }
                }

                indexCt = (int)((float)Math.Abs(ctNext.Coordinate.X - ct.Coordinate.X) * ct.Text.Length / ct.TextWidth);

                for (int i = 0; i < indexCt; ++i)
                {
                    ctNext.Text.Insert(0, ct.Text[i]);
                }
                ctNext.TextWidth += ctNext.Coordinate.X - ct.Coordinate.X;
                return(1);
            }

            if (getCountSpace(ct.Text.ToString()) < getCountSpace(ctNext.Text.ToString()))
            {
                return(0);
            }

            return(1);
        }