Пример #1
0
        public TypefaceListItem(Typeface typeface)
        {
            _displayName = GetDisplayName(typeface);
            _simulated   = typeface.IsBoldSimulated || typeface.IsObliqueSimulated;

            FontFamily  = typeface.FontFamily;
            FontWeight  = typeface.Weight;
            FontStyle   = typeface.Style;
            FontStretch = typeface.Stretch;

            var itemLabel = _displayName;

            if (_simulated)
            {
                var formatString = Properties.Resources.ResourceManager.GetString(
                    "simulated",
                    CultureInfo.CurrentUICulture
                    );
                itemLabel = string.Format(formatString, itemLabel);
            }

            Text    = itemLabel;
            ToolTip = itemLabel;

            // In the case of symbol font, apply the default message font to the text so it can be read.
            if (FontFamilyListItem.IsSymbolFont(typeface.FontFamily))
            {
                var range = new TextRange(ContentStart, ContentEnd);
                range.ApplyPropertyValue(FontFamilyProperty, SystemFonts.MessageFontFamily);
            }
        }
Пример #2
0
        private void InitializeFontFamilyList()
        {
            var familyCollection = FontFamilyCollection;
            if (familyCollection != null)
            {
                var items = new FontFamilyListItem[familyCollection.Count];

                var i = 0;

                foreach (var family in familyCollection)
                {
                    items[i++] = new FontFamilyListItem(family);
                }

                Array.Sort(items);

                foreach (var item in items)
                {
                    fontFamilyList.Items.Add(item);
                }
            }
        }