示例#1
0
        /// <summary>
        /// Compares two CharacterMetrics for equality.
        /// </summary>
        public override bool Equals(object obj)
        {
            CharacterMetrics other = obj as CharacterMetrics;

            // Suppress PRESharp warning that other can be null; apparently PRESharp
            // doesn't understand short circuit evaluation of operator &&.
            #pragma warning disable 6506
            return(other != null &&
                   other._blackBoxWidth == _blackBoxWidth &&
                   other._blackBoxHeight == _blackBoxHeight &&
                   other._leftSideBearing == _leftSideBearing &&
                   other._rightSideBearing == _rightSideBearing &&
                   other._topSideBearing == _topSideBearing &&
                   other._bottomSideBearing == _bottomSideBearing);

            #pragma warning restore 6506
        }
示例#2
0
 unsafe void IDeviceFont.GetAdvanceWidths(
     char *characterString,
     int characterLength,
     double emSize,
     int *pAdvances
     )
 {
     unsafe
     {
         for (int i = 0; i < characterLength; ++i)
         {
             CharacterMetrics metrics = _characterMetrics.GetValue(characterString[i]);
             if (metrics != null)
             {
                 // Side bearings are included in the advance width but are not used as offsets for glyph positioning.
                 pAdvances[i] = Math.Max(0, (int)((metrics.BlackBoxWidth + metrics.LeftSideBearing + metrics.RightSideBearing) * emSize));
             }
             else
             {
                 pAdvances[i] = 0;
             }
         }
     }
 }