Пример #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (obj.GetType() != typeof(DXFontStyle))
            {
                return(false);
            }
            DXFontStyle other = (DXFontStyle)obj;

            return(_id == other._id);
        }
Пример #2
0
 internal void AddStyle(DXFontStyle style)
 {
     _fontStyles = null;
     _styleList.Add(style);
 }
Пример #3
0
        public IFontFamily[] Initialize()
        {
            var familyList = new List <DXFontFamily>();
            var families   = new Dictionary <string, DXFontFamily>();

            var fontCollection = DXGraphicsService.FactoryDirectWrite.GetSystemFontCollection(false);
            int familyCount    = fontCollection.FontFamilyCount;

            for (int i = 0; i < familyCount; i++)
            {
                var fontFamily  = fontCollection.GetFontFamily(i);
                var familyNames = fontFamily.FamilyNames;

                if (!familyNames.FindLocaleName("en-us", out var index))
                {
                    index = 0;
                }
                var familyName = familyNames.GetString(index);

                for (int j = 0; j < fontFamily.FontCount; j++)
                {
                    string postScriptName = familyName;

                    var font = fontFamily.GetFont(j);

                    var found = font.GetInformationalStrings(InformationalStringId.PostscriptName,
                                                             out var localizedPostScriptName);
                    if (found)
                    {
                        postScriptName = localizedPostScriptName.GetString(0);
                    }

                    if (!families.TryGetValue(familyName, out var family))
                    {
                        family = new DXFontFamily(familyName);
                        families[familyName] = family;
                        familyList.Add(family);
                    }

                    var id = postScriptName;
                    if (!font.FaceNames.FindLocaleName("en-us", out index))
                    {
                        index = 0;
                    }

                    var name = font.FaceNames.GetString(index);

                    var fullName = familyName;
                    if (!("Regular".Equals(name) || "Plain".Equals(name) || "Normal".Equals(name)))
                    {
                        fullName = string.Format("{0} {1}", familyName, name);
                    }

                    var fontFace = new FontFace(font);
                    var style    = new DXFontStyle(family, id, name, fullName, font.Style, font.Weight, fontFace);
                    family.AddStyle(style);
                }
            }

            familyList.Sort();

            foreach (var family in familyList)
            {
                family.RemoveDuplicates();
            }

            return(familyList.OfType <IFontFamily>().ToArray());
        }