コード例 #1
0
        /// <summary>
        /// Sets the kerning offset for the specified pair of characters.
        /// </summary>
        /// <param name="pair">The character pair.</param>
        /// <param name="value">The kerning offset to set for the specified pair of characters.</param>
        public void Set(SpriteFontKerningPair pair, Int32 value)
        {
            kerning[pair] = value;

            var c1 = pair.FirstCharacter;

            if (c1 < asciiLookup.Length)
            {
                asciiLookup[c1] = true;
            }
        }
コード例 #2
0
        /// <summary>
        /// Sets the kerning offset for the specified pair of characters.
        /// </summary>
        /// <param name="c1">The first character in the pair.</param>
        /// <param name="c2">The second character in the pair.</param>
        /// <param name="value">The kerning offset to set for the specified pair of characters.</param>
        public void Set(Char c1, Char c2, Int32 value)
        {
            var pair = new SpriteFontKerningPair(c1, c2);

            kerning[pair] = value;

            if (c1 < asciiLookup.Length)
            {
                asciiLookup[c1] = true;
            }
        }
コード例 #3
0
        /// <summary>
        /// Gets a value indicating whether the kerning data contains the specified character pair.
        /// </summary>
        /// <param name="pair">The character pair.</param>
        /// <returns><see langword="true"/> if the kerning data contains the specified character pair; otherwise, <see langword="false"/>.</returns>
        public Boolean Contains(SpriteFontKerningPair pair)
        {
            var c1 = pair.FirstCharacter;

            if (c1 < asciiLookup.Length && !asciiLookup[c1])
            {
                return(false);
            }

            return(kerning.ContainsKey(pair));
        }
コード例 #4
0
        /// <summary>
        /// Gets the kerning offset for the specified pair of characters.
        /// </summary>
        /// <param name="pair">The character pair.</param>
        /// <returns>The kerning offset for the specified pair of characters.</returns>
        public Int32 Get(SpriteFontKerningPair pair)
        {
            if (Char.IsSurrogate(pair.FirstCharacter) || Char.IsSurrogate(pair.SecondCharacter))
            {
                return(0);
            }

            var c1 = pair.FirstCharacter;

            if (c1 < asciiLookup.Length && !asciiLookup[c1])
            {
                return(DefaultAdjustment);
            }

            int offset;

            if (!kerning.TryGetValue(pair, out offset))
            {
                return(DefaultAdjustment);
            }
            return(offset);
        }
コード例 #5
0
 /// <inheritdoc/>
 public Boolean Equals(SpriteFontKerningPair other)
 {
     return
         (this.firstCharacter == other.firstCharacter &&
          this.secondCharacter == other.secondCharacter);
 }
コード例 #6
0
 /// <summary>
 /// Removes the specified character pair from the kerning data.
 /// </summary>
 /// <param name="pair">The character pair.</param>
 /// <returns><see langword="true"/> if the character pair was removed; otherwise, <see langword="false"/>.</returns>
 public Boolean Remove(SpriteFontKerningPair pair)
 {
     return(kerning.Remove(pair));
 }