Ejemplo n.º 1
0
        /// <summary>
        /// Create a FontFamilyIdentifier by concatenating two existing identifiers.
        /// </summary>
        internal FontFamilyIdentifier(FontFamilyIdentifier first, FontFamilyIdentifier second)
        {
            first.Canonicalize();
            second.Canonicalize();

            _friendlyName = null;
            _tokenCount   = first._tokenCount + second._tokenCount;
            _baseUri      = null;

            if (first._tokenCount == 0)
            {
                _canonicalReferences = second._canonicalReferences;
            }
            else if (second._tokenCount == 0)
            {
                _canonicalReferences = first._canonicalReferences;
            }
            else
            {
                _canonicalReferences = new CanonicalFontFamilyReference[_tokenCount];

                int i = 0;
                foreach (CanonicalFontFamilyReference family in first._canonicalReferences)
                {
                    _canonicalReferences[i++] = family;
                }
                foreach (CanonicalFontFamilyReference family in second._canonicalReferences)
                {
                    _canonicalReferences[i++] = family;
                }
            }
        }
Ejemplo n.º 2
0
        public bool Equals(FontFamilyIdentifier other)
        {
            if (_friendlyName == other._friendlyName && _baseUri == other._baseUri)
            {
                return(true);
            }

            int c = Count;

            if (other.Count != c)
            {
                return(false);
            }

            if (c != 0)
            {
                Canonicalize();
                other.Canonicalize();

                for (int i = 0; i < c; ++i)
                {
                    if (!_canonicalReferences[i].Equals(other._canonicalReferences[i]))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        /// <summary> 
        /// Constructs FontFamily from a string and an optional base URI.
        /// </summary> 
        /// <param name="baseUri">Specifies the base URI used to resolve family names, typically 
        /// the URI of the document or element that refers to the font family. Can be null.</param>
        /// <param name="familyName">Specifies one or more comma-separated family names, each 
        /// of which may be either a regular family name string (e.g., "Arial") or a URI
        /// (e.g., "file:///c:/windows/fonts/#Arial").</param>
        public FontFamily(Uri baseUri, string familyName)
        { 
            if (familyName == null)
                throw new ArgumentNullException("familyName"); 
 
            if (baseUri != null && !baseUri.IsAbsoluteUri)
                throw new ArgumentException(SR.Get(SRID.UriNotAbsolute), "baseUri"); 

            _familyIdentifier = new FontFamilyIdentifier(familyName, baseUri);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Scan the friendly name string finding the first valid font family
        /// </summary> 
        internal static IFontFamily FindFontFamilyFromFriendlyNameList(string friendlyNameList)
        { 
            IFontFamily firstFontFamily = null; 

            // Split limits the number of tokens in a family name. 
            FontFamilyIdentifier identifier = new FontFamilyIdentifier(friendlyNameList, null);
            for (int i = 0, c = identifier.Count; firstFontFamily == null && i < c; i++)
            {
                firstFontFamily = LookupFontFamily(identifier[i]); 
            }
 
            if (firstFontFamily == null) 
            {
                // cannot find first font family, assume null font for first font family 
                firstFontFamily = LookupFontFamily(NullFontFamilyCanonicalName);

                // null font family should always exist
                Invariant.Assert(firstFontFamily != null); 

            } 
 
            return firstFontFamily;
        } 
Ejemplo n.º 5
0
 /// <summary>
 /// Construct an anonymous font family, i.e., a composite font that is created
 /// programatically instead of referenced by name or URI.
 /// </summary> 
 public FontFamily()
 { 
     _familyIdentifier = new FontFamilyIdentifier(null, null); 
     _firstFontFamily = new CompositeFontFamily();
 } 
Ejemplo n.º 6
0
 internal FontFamily(FontFamilyIdentifier familyIdentifier)
 { 
     _familyIdentifier = familyIdentifier; 
 }
Ejemplo n.º 7
0
 ICollection<Typeface> IFontFamily.GetTypefaces(FontFamilyIdentifier familyIdentifier)
 {
     return new TypefaceCollection(new FontFamily(familyIdentifier), FamilyTypefaces);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Create a FontFamilyIdentifier by concatenating two existing identifiers.
        /// </summary>
        internal FontFamilyIdentifier(FontFamilyIdentifier first, FontFamilyIdentifier second)
        {
            first.Canonicalize();
            second.Canonicalize();

            _friendlyName = null;
            _tokenCount = first._tokenCount + second._tokenCount;
            _baseUri = null;

            if (first._tokenCount == 0)
            {
                _canonicalReferences = second._canonicalReferences;
            }
            else if (second._tokenCount == 0)
            {
                _canonicalReferences = first._canonicalReferences;
            }
            else
            {
                _canonicalReferences = new CanonicalFontFamilyReference[_tokenCount];

                int i = 0;
                foreach (CanonicalFontFamilyReference family in first._canonicalReferences)
                {
                    _canonicalReferences[i++] = family;
                }
                foreach (CanonicalFontFamilyReference family in second._canonicalReferences)
                {
                    _canonicalReferences[i++] = family;
                }
            }
        }
Ejemplo n.º 9
0
        public bool Equals(FontFamilyIdentifier other)
        {
            if (_friendlyName == other._friendlyName && _baseUri == other._baseUri)
                return true;

            int c = Count;
            if (other.Count != c)
                return false;

            if (c != 0)
            {
                Canonicalize();
                other.Canonicalize();

                for (int i = 0; i < c; ++i)
                {
                    if (!_canonicalReferences[i].Equals(other._canonicalReferences[i]))
                        return false;
                }
            }

            return true;
        }
Ejemplo n.º 10
0
 ICollection <Typeface> IFontFamily.GetTypefaces(FontFamilyIdentifier familyIdentifier)
 {
     return(new TypefaceCollection(new FontFamily(familyIdentifier), _family));
 }