CompareTo() public method

Compares this Font with another
public CompareTo ( Object obj ) : int
obj Object the other Font
return int
Exemplo n.º 1
0
        /// <summary>
        /// Adds a Chunk.
        /// </summary>
        /// <remarks>
        /// This method is a hack to solve a problem I had with phrases that were split between chunks
        /// in the wrong place.
        /// </remarks>
        /// <param name="chunk">a Chunk</param>
        /// <returns>a bool</returns>
        virtual protected bool AddChunk(Chunk chunk)
        {
            Font   f = chunk.Font;
            String c = chunk.Content;

            if (font != null && !font.IsStandardFont())
            {
                f = font.Difference(chunk.Font);
            }
            if (Count > 0 && !chunk.HasAttributes())
            {
                try {
                    Chunk   previous     = (Chunk)this[Count - 1];
                    PdfName previousRole = previous.Role;
                    PdfName chunkRole    = chunk.Role;
                    Boolean sameRole;
                    if (previousRole == null || chunkRole == null)
                    {
                        //Set the value to true if either are null since the overwriting of the role will not matter
                        sameRole = true;
                    }
                    else
                    {
                        sameRole = previousRole.Equals(chunkRole);
                    }
                    if (sameRole && !previous.HasAttributes() && !chunk.HasAccessibleAttributes() && !previous.HasAccessibleAttributes() &&
                        (f == null ||
                         f.CompareTo(previous.Font) == 0) &&
                        previous.Font.CompareTo(f) == 0 &&
                        !"".Equals(previous.Content.Trim()) &&
                        !"".Equals(c.Trim()))
                    {
                        previous.Append(c);
                        return(true);
                    }
                }
                catch {
                }
            }
            Chunk newChunk = new Chunk(c, f);

            newChunk.Attributes           = chunk.Attributes;
            newChunk.role                 = chunk.Role;
            newChunk.accessibleAttributes = chunk.GetAccessibleAttributes();
            if (hyphenation != null && newChunk.GetHyphenation() == null && !newChunk.IsEmpty())
            {
                newChunk.SetHyphenation(hyphenation);
            }
            base.Add(newChunk);
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a Chunk.
        /// </summary>
        /// <remarks>
        /// This method is a hack to solve a problem I had with phrases that were split between chunks
        /// in the wrong place.
        /// </remarks>
        /// <param name="chunk">a Chunk</param>
        /// <returns>a bool</returns>
        virtual protected bool AddChunk(Chunk chunk)
        {
            Font   f = chunk.Font;
            String c = chunk.Content;

            if (font != null && !font.IsStandardFont())
            {
                f = font.Difference(chunk.Font);
            }
            if (Count > 0 && !chunk.HasAttributes())
            {
                try {
                    Chunk previous = (Chunk)this[Count - 1];
                    if (!previous.HasAttributes() && !chunk.HasAccessibleAttributes() &&
                        (f == null ||
                         f.CompareTo(previous.Font) == 0) &&
                        previous.Font.CompareTo(f) == 0 &&
                        !"".Equals(previous.Content.Trim()) &&
                        !"".Equals(c.Trim()))
                    {
                        previous.Append(c);
                        return(true);
                    }
                }
                catch {
                }
            }
            Chunk newChunk = new Chunk(c, f);

            newChunk.Attributes           = chunk.Attributes;
            newChunk.role                 = chunk.Role;
            newChunk.accessibleAttributes = chunk.GetAccessibleAttributes();
            if (hyphenation != null && newChunk.GetHyphenation() == null && !newChunk.IsEmpty())
            {
                newChunk.SetHyphenation(hyphenation);
            }
            base.Add(newChunk);
            return(true);
        }