iTextSharp.text.Font.Difference C# (CSharp) Метод

Difference() публичный Метод

Replaces the attributes that are equal to null with the attributes of a given font.
public Difference ( Font font ) : Font
font Font the font of a bigger element class
Результат Font
        public virtual Font Difference(Font font) {
            if (font == null) return this;
            // size
            float dSize = font.size;
            if (dSize == UNDEFINED) {
                dSize = this.size;
            }
            // style
            int dStyle = UNDEFINED;
            int style1 = this.Style;
            int style2 = font.Style;
            if (style1 != UNDEFINED || style2 != UNDEFINED) {
                if (style1 == UNDEFINED) style1 = 0;
                if (style2 == UNDEFINED) style2 = 0;
                dStyle = style1 | style2;
            }
            // color
            object dColor = (Color)font.Color;
            if (dColor == null) {
                dColor = this.Color;
            }
            // family
            if (font.baseFont != null) {
                return new Font(font.BaseFont, dSize, dStyle, (Color)dColor);
            }
            if (font.Family != UNDEFINED) {
                return new Font(font.Family, dSize, dStyle, (Color)dColor);
            }
            if (this.baseFont != null) {
                if (dStyle == style1) {
                    return new Font(this.BaseFont, dSize, dStyle, (Color)dColor);
                }
                else {
                    return FontFactory.GetFont(this.Familyname, dSize, dStyle, (Color)dColor);
                }
            }
            return new Font(this.Family, dSize, dStyle, (Color)dColor);
        }
    }

Usage Example

Пример #1
0
        // overriding some of the ArrayList-methods

        /// <summary>
        /// Adds a Chunk, an Anchor or another Phrase
        /// to this Phrase.
        /// </summary>
        /// <param name="index">index at which the specified element is to be inserted</param>
        /// <param name="o">an object of type Chunk, Anchor, or Phrase</param>
        public virtual void Add(int index, Object o)
        {
            if (o == null)
            {
                return;
            }
            try {
                IElement element = (IElement)o;
                if (element.Type == Element.CHUNK)
                {
                    Chunk chunk = (Chunk)element;
                    if (!font.IsStandardFont())
                    {
                        chunk.Font = font.Difference(chunk.Font);
                    }
                    base.Insert(index, chunk);
                }
                else if (element.Type == Element.PHRASE ||
                         element.Type == Element.ANCHOR ||
                         element.Type == Element.ANNOTATION ||
                         element.Type == Element.TABLE || // line added by David Freels
                         element.Type == Element.GRAPHIC)
                {
                    base.Insert(index, element);
                }
                else
                {
                    throw new Exception(element.Type.ToString());
                }
            }
            catch (Exception cce) {
                throw new Exception("Insertion of illegal Element: " + cce.Message);
            }
        }
All Usage Examples Of iTextSharp.text.Font::Difference