Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Avalonia.Media.FontFamily" /> class.
        /// </summary>
        /// <param name="baseUri">Specifies the base uri that is used to resolve font family assets.</param>
        /// <param name="name">The name of the <see cref="T:Avalonia.Media.FontFamily" />.</param>
        /// <exception cref="T:System.ArgumentException">Base uri must be an absolute uri.</exception>
        public FontFamily(Uri?baseUri, string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var fontFamilySegment = GetFontFamilyIdentifier(name);

            if (fontFamilySegment.Source != null)
            {
                if (baseUri != null && !baseUri.IsAbsoluteUri)
                {
                    throw new ArgumentException("Base uri must be an absolute uri.", nameof(baseUri));
                }

                Key = new FontFamilyKey(fontFamilySegment.Source, baseUri);
            }

            FamilyNames = new FamilyNameCollection(fontFamilySegment.Name);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Avalonia.Media.FontFamily" /> class.
        /// </summary>
        /// <param name="names">The names of the <see cref="FontFamily"/>.</param>
        /// <exception cref="T:System.ArgumentNullException">name</exception>
        public FontFamily(IEnumerable <string> names)
        {
            Contract.Requires <ArgumentNullException>(names != null);

            FamilyNames = new FamilyNameCollection(names);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Avalonia.Media.FontFamily" /> class.
        /// </summary>
        /// <param name="name">The name of the <see cref="FontFamily"/>.</param>
        /// <exception cref="T:System.ArgumentNullException">name</exception>
        public FontFamily(string name)
        {
            Contract.Requires <ArgumentNullException>(name != null);

            FamilyNames = new FamilyNameCollection(new[] { name });
        }
        public void Should_Be_Equal()
        {
            var familyNames = new FamilyNameCollection("Arial, Times New Roman");

            Assert.Equal(new FamilyNameCollection("Arial, Times New Roman"), familyNames);
        }
        public void Should_Be_Equal()
        {
            var familyNames = new FamilyNameCollection(new[] { "Arial", "Times New Roman" });

            Assert.Equal(new FamilyNameCollection(new[] { "Arial", "Times New Roman" }), familyNames);
        }