コード例 #1
0
 /// <summary>
 /// See whether this is a better match to the specified matching target style
 /// </summary>
 /// <param name="target">matching target style</param>
 /// <param name="best">current best match</param>
 /// <param name="matching">matching style</param>
 internal static bool IsBetterMatch(
     MatchingStyle target,
     MatchingStyle best,
     ref MatchingStyle matching
     )
 {
     return(matching.IsBetterMatch(target, best));
 }
コード例 #2
0
        /// <summary>
        /// Find the face most closely matching the specified style, weight and stretch.
        /// Returns CachedFontFace.Null if there is no available face.
        /// </summary>
        private CachedFontFace FindNearestTypeface(FontStyle style, FontWeight weight, FontStretch stretch)
        {
            if (_cachedFamily.NumberOfFaces == 0)
            {
                return(CachedFontFace.Null);
            }

            MatchingStyle  target    = new MatchingStyle(style, weight, stretch);
            CachedFontFace bestFace  = _cachedFamily.FamilyCollection.GetCachedFace(_cachedFamily, 0);
            MatchingStyle  bestMatch = bestFace.MatchingStyle;

            for (int i = 1; i < _cachedFamily.NumberOfFaces; i++)
            {
                CachedFontFace currentFace  = _cachedFamily.FamilyCollection.GetCachedFace(_cachedFamily, i);
                MatchingStyle  currentMatch = currentFace.MatchingStyle;
                if (MatchingStyle.IsBetterMatch(target, bestMatch, ref currentMatch))
                {
                    bestMatch = currentMatch;
                    bestFace  = currentFace;
                }
            }

            return(bestFace);
        }
コード例 #3
0
 /// <summary>
 /// See whether this is a better match to the specified matching target style
 /// </summary>
 /// <param name="target">matching target style</param>
 /// <param name="best">current best match</param>
 /// <param name="matching">matching style</param>
 internal static bool IsBetterMatch(
     MatchingStyle           target,
     MatchingStyle           best,
     ref MatchingStyle       matching
     )
 {
     return matching.IsBetterMatch(target, best);
 }