iTextSharp.text.html.HtmlUtilities.GetIndexedFontSize C# (CSharp) Метод

GetIndexedFontSize() публичный статический Метод

public static GetIndexedFontSize ( String value, String previous ) : int
value String
previous String
Результат int
        public static int GetIndexedFontSize(String value, String previous)
        {
            // the font is expressed as an index in a series of predefined font sizes
            int sIndex = 0;
            // the font is defined as a relative size
            if (value.StartsWith("+") || value.StartsWith("-")) {
                // fetch the previous value
                if (previous == null)
                    previous = "12";
                int c = (int)float.Parse(previous, CultureInfo.InvariantCulture);
                // look for the nearest font size in the predefined series
                for (int k = FONTSIZES.Length - 1; k >= 0; --k) {
                    if (c >= FONTSIZES[k]) {
                        sIndex = k;
                        break;
                    }
                }
                // retrieve the difference
                int diff =
                    int.Parse(value.StartsWith("+") ?
                        value.Substring(1) : value);
                // apply the difference
                sIndex += diff;
            }
            // the font is defined as an index
            else {
                try {
                    sIndex = int.Parse(value) - 1;
                }
                catch {
                    sIndex = 0;
                }
            }
            if (sIndex < 0)
                sIndex = 0;
            else if (sIndex >= FONTSIZES.Length)
                sIndex = FONTSIZES.Length - 1;
            return FONTSIZES[sIndex];
        }