public void ScriptLayout(Win32DCSafeHandle hdc, FontCache fontCache) { if (this.m_visualRuns == null) { int count = this.m_logicalRuns.Count; if (count != 0) { byte[] array = new byte[count]; int[] array2 = new int[count]; for (int i = 0; i < count; i++) { array[i] = (byte)this.m_logicalRuns[i].ScriptAnalysis.s.uBidiLevel; } int num = Win32.ScriptLayout(count, array, null, array2); if (Win32.Failed(num)) { Marshal.ThrowExceptionForHR(num); } this.m_visualRuns = new List <TextRun>(count); for (int j = 0; j < count; j++) { this.m_visualRuns.Add(null); } for (int k = 0; k < count; k++) { this.m_visualRuns[array2[k]] = this.m_logicalRuns[k]; } int num2 = 0; int l = -1; for (int m = 0; m < count; m++) { TextRun textRun = this.m_visualRuns[m]; textRun.UnderlineHeight = 0; if (textRun.TextRunProperties.TextDecoration == RPLFormat.TextDecorations.Underline) { if (l < 0) { l = m; } int height = textRun.GetHeight(hdc, fontCache); if (height > num2) { num2 = height; } } else if (l >= 0) { for (; l < m; l++) { this.m_visualRuns[l].UnderlineHeight = num2; } num2 = 0; l = -1; } } if (l >= 0) { for (; l < count; l++) { this.m_visualRuns[l].UnderlineHeight = num2; } } } } }