Bloom.MiscUI.LanguageFontDetails.LoadFontCombo C# (CSharp) Method

LoadFontCombo() private method

private LoadFontCombo ( ) : void
return void
        private void LoadFontCombo()
        {
            // Display the fonts in sorted order.
            var fontNames = new List<string>();
            fontNames.AddRange(Browser.NamesOfFontsThatBrowserCanRender());
            fontNames.Sort();
            var defaultFont = CollectionSettings.GetDefaultFontName();
            foreach (var font in fontNames)
            {
                _fontCombo.Items.Add(font);
                if (font == defaultFont)
                    _fontCombo.SelectedItem = font;
            }

            // Make the font combobox wide enough to display the longest value.
            int width = _fontCombo.DropDownWidth;
            using (Graphics g = _fontCombo.CreateGraphics())
            {
                Font font = _fontCombo.Font;
                int vertScrollBarWidth = (_fontCombo.Items.Count > _fontCombo.MaxDropDownItems) ? SystemInformation.VerticalScrollBarWidth : 0;

                width = (from string s in _fontCombo.Items select (int)g.MeasureString(s, font).Width).Concat(new[] { width }).Max() + vertScrollBarWidth;
            }
            _fontCombo.DropDownWidth = width;
        }