コード例 #1
0
        private static int FindFoldTextPosition_CharacterTrim(TextRun run, Win32DCSafeHandle hdc, FontCache fontCache, float maxWidth)
        {
            string text = run.Text;

            int[] logicalWidths = run.GetLogicalWidths(hdc, fontCache);
            int   i             = 0;

            for (int num = 0; i < text.Length && (float)(num + logicalWidths[i]) <= maxWidth; i++)
            {
                num += logicalWidths[i];
            }
            return(i);
        }
コード例 #2
0
        private static int FindWidthToBreakPosition(TextRun run, Win32DCSafeHandle hdc, FontCache fontCache, float maxWidth, out int width)
        {
            string text = run.Text;

            int[] logicalWidths = run.GetLogicalWidths(hdc, fontCache);
            int   i             = 0;

            for (width = 0; i < text.Length && ((float)(width + logicalWidths[i]) <= maxWidth || (!run.ScriptLogAttr[i].IsWhiteSpace && !run.ScriptLogAttr[i].IsSoftBreak)); i++)
            {
                width += logicalWidths[i];
            }
            return(i);
        }