コード例 #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;
                }
            }
        }
コード例 #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);
        }
コード例 #3
0
ファイル: FontFamily.cs プロジェクト: sjyanxin/WPFSource
        /// <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);
        }
コード例 #4
0
ファイル: FontFamily.cs プロジェクト: sjyanxin/WPFSource
        /// <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;
        } 
コード例 #5
0
ファイル: FontFamily.cs プロジェクト: sjyanxin/WPFSource
 /// <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();
 } 
コード例 #6
0
ファイル: FontFamily.cs プロジェクト: sjyanxin/WPFSource
 internal FontFamily(FontFamilyIdentifier familyIdentifier)
 { 
     _familyIdentifier = familyIdentifier; 
 }
コード例 #7
0
ファイル: CompositeFontFamily.cs プロジェクト: JianwenSun/cc
 ICollection<Typeface> IFontFamily.GetTypefaces(FontFamilyIdentifier familyIdentifier)
 {
     return new TypefaceCollection(new FontFamily(familyIdentifier), FamilyTypefaces);
 }
コード例 #8
0
ファイル: FontFamilyIdentifier.cs プロジェクト: JianwenSun/cc
        /// <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;
                }
            }
        }
コード例 #9
0
ファイル: FontFamilyIdentifier.cs プロジェクト: JianwenSun/cc
        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;
        }
コード例 #10
0
 ICollection <Typeface> IFontFamily.GetTypefaces(FontFamilyIdentifier familyIdentifier)
 {
     return(new TypefaceCollection(new FontFamily(familyIdentifier), _family));
 }