Example #1
0
        public FontVariant(CanvasFontFace face, string familyName, StorageFile file)
        {
            FontFace   = face;
            Characters = new List <Character>();
            FamilyName = familyName;

            if (file != null)
            {
                IsImported = true;
                FileName   = file.Name;
                Source     = $"{FontFinder.GetAppPath(file)}#{familyName}";
            }
            else
            {
                Source = familyName;
            }

            if (!face.FaceNames.TryGetValue(CultureInfo.CurrentCulture.Name, out string name))
            {
                if (!face.FaceNames.TryGetValue("en-us", out name))
                {
                    if (face.FaceNames.Any())
                    {
                        name = face.FaceNames.FirstOrDefault().Value;
                    }
                    else
                    {
                        name = Utils.GetVariantDescription(face);
                    }
                }
            }

            PreferredName = name;
        }
        public FontVariant(CanvasFontFace face, StorageFile file, DWriteProperties dwProps)
        {
            FontFace   = face;
            FamilyName = dwProps.FamilyName;

            if (file != null)
            {
                IsImported = true;
                FileName   = file.Name;
                Source     = $"{FontFinder.GetAppPath(file)}#{dwProps.FamilyName}";
            }
            else
            {
                Source = dwProps.FamilyName;
            }

            string name = dwProps.FaceName;

            if (String.IsNullOrEmpty(name))
            {
                name = Utils.GetVariantDescription(face);
            }

            DirectWriteProperties = dwProps;
            PreferredName         = name;
            Panose = PanoseParser.Parse(face);
        }