Ejemplo n.º 1
0
        /// <summary>
        /// Constructs an <code>InputMethodEvent</code> with the specified
        /// source component, type, time, text, caret, and visiblePosition.
        /// <para>
        /// The offsets of caret and visiblePosition are relative to the current
        /// composed text; that is, the composed text within <code>text</code>
        /// if this is an <code>INPUT_METHOD_TEXT_CHANGED</code> event,
        /// the composed text within the <code>text</code> of the
        /// preceding <code>INPUT_METHOD_TEXT_CHANGED</code> event otherwise.
        /// </para>
        /// <para>Note that passing in an invalid <code>id</code> results in
        /// unspecified behavior. This method throws an
        /// <code>IllegalArgumentException</code> if <code>source</code>
        /// is <code>null</code>.
        ///
        /// </para>
        /// </summary>
        /// <param name="source"> the object where the event originated </param>
        /// <param name="id"> the event type </param>
        /// <param name="when"> a long integer that specifies the time the event occurred </param>
        /// <param name="text"> the combined committed and composed text,
        ///      committed text first; must be <code>null</code>
        ///      when the event type is <code>CARET_POSITION_CHANGED</code>;
        ///      may be <code>null</code> for
        ///      <code>INPUT_METHOD_TEXT_CHANGED</code> if there's no
        ///      committed or composed text </param>
        /// <param name="committedCharacterCount"> the number of committed
        ///      characters in the text </param>
        /// <param name="caret"> the caret (a.k.a. insertion point);
        ///      <code>null</code> if there's no caret within current
        ///      composed text </param>
        /// <param name="visiblePosition"> the position that's most important
        ///      to be visible; <code>null</code> if there's no
        ///      recommendation for a visible position within current
        ///      composed text </param>
        /// <exception cref="IllegalArgumentException"> if <code>id</code> is not
        ///      in the range
        ///      <code>INPUT_METHOD_FIRST</code>..<code>INPUT_METHOD_LAST</code>;
        ///      or if id is <code>CARET_POSITION_CHANGED</code> and
        ///      <code>text</code> is not <code>null</code>;
        ///      or if <code>committedCharacterCount</code> is not in the range
        ///      <code>0</code>..<code>(text.getEndIndex() - text.getBeginIndex())</code> </exception>
        /// <exception cref="IllegalArgumentException"> if <code>source</code> is null
        ///
        /// @since 1.4 </exception>
        public InputMethodEvent(Component source, int id, long when, AttributedCharacterIterator text, int committedCharacterCount, TextHitInfo caret, TextHitInfo visiblePosition) : base(source, id)
        {
            if (id < INPUT_METHOD_FIRST || id > INPUT_METHOD_LAST)
            {
                throw new IllegalArgumentException("id outside of valid range");
            }

            if (id == CARET_POSITION_CHANGED && text != null)
            {
                throw new IllegalArgumentException("text must be null for CARET_POSITION_CHANGED");
            }

            this.When_Renamed = when;
            this.Text_Renamed = text;
            int textLength = 0;

            if (text != null)
            {
                textLength = text.EndIndex - text.BeginIndex;
            }

            if (committedCharacterCount < 0 || committedCharacterCount > textLength)
            {
                throw new IllegalArgumentException("committedCharacterCount outside of valid range");
            }
            this.CommittedCharacterCount_Renamed = committedCharacterCount;

            this.Caret_Renamed           = caret;
            this.VisiblePosition_Renamed = visiblePosition;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Return a StyledParagraph reflecting the insertion of a single character
        /// into the text.  This method will attempt to reuse the given paragraph,
        /// but may create a new paragraph. </summary>
        /// <param name="aci"> an iterator over the text.  The text should be the same as the
        ///     text used to create (or most recently update) oldParagraph, with
        ///     the exception of deleting a single character at deletePos. </param>
        /// <param name="chars"> the characters in aci </param>
        /// <param name="deletePos"> the index where a character was removed </param>
        /// <param name="oldParagraph"> a StyledParagraph for the text in aci before the
        ///     insertion </param>
        public static StyledParagraph DeleteChar(AttributedCharacterIterator aci, char[] chars, int deletePos, StyledParagraph oldParagraph)
        {
            // We will reuse oldParagraph unless there was a length-1 run
            // at deletePos.  We could do more work and check the individual
            // Font and Decoration runs, but we don't right now...
            deletePos -= aci.BeginIndex;

            if (oldParagraph.Decorations == null && oldParagraph.Fonts == null)
            {
                oldParagraph.Length -= 1;
                return(oldParagraph);
            }

            if (oldParagraph.GetRunLimit(deletePos) == deletePos + 1)
            {
                if (deletePos == 0 || oldParagraph.GetRunLimit(deletePos - 1) == deletePos)
                {
                    return(new StyledParagraph(aci, chars));
                }
            }

            oldParagraph.Length -= 1;
            if (oldParagraph.Decorations != null)
            {
                DeleteFrom(deletePos, oldParagraph.DecorationStarts, oldParagraph.Decorations.Count);
            }
            if (oldParagraph.Fonts != null)
            {
                DeleteFrom(deletePos, oldParagraph.FontStarts, oldParagraph.Fonts.Count);
            }
            return(oldParagraph);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates the <code>TextMeasurer</code> after a single character has
        /// been deleted
        /// from the paragraph currently represented by this
        /// <code>TextMeasurer</code>.  After this call, this
        /// <code>TextMeasurer</code> is equivalent to a new <code>TextMeasurer</code>
        /// created from the text;  however, it will usually be more efficient
        /// to update an existing <code>TextMeasurer</code> than to create a new one
        /// from scratch.
        /// </summary>
        /// <param name="newParagraph"> the text of the paragraph after performing
        /// the deletion.  Cannot be null. </param>
        /// <param name="deletePos"> the position in the text where the character was removed.
        /// Must not be less than
        /// the start of <code>newParagraph</code>, and must not be greater than the
        /// end of <code>newParagraph</code>. </param>
        /// <exception cref="IndexOutOfBoundsException"> if <code>deletePos</code> is
        ///         less than the start of <code>newParagraph</code> or greater
        ///         than the end of <code>newParagraph</code> </exception>
        /// <exception cref="NullPointerException"> if <code>newParagraph</code> is
        ///         <code>null</code> </exception>
        public void DeleteChar(AttributedCharacterIterator newParagraph, int deletePos)
        {
            FStart = newParagraph.BeginIndex;
            int end = newParagraph.EndIndex;

            if (end - FStart != FChars.Length - 1)
            {
                InitAll(newParagraph);
            }

            char[] newChars     = new char[end - FStart];
            int    changedIndex = deletePos - FStart;

            System.Array.Copy(FChars, 0, newChars, 0, deletePos - FStart);
            System.Array.Copy(FChars, changedIndex + 1, newChars, changedIndex, end - deletePos);
            FChars = newChars;

            if (FBidi != null)
            {
                FBidi = new Bidi(newParagraph);
                if (FBidi.LeftToRight)
                {
                    FBidi = null;
                }
            }

            FParagraph = StyledParagraph.DeleteChar(newParagraph, FChars, deletePos, FParagraph);
            InvalidateComponents();
        }
Ejemplo n.º 4
0
        public LineBreakMeasurer(AttributedCharacterIterator text)
        {
            //GetGraphics();
            if (text.GetEndIndex() - text.GetBeginIndex() < 1)
            {
                throw new ArgumentException("Text must contain at least one character.");
            }

            this.limit = text.GetEndIndex();
            this.pos   = this.start = text.GetBeginIndex();

            // extract chars
            fChars = new char[text.GetEndIndex() - text.GetBeginIndex()];
            int n = 0;

            for (char c = text.First(); c != DONE; c = text.Next())
            {
                fChars[n++] = c;
            }
            text.First();

            stringFont     = (Font)text.GetAttribute(TextAttribute.FONT);
            stringColor    = (Color)text.GetAttribute(TextAttribute.FOREGROUND);
            characterCount = fChars.Length;
        }
Ejemplo n.º 5
0
        /**
         * Constructs an {@code AttributedString} from an {@code
         * AttributedCharacterIterator}, which represents attributed text.
         *
         * @param iterator
         *            the {@code AttributedCharacterIterator} that contains the text
         *            for this attributed string.
         */
        public AttributedString(AttributedCharacterIterator iterator)
        {
            if (iterator.getBeginIndex() > iterator.getEndIndex()) {
                // text.0A=Invalid substring range
                throw new java.lang.IllegalArgumentException("Invalid substring range"); //$NON-NLS-1$
            }
            StringBuilder buffer = new StringBuilder();
            for (int i = iterator.getBeginIndex(); i < iterator.getEndIndex(); i++) {
                buffer.Append(iterator.current());
                iterator.next();
            }
            text = buffer.ToString();
            java.util.Set<AttributedCharacterIteratorNS.Attribute> attributes = iterator
                    .getAllAttributeKeys();
            if (attributes == null) {
                return;
            }
            attributeMap = new java.util.HashMap<AttributedCharacterIteratorNS.Attribute, java.util.List<IAC_Range>>();//(attributes.size() * 4 / 3) + 1);

            java.util.Iterator<AttributedCharacterIteratorNS.Attribute> it = attributes.iterator();
            while (it.hasNext()) {
                AttributedCharacterIteratorNS.Attribute attribute = it.next();
                iterator.setIndex(0);
                while (iterator.current() != CharacterIteratorConstants.DONE) {
                    int start = iterator.getRunStart(attribute);
                    int limit = iterator.getRunLimit(attribute);
                    System.Object value = iterator.getAttribute(attribute);
                    if (value != null) {
                        addAttribute(attribute, value, start, limit);
                    }
                    iterator.setIndex(limit);
                }
            }
        }
Ejemplo n.º 6
0
        private void SetData(int row, int col, TextLayout layout, AttributedCharacterIterator iter)
        {
            if (layout == null)
            {
                return;
            }
            if (p_sizeCalculated)
            {
                throw new Exception("Size already calculated");
            }
            if (row < 0 || row >= m_rows)
            {
                throw new IndexOutOfRangeException("Row Index=" + row + " Rows=" + m_rows);
            }
            if (col < 0 || col >= m_cols)
            {
                throw new IndexOutOfRangeException("Column Index=" + col + " Cols=" + m_cols);
            }
            //
            m_textLayout[row, col] = layout;
            m_iterator[row, col]   = iter;
            //	Set Size
            int height = layout.GetFont().Height;
            int width  = (int)layout.GetAdvance() + 1;

            if (m_rowHeight[row] < height)
            {
                m_rowHeight[row] = height;
            }
            if (m_colWidth[col] < width)
            {
                m_colWidth[col] = width;
            }
        }       //	setData
Ejemplo n.º 7
0
        public TextLayout(AttributedCharacterIterator text)
        {
            fullText    = text.GetText();
            trimText    = fullText;
            font        = text.GetFont();
            layout      = font.FontFamily;
            stringColor = text.GetColor();

            int start = text.GetBeginIndex();
            int limit = text.GetEndIndex();

            if (start == limit)
            {
                throw new ArgumentException("Zero length iterator passed to TextLayout constructor.");
            }

            int len = limit - start;

            text.First();
            char[] chars = new char[len];
            int    n     = 0;

            for (char c = text.First(); c != DONE; c = text.Next())
            {
                chars[n++] = c;
            }
            GetGraphicLayout(fullText, text.GetFont());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// If fields vector is not null, find and add the fields of this format to
        /// the fields vector by iterating through its AttributedCharacterIterator
        /// </summary>
        ///
        /// <param name="format">the format to find fields for</param>
        /// <param name="arg">object to format</param>
        /// <param name="begin">the index where the string this format has formatted begins</param>
        /// <param name="fields">fields vector, each entry in this vector are of typeFieldContainer.</param>
        private void Handleformat(Format format, Object arg, int begin,
                                  List <FieldContainer> fields)
        {
            if (fields != null)
            {
                AttributedCharacterIterator iterator = format
                                                       .FormatToCharacterIterator(arg);
                while (iterator.GetIndex() != iterator.GetEndIndex())
                {
                    int start_0 = iterator.GetRunStart();
                    int end_1   = iterator.GetRunLimit();

                    IIterator <ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute> it = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute>(new ILOG.J2CsMapping.Collections.Generics.ListSet <ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute>(iterator.GetAttributes().Keys).GetEnumerator());
                    while (it.HasNext())
                    {
                        AttributedCharacterIterator_Constants.Attribute attribute_2 = (AttributedCharacterIterator_Constants.Attribute)it
                                                                                      .Next();
                        Object value_ren = iterator.GetAttribute(attribute_2);
                        fields.Add(new MessageFormat.FieldContainer(begin + start_0, begin + end_1,
                                                                    attribute_2, value_ren));
                    }
                    iterator.SetIndex(end_1);
                }
            }
        }
Ejemplo n.º 9
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder("StringElement[");

            sb.Append("Bounds=").Append(GetBounds())
            .Append(",Height=").Append(p_height).Append("(").Append(p_maxHeight)
            .Append("),Width=").Append(p_width).Append("(").Append(p_maxHeight)
            .Append("),PageLocation=").Append(p_pageLocation).Append(" - ");
            for (int i = 0; i < m_string_paper.Length; i++)
            {
                if (m_string_paper.Length > 1)
                {
                    sb.Append(Env.NL).Append(i).Append(":");
                }
                AttributedCharacterIterator iter = m_string_paper[i].GetIterator();
                for (char c = iter.First(); c != DONE; c = iter.Next())
                {
                    sb.Append(c);
                }
            }
            if (m_ID != null)
            {
                sb.Append(",ID=(").Append(m_ID.ToStringX()).Append(")");
            }
            sb.Append("]");
            return(sb.ToString());
        }       //	toString
Ejemplo n.º 10
0
        /// <summary>
        /// Updates this <code>LineBreakMeasurer</code> after a single
        /// character is deleted from the text, and sets the current
        /// position to the beginning of the paragraph. </summary>
        /// <param name="newParagraph"> the text after the deletion </param>
        /// <param name="deletePos"> the position in the text at which the character
        ///    is deleted </param>
        /// <exception cref="IndexOutOfBoundsException"> if <code>deletePos</code> is
        ///         less than the start of <code>newParagraph</code> or greater
        ///         than the end of <code>newParagraph</code> </exception>
        /// <exception cref="NullPointerException"> if <code>newParagraph</code> is
        ///         <code>null</code> </exception>
        /// <seealso cref= #insertChar </seealso>
        public void DeleteChar(AttributedCharacterIterator newParagraph, int deletePos)
        {
            Measurer.DeleteChar(newParagraph, deletePos);

            Limit = newParagraph.EndIndex;
            Pos   = Start = newParagraph.BeginIndex;

            CharIter.Reset(Measurer.Chars, Start);
            BreakIter.SetText(CharIter);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Updates this <code>LineBreakMeasurer</code> after a single
        /// character is inserted into the text, and sets the current
        /// position to the beginning of the paragraph.
        /// </summary>
        /// <param name="newParagraph"> the text after the insertion </param>
        /// <param name="insertPos"> the position in the text at which the character
        ///    is inserted </param>
        /// <exception cref="IndexOutOfBoundsException"> if <code>insertPos</code> is less
        ///         than the start of <code>newParagraph</code> or greater than
        ///         or equal to the end of <code>newParagraph</code> </exception>
        /// <exception cref="NullPointerException"> if <code>newParagraph</code> is
        ///         <code>null</code> </exception>
        /// <seealso cref= #deleteChar </seealso>
        public void InsertChar(AttributedCharacterIterator newParagraph, int insertPos)
        {
            Measurer.InsertChar(newParagraph, insertPos);

            Limit = newParagraph.EndIndex;
            Pos   = Start = newParagraph.BeginIndex;

            CharIter.Reset(Measurer.Chars, newParagraph.BeginIndex);
            BreakIter.SetText(CharIter);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Create Bidi from the given paragraph of text.
        /// <para>
        /// The RUN_DIRECTION attribute in the text, if present, determines the base
        /// direction (left-to-right or right-to-left).  If not present, the base
        /// direction is computes using the Unicode Bidirectional Algorithm, defaulting to left-to-right
        /// if there are no strong directional characters in the text.  This attribute, if
        /// present, must be applied to all the text in the paragraph.
        /// </para>
        /// <para>
        /// The BIDI_EMBEDDING attribute in the text, if present, represents embedding level
        /// information.  Negative values from -1 to -62 indicate overrides at the absolute value
        /// of the level.  Positive values from 1 to 62 indicate embeddings.  Where values are
        /// zero or not defined, the base embedding level as determined by the base direction
        /// is assumed.
        /// </para>
        /// <para>
        /// The NUMERIC_SHAPING attribute in the text, if present, converts European digits to
        /// other decimal digits before running the bidi algorithm.  This attribute, if present,
        /// must be applied to all the text in the paragraph.
        ///
        /// </para>
        /// </summary>
        /// <param name="paragraph"> a paragraph of text with optional character and paragraph attribute information
        /// </param>
        /// <seealso cref= java.awt.font.TextAttribute#BIDI_EMBEDDING </seealso>
        /// <seealso cref= java.awt.font.TextAttribute#NUMERIC_SHAPING </seealso>
        /// <seealso cref= java.awt.font.TextAttribute#RUN_DIRECTION </seealso>
        public Bidi(AttributedCharacterIterator paragraph)
        {
            if (paragraph == null)
            {
                throw new IllegalArgumentException("paragraph is null");
            }

            BidiBase      = new BidiBase(0, 0);
            BidiBase.Para = paragraph;
        }
Ejemplo n.º 13
0
        /**
         * @see Graphics2D#drawString(AttributedCharacterIterator, float, float)
         */
        public void drawString(AttributedCharacterIterator iter, float x, float y)
        {
            StringBuffer sb = new StringBuffer();

            for (char c = iter.first(); c != AttributedCharacterIterator.DONE; c = iter.next())
            {
                sb.append(c);
            }
            drawString(sb.toString(), x, y);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Create a new StyledParagraph over the given styled text. </summary>
        /// <param name="aci"> an iterator over the text </param>
        /// <param name="chars"> the characters extracted from aci </param>
        public StyledParagraph(AttributedCharacterIterator aci, char[] chars)
        {
            int start = aci.BeginIndex;
            int end   = aci.EndIndex;

            Length = end - start;

            int index = start;

            aci.First();

            do
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int nextRunStart = aci.getRunLimit();
                int nextRunStart = aci.RunLimit;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int localIndex = index-start;
                int localIndex = index - start;

//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
//ORIGINAL LINE: java.util.Map<? extends java.text.AttributedCharacterIterator_Attribute, ?> attributes = aci.getAttributes();
                IDictionary <?, ?> attributes = aci.Attributes;
                attributes = AddInputMethodAttrs(attributes);
                Decoration d = Decoration.getDecoration(attributes);
                AddDecoration(d, localIndex);

                Object f = GetGraphicOrFont(attributes);
                if (f == null)
                {
                    AddFonts(chars, attributes, localIndex, nextRunStart - start);
                }
                else
                {
                    AddFont(f, localIndex);
                }

                aci.Index = nextRunStart;
                index     = nextRunStart;
            } while (index < end);

            // Add extra entries to starts arrays with the length
            // of the paragraph.  'this' is used as a dummy value
            // in the Vector.
            if (Decorations != null)
            {
                DecorationStarts = AddToVector(this, Length, Decorations, DecorationStarts);
            }
            if (Fonts != null)
            {
                FontStarts = AddToVector(this, Length, Fonts, FontStarts);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Constructs a <code>LineBreakMeasurer</code> for the specified text.
        /// </summary>
        /// <param name="text"> the text for which this <code>LineBreakMeasurer</code>
        ///     produces <code>TextLayout</code> objects; the text must contain
        ///     at least one character; if the text available through
        ///     <code>iter</code> changes, further calls to this
        ///     <code>LineBreakMeasurer</code> instance are undefined (except,
        ///     in some cases, when <code>insertChar</code> or
        ///     <code>deleteChar</code> are invoked afterward - see below) </param>
        /// <param name="breakIter"> the <seealso cref="BreakIterator"/> which defines line
        ///     breaks </param>
        /// <param name="frc"> contains information about a graphics device which is
        ///       needed to measure the text correctly;
        ///       text measurements can vary slightly depending on the
        ///       device resolution, and attributes such as antialiasing; this
        ///       parameter does not specify a translation between the
        ///       <code>LineBreakMeasurer</code> and user space </param>
        /// <exception cref="IllegalArgumentException"> if the text has less than one character </exception>
        /// <seealso cref= LineBreakMeasurer#insertChar </seealso>
        /// <seealso cref= LineBreakMeasurer#deleteChar </seealso>
        public LineBreakMeasurer(AttributedCharacterIterator text, BreakIterator breakIter, FontRenderContext frc)
        {
            if (text.EndIndex - text.BeginIndex < 1)
            {
                throw new IllegalArgumentException("Text must contain at least one character.");
            }

            this.BreakIter = breakIter;
            this.Measurer  = new TextMeasurer(text, frc);
            this.Limit     = text.EndIndex;
            this.Pos       = this.Start = text.BeginIndex;

            CharIter = new CharArrayIterator(Measurer.Chars, this.Start);
            this.BreakIter.SetText(CharIter);
        }
Ejemplo n.º 16
0
        private AttributedString(AttributedCharacterIterator iterator, int start_0,
                                 int end_1, ILOG.J2CsMapping.Collections.Generics.ISet <AttributedCharacterIterator_Constants.Attribute> attributes)
        {
            if (start_0 < iterator.GetBeginIndex() || end_1 > iterator.GetEndIndex() ||
                start_0 > end_1)
            {
                throw new ArgumentException();
            }

            if (attributes == null)
            {
                return;
            }

            StringBuilder buffer = new StringBuilder();

            iterator.SetIndex(start_0);
            while (iterator.GetIndex() < end_1)
            {
                buffer.Append(iterator.Current());
                iterator.Next();
            }
            text         = buffer.ToString();
            attributeMap = new Dictionary <AttributedCharacterIterator_Constants.Attribute, IList <Range> >(
                (attributes.Count * 4 / 3) + 1);

            IIterator <AttributedCharacterIterator_Constants.Attribute> it = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute>(attributes.GetEnumerator());

            while (it.HasNext())
            {
                AttributedCharacterIterator_Constants.Attribute attribute = it.Next();
                iterator.SetIndex(start_0);
                while (iterator.GetIndex() < end_1)
                {
                    Object value_ren = iterator.GetAttribute(attribute);
                    int    runStart  = iterator.GetRunStart(attribute);
                    int    limit     = iterator.GetRunLimit(attribute);
                    if ((value_ren is ILOG.J2CsMapping.Util.Annotation && runStart >= start_0 && limit <= end_1) ||
                        (value_ren != null && !(value_ren is ILOG.J2CsMapping.Util.Annotation)))
                    {
                        AddAttribute(attribute, value_ren, ((runStart < start_0) ? start_0
                                : runStart) - start_0, ((limit > end_1) ? end_1 : limit)
                                     - start_0);
                    }
                    iterator.SetIndex(limit);
                }
            }
        }
Ejemplo n.º 17
0
        private AttributedString(AttributedCharacterIterator iterator, int start,
                                 int end, java.util.Set <AttributedCharacterIteratorNS.Attribute> attributes)
        {
            if (start < iterator.getBeginIndex() || end > iterator.getEndIndex() ||
                start > end)
            {
                throw new java.lang.IllegalArgumentException();
            }

            if (attributes == null)
            {
                return;
            }

            StringBuilder buffer = new StringBuilder();

            iterator.setIndex(start);
            while (iterator.getIndex() < end)
            {
                buffer.Append(iterator.current());
                iterator.next();
            }
            text         = buffer.ToString();
            attributeMap = new java.util.HashMap <AttributedCharacterIteratorNS.Attribute, java.util.List <IAC_Range> >();//(attributes.size() * 4 / 3) + 1);

            java.util.Iterator <AttributedCharacterIteratorNS.Attribute> it = attributes.iterator();
            while (it.hasNext())
            {
                AttributedCharacterIteratorNS.Attribute attribute = it.next();
                iterator.setIndex(start);
                while (iterator.getIndex() < end)
                {
                    System.Object value    = iterator.getAttribute(attribute);
                    int           runStart = iterator.getRunStart(attribute);
                    int           limit    = iterator.getRunLimit(attribute);
                    if ((value is java.lang.annotation.Annotation && runStart >= start && limit <= end) ||
                        (value != null && !(value is java.lang.annotation.Annotation)))
                    {
                        addAttribute(attribute, value, (runStart < start ? start
                                : runStart)
                                     - start, (limit > end ? end : limit) - start);
                    }
                    iterator.setIndex(limit);
                }
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Returns an <code>AttributedCharacterIterator</code> that can be used
        /// to iterate over the resulting formatted String.
        ///
        /// @pararm string Result of formatting.
        /// </summary>
        public virtual AttributedCharacterIterator GetIterator(String @string)
        {
            // Add the last AttributedCharacterIterator if necessary
            // assert(size <= string.length());
            if (@string.Length() > Size)
            {
                AttributedStrings.Add(new AttributedString(@string.Substring(Size)));
                Size = @string.Length();
            }
            int iCount = AttributedStrings.Count;

            AttributedCharacterIterator[] iterators = new AttributedCharacterIterator[iCount];

            for (int counter = 0; counter < iCount; counter++)
            {
                iterators[counter] = AttributedStrings[counter].Iterator;
            }
            return((new AttributedString(iterators)).Iterator);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Return a StyledParagraph reflecting the insertion of a single character
        /// into the text.  This method will attempt to reuse the given paragraph,
        /// but may create a new paragraph. </summary>
        /// <param name="aci"> an iterator over the text.  The text should be the same as the
        ///     text used to create (or most recently update) oldParagraph, with
        ///     the exception of inserting a single character at insertPos. </param>
        /// <param name="chars"> the characters in aci </param>
        /// <param name="insertPos"> the index of the new character in aci </param>
        /// <param name="oldParagraph"> a StyledParagraph for the text in aci before the
        ///     insertion </param>
        public static StyledParagraph InsertChar(AttributedCharacterIterator aci, char[] chars, int insertPos, StyledParagraph oldParagraph)
        {
            // If the styles at insertPos match those at insertPos-1,
            // oldParagraph will be reused.  Otherwise we create a new
            // paragraph.

            char ch          = aci.setIndex(insertPos);
            int  relativePos = System.Math.Max(insertPos - aci.BeginIndex - 1, 0);

//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
//ORIGINAL LINE: java.util.Map<? extends java.text.AttributedCharacterIterator_Attribute, ?> attributes = addInputMethodAttrs(aci.getAttributes());
            IDictionary <?, ?> attributes = AddInputMethodAttrs(aci.Attributes);
            Decoration         d          = Decoration.getDecoration(attributes);

            if (!oldParagraph.GetDecorationAt(relativePos).Equals(d))
            {
                return(new StyledParagraph(aci, chars));
            }
            Object f = GetGraphicOrFont(attributes);

            if (f == null)
            {
                FontResolver resolver  = FontResolver.Instance;
                int          fontIndex = resolver.getFontIndex(ch);
                f = resolver.getFont(fontIndex, attributes);
            }
            if (!oldParagraph.GetFontOrGraphicAt(relativePos).Equals(f))
            {
                return(new StyledParagraph(aci, chars));
            }

            // insert into existing paragraph
            oldParagraph.Length += 1;
            if (oldParagraph.Decorations != null)
            {
                InsertInto(relativePos, oldParagraph.DecorationStarts, oldParagraph.Decorations.Count);
            }
            if (oldParagraph.Fonts != null)
            {
                InsertInto(relativePos, oldParagraph.FontStarts, oldParagraph.Fonts.Count);
            }
            return(oldParagraph);
        }
Ejemplo n.º 20
0
        public AttributedString(AttributedCharacterIterator iterator)
        {
            if (iterator.GetBeginIndex() > iterator.GetEndIndex())
            {
                // text.0A=Invalid substring range
                throw new ArgumentException("text.0A"); //$NON-NLS-1$
            }
            StringBuilder buffer = new StringBuilder();

            for (int i = iterator.GetBeginIndex(); i < iterator.GetEndIndex(); i++)
            {
                buffer.Append(iterator.Current());
                iterator.Next();
            }
            text = buffer.ToString();
            ILOG.J2CsMapping.Collections.Generics.ISet <AttributedCharacterIterator_Constants.Attribute> attributes = iterator
                                                                                                                      .GetAllAttributeKeys();
            if (attributes == null)
            {
                return;
            }
            attributeMap = new Dictionary <AttributedCharacterIterator_Constants.Attribute, IList <Range> >(
                (attributes.Count * 4 / 3) + 1);

            IIterator <AttributedCharacterIterator_Constants.Attribute> it = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute>(attributes.GetEnumerator());

            while (it.HasNext())
            {
                AttributedCharacterIterator_Constants.Attribute attribute = it.Next();
                iterator.SetIndex(0);
                while (iterator.Current() != ILOG.J2CsMapping.Text.CharacterIterator.Done)
                {
                    int    start_0   = iterator.GetRunStart(attribute);
                    int    limit     = iterator.GetRunLimit(attribute);
                    Object value_ren = iterator.GetAttribute(attribute);
                    if (value_ren != null)
                    {
                        AddAttribute(attribute, value_ren, start_0, limit);
                    }
                    iterator.SetIndex(limit);
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Updates the <code>TextMeasurer</code> after a single character has
        /// been inserted
        /// into the paragraph currently represented by this
        /// <code>TextMeasurer</code>.  After this call, this
        /// <code>TextMeasurer</code> is equivalent to a new
        /// <code>TextMeasurer</code> created from the text;  however, it will
        /// usually be more efficient to update an existing
        /// <code>TextMeasurer</code> than to create a new one from scratch.
        /// </summary>
        /// <param name="newParagraph"> the text of the paragraph after performing
        /// the insertion.  Cannot be null. </param>
        /// <param name="insertPos"> the position in the text where the character was
        /// inserted.  Must not be less than the start of
        /// <code>newParagraph</code>, and must be less than the end of
        /// <code>newParagraph</code>. </param>
        /// <exception cref="IndexOutOfBoundsException"> if <code>insertPos</code> is less
        ///         than the start of <code>newParagraph</code> or greater than
        ///         or equal to the end of <code>newParagraph</code> </exception>
        /// <exception cref="NullPointerException"> if <code>newParagraph</code> is
        ///         <code>null</code> </exception>
        public void InsertChar(AttributedCharacterIterator newParagraph, int insertPos)
        {
            if (CollectStats)
            {
                PrintStats();
            }
            if (WantStats)
            {
                CollectStats = true;
            }

            FStart = newParagraph.BeginIndex;
            int end = newParagraph.EndIndex;

            if (end - FStart != FChars.Length + 1)
            {
                InitAll(newParagraph);
            }

            char[] newChars     = new char[end - FStart];
            int    newCharIndex = insertPos - FStart;

            System.Array.Copy(FChars, 0, newChars, 0, newCharIndex);

            char newChar = newParagraph.setIndex(insertPos);

            newChars[newCharIndex] = newChar;
            System.Array.Copy(FChars, newCharIndex, newChars, newCharIndex + 1, end - insertPos - 1);
            FChars = newChars;

            if (FBidi != null || Bidi.RequiresBidi(newChars, newCharIndex, newCharIndex + 1) || newParagraph.GetAttribute(TextAttribute.BIDI_EMBEDDING) != null)
            {
                FBidi = new Bidi(newParagraph);
                if (FBidi.LeftToRight)
                {
                    FBidi = null;
                }
            }

            FParagraph = StyledParagraph.InsertChar(newParagraph, FChars, insertPos, FParagraph);
            InvalidateComponents();
        }
Ejemplo n.º 22
0
        }       //	setData

        public void SetData(int row, int col, String stringData, Font font, Color foreground)
        {
            if (string.IsNullOrEmpty(stringData))
            {
                return;
            }

            TextLayout       layout;
            AttributedString aString = new AttributedString(stringData);

            aString.AddAttribute(TextAttribute.FONT, font);
            aString.AddAttribute(TextAttribute.FOREGROUND, foreground);
            AttributedCharacterIterator iter = aString.GetIterator();

            //HashMap<TextAttribute, object> map = new HashMap<TextAttribute, object>();
            //map.Put(TextAttribute.FONT, font);
            //map.Put(TextAttribute.FOREGROUND, foreground);
            layout = new TextLayout(iter);
            SetData(row, col, layout, iter);
        }
Ejemplo n.º 23
0
        /**
         * Constructs an {@code AttributedString} from an {@code
         * AttributedCharacterIterator}, which represents attributed text.
         *
         * @param iterator
         *            the {@code AttributedCharacterIterator} that contains the text
         *            for this attributed string.
         */
        public AttributedString(AttributedCharacterIterator iterator)
        {
            if (iterator.getBeginIndex() > iterator.getEndIndex())
            {
                // text.0A=Invalid substring range
                throw new java.lang.IllegalArgumentException("Invalid substring range"); //$NON-NLS-1$
            }
            StringBuilder buffer = new StringBuilder();

            for (int i = iterator.getBeginIndex(); i < iterator.getEndIndex(); i++)
            {
                buffer.Append(iterator.current());
                iterator.next();
            }
            text = buffer.ToString();
            java.util.Set <AttributedCharacterIteratorNS.Attribute> attributes = iterator
                                                                                 .getAllAttributeKeys();
            if (attributes == null)
            {
                return;
            }
            attributeMap = new java.util.HashMap <AttributedCharacterIteratorNS.Attribute, java.util.List <IAC_Range> >();//(attributes.size() * 4 / 3) + 1);

            java.util.Iterator <AttributedCharacterIteratorNS.Attribute> it = attributes.iterator();
            while (it.hasNext())
            {
                AttributedCharacterIteratorNS.Attribute attribute = it.next();
                iterator.setIndex(0);
                while (iterator.current() != CharacterIteratorConstants.DONE)
                {
                    int           start = iterator.getRunStart(attribute);
                    int           limit = iterator.getRunLimit(attribute);
                    System.Object value = iterator.getAttribute(attribute);
                    if (value != null)
                    {
                        addAttribute(attribute, value, start, limit);
                    }
                    iterator.setIndex(limit);
                }
            }
        }
Ejemplo n.º 24
0
 public GridElement(int rows, int cols)
 {
     m_rows       = rows;
     m_cols       = cols;
     m_textLayout = new TextLayout[rows, cols];
     m_iterator   = new AttributedCharacterIterator[rows, cols];
     m_rowHeight  = new int[rows];
     m_colWidth   = new int[cols];
     //	explicit init
     for (int r = 0; r < m_rows; r++)
     {
         m_rowHeight[r] = 0;
         for (int c = 0; c < m_cols; c++)
         {
             m_textLayout[r, c] = null;
             m_iterator[r, c]   = null;
         }
     }
     for (int c = 0; c < m_cols; c++)
     {
         m_colWidth[c] = 0;
     }
     p_info = "Grid:R=" + rows + ",C=" + cols;
 }       //	GridElement
Ejemplo n.º 25
0
 /// <summary>
 /// Renders the text of the specified iterator, using the
 /// <code>Graphics2D</code> context's current <code>Paint</code>.
 /// </summary>
 abstract public void drawString(AttributedCharacterIterator @iterator, float @x, float @y);
Ejemplo n.º 26
0
 public AttributedString(AttributedCharacterIterator arg0)
     : base(ProxyCtor.I)
 {
     Instance.CallConstructor("(Ljava/text/AttributedCharacterIterator;)V", arg0);
 }
Ejemplo n.º 27
0
 public AttributedString(AttributedCharacterIterator arg0, int arg1, int arg2, ObjectArray<AttributedCharacterIterator_.Attribute> arg3)
     : base(ProxyCtor.I)
 {
     Instance.CallConstructor("(Ljava/text/AttributedCharacterIterator;II[Ljava/text/AttributedCharacterIterator/Attribute;)V", arg0, arg1, arg2, arg3);
 }
		/// <summary>
		/// Constructs an <code>InputMethodEvent</code> with the specified
		/// source component, type, time, text, caret, and visiblePosition.
		/// </summary>
		public InputMethodEvent(Component @source, int @id, long @when, AttributedCharacterIterator @text, int @committedCharacterCount, TextHitInfo @caret, TextHitInfo @visiblePosition)
		{
		}
Ejemplo n.º 29
0
 /**
  * Constructs an {@code AttributedString} from a range of the text contained
  * in the specified {@code AttributedCharacterIterator}, starting at {@code
  * start} and ending at {@code end}. All attributes will be copied to this
  * attributed string.
  *
  * @param iterator
  *            the {@code AttributedCharacterIterator} that contains the text
  *            for this attributed string.
  * @param start
  *            the start index of the range of the copied text.
  * @param end
  *            the end index of the range of the copied text.
  * @throws IllegalArgumentException
  *             if {@code start} is less than first index of
  *             {@code iterator}, {@code end} is greater than the last
  *             index + 1 in {@code iterator} or if {@code start > end}.
  */
 public AttributedString(AttributedCharacterIterator iterator, int start,
                         int end) : this(iterator, start, end, iterator.getAllAttributeKeys())
 {
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Creates an AttributedCharacterIterator with the contents of
        /// <code>iterator</code> and the additional attribute <code>key</code>
        /// <code>value</code>.
        /// </summary>
        /// <param name="iterator"> Initial AttributedCharacterIterator to add arg to </param>
        /// <param name="key"> Key for AttributedCharacterIterator </param>
        /// <param name="value"> Value associated with key in AttributedCharacterIterator </param>
        /// <returns> AttributedCharacterIterator wrapping args </returns>
        internal virtual AttributedCharacterIterator CreateAttributedCharacterIterator(AttributedCharacterIterator iterator, AttributedCharacterIterator_Attribute key, Object value)
        {
            AttributedString @as = new AttributedString(iterator);

            @as.AddAttribute(key, value);
            return(@as.Iterator);
        }
Ejemplo n.º 31
0
		/// <summary>
		/// Renders the text of the specified iterator, using the
		/// <code>Graphics2D</code> context's current <code>Paint</code>.
		/// </summary>
		abstract public override void drawString(AttributedCharacterIterator @iterator, int @x, int @y);
Ejemplo n.º 32
0
		/// <summary>
		/// Renders the text of the specified iterator, using the
		/// <code>Graphics2D</code> context's current <code>Paint</code>.
		/// </summary>
		abstract public void drawString(AttributedCharacterIterator @iterator, float @x, float @y);
Ejemplo n.º 33
0
 /**
  * Renders the text of the specified iterator, using the
  * <code>Graphics2D</code> context's current <code>Paint</code>. The
  * iterator must specify a font
  * for each character. The baseline of the
  * first character is at position (<i>x</i>,&nbsp;<i>y</i>) in the
  * User Space.
  * The rendering attributes applied include the <code>Clip</code>,
  * <code>Transform</code>, <code>Paint</code>, and
  * <code>Composite</code> attributes.
  * For characters in script systems such as Hebrew and Arabic,
  * the glyphs can be rendered from right to left, in which case the
  * coordinate supplied is the location of the leftmost character
  * on the baseline.
  * @param iterator the iterator whose text is to be rendered
  * @param x the x coordinate where the iterator's text is to be
  * rendered
  * @param y the y coordinate where the iterator's text is to be
  * rendered
  * @see #setPaint
  * @see java.awt.Graphics#setColor
  * @see #setTransform
  * @see #setComposite
  * @see #setClip
  */
 public void DrawString(AttributedCharacterIterator iterator, float x, float y) {
     log.log(POILogger.WARN, "Not implemented");
 }
Ejemplo n.º 34
0
 /**
  * Draws the text given by the specified iterator, using this
  * graphics context's current color. The iterator has to specify a font
  * for each character. The baseline of the
  * first character is at position (<i>x</i>,&nbsp;<i>y</i>) in this
  * graphics context's coordinate system.
  * @param       iterator the iterator whose text is to be Drawn
  * @param       x        the <i>x</i> coordinate.
  * @param       y        the <i>y</i> coordinate.
  * @see         java.awt.Graphics#drawBytes
  * @see         java.awt.Graphics#drawChars
  */
 public void DrawString(AttributedCharacterIterator iterator,
                        int x, int y){
     DrawString(iterator, (float)x, (float)y);
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Renders the text of the specified iterator, using the
 /// <code>Graphics2D</code> context's current <code>Paint</code>.
 /// </summary>
 abstract public override void drawString(AttributedCharacterIterator @iterator, int @x, int @y);
Ejemplo n.º 36
0
 /**
  * Constructs an {@code AttributedString} from a range of the text contained
  * in the specified {@code AttributedCharacterIterator}, starting at {@code
  * start} and ending at {@code end}. All attributes will be copied to this
  * attributed string.
  *
  * @param iterator
  *            the {@code AttributedCharacterIterator} that contains the text
  *            for this attributed string.
  * @param start
  *            the start index of the range of the copied text.
  * @param end
  *            the end index of the range of the copied text.
  * @throws IllegalArgumentException
  *             if {@code start} is less than first index of
  *             {@code iterator}, {@code end} is greater than the last
  *             index + 1 in {@code iterator} or if {@code start > end}.
  */
 public AttributedString(AttributedCharacterIterator iterator, int start,
         int end)
     : this(iterator, start, end, iterator.getAllAttributeKeys())
 {
 }
Ejemplo n.º 37
0
 /**
  * @see Graphics#drawString(AttributedCharacterIterator, int, int)
  */
 public void drawString(AttributedCharacterIterator iterator, int x, int y)
 {
     drawString(iterator, (float)x, (float)y);
 }
Ejemplo n.º 38
0
 /**
  * Constructs an {@code AttributedString} from a range of the text contained
  * in the specified {@code AttributedCharacterIterator}, starting at {@code
  * start}, ending at {@code end} and it will copy the attributes defined in
  * the specified set. If the set is {@code null} then all attributes are
  * copied.
  *
  * @param iterator
  *            the {@code AttributedCharacterIterator} that contains the text
  *            for this attributed string.
  * @param start
  *            the start index of the range of the copied text.
  * @param end
  *            the end index of the range of the copied text.
  * @param attributes
  *            the set of attributes that will be copied, or all if it is
  *            {@code null}.
  * @throws IllegalArgumentException
  *             if {@code start} is less than first index of
  *             {@code iterator}, {@code end} is greater than the last index +
  *             1 in {@code iterator} or if {@code start > end}.
  */
 public AttributedString(AttributedCharacterIterator iterator, int start,
                         int end, AttributedCharacterIteratorNS.Attribute[] attributes)
     : this(iterator, start, end, new java.util.HashSet <AttributedCharacterIteratorNS.Attribute>(java.util.Arrays <System.Object> .asList(attributes)))
 {
 }
Ejemplo n.º 39
0
        private AttributedString(AttributedCharacterIterator iterator, int start,
                int end, java.util.Set<AttributedCharacterIteratorNS.Attribute> attributes)
        {
            if (start < iterator.getBeginIndex() || end > iterator.getEndIndex()
                    || start > end) {
                throw new java.lang.IllegalArgumentException();
            }

            if (attributes == null) {
                return;
            }

            StringBuilder buffer = new StringBuilder();
            iterator.setIndex(start);
            while (iterator.getIndex() < end) {
                buffer.Append(iterator.current());
                iterator.next();
            }
            text = buffer.ToString();
            attributeMap = new java.util.HashMap<AttributedCharacterIteratorNS.Attribute, java.util.List<IAC_Range>>();//(attributes.size() * 4 / 3) + 1);

            java.util.Iterator<AttributedCharacterIteratorNS.Attribute> it = attributes.iterator();
            while (it.hasNext()) {
                AttributedCharacterIteratorNS.Attribute attribute = it.next();
                iterator.setIndex(start);
                while (iterator.getIndex() < end) {
                    System.Object value = iterator.getAttribute(attribute);
                    int runStart = iterator.getRunStart(attribute);
                    int limit = iterator.getRunLimit(attribute);
                    if ((value is java.lang.annotation.Annotation && runStart >= start && limit <= end)
                            || (value != null && !(value is java.lang.annotation.Annotation))) {
                        addAttribute(attribute, value, (runStart < start ? start
                                : runStart)
                                - start, (limit > end ? end : limit) - start);
                    }
                    iterator.setIndex(limit);
                }
            }
        }
Ejemplo n.º 40
0
 /**
  * Constructs an {@code AttributedString} from a range of the text contained
  * in the specified {@code AttributedCharacterIterator}, starting at {@code
  * start}, ending at {@code end} and it will copy the attributes defined in
  * the specified set. If the set is {@code null} then all attributes are
  * copied.
  *
  * @param iterator
  *            the {@code AttributedCharacterIterator} that contains the text
  *            for this attributed string.
  * @param start
  *            the start index of the range of the copied text.
  * @param end
  *            the end index of the range of the copied text.
  * @param attributes
  *            the set of attributes that will be copied, or all if it is
  *            {@code null}.
  * @throws IllegalArgumentException
  *             if {@code start} is less than first index of
  *             {@code iterator}, {@code end} is greater than the last index +
  *             1 in {@code iterator} or if {@code start > end}.
  */
 public AttributedString(AttributedCharacterIterator iterator, int start,
         int end, AttributedCharacterIteratorNS.Attribute[] attributes)
     : this(iterator, start, end, new java.util.HashSet<AttributedCharacterIteratorNS.Attribute>(java.util.Arrays<System.Object>.asList(attributes)))
 {
 }
Ejemplo n.º 41
0
        }       //	translate

        public override void PaintPdf(XGraphics g2D, int pageNo, PointF pageStart, Ctx ctx, bool isView)
        {
            m_solidbrush = new SolidBrush(Color.Black);
            PointF location = GetAbsoluteLocation(pageStart);

            //
            if (m_originalString != null)
            {
                Translate(ctx);
            }

            AttributedString            aString = null;
            AttributedCharacterIterator iter    = null;
            //	AttributedCharacterIterator iter2 = null;
            float xPos   = (float)location.X;
            float yPos   = (float)location.Y;
            float yPen   = 0f;
            float height = 0f;
            float width  = 0f;

            //	for all lines
            for (int i = 0; i < m_string_paper.Length; i++)
            {
                //	Get Text
                if (isView)
                {
                    if (m_string_view[i] == null)
                    {
                        continue;
                    }
                    aString = m_string_view[i];
                }
                else
                {
                    if (m_string_paper[i] == null)
                    {
                        continue;
                    }
                    aString = m_string_paper[i];
                }
                iter = aString.GetIterator();
                //	Zero Length
                if (iter.GetBeginIndex() == iter.GetEndIndex())
                {
                    continue;
                }


                //	Check for Tab (just first) and 16 bit characters
                int  tabPos = -1;
                bool is8Bit = true;
                for (char c = iter.First(); c != DONE; c = iter.Next())
                {
                    if (c == '\t' && tabPos == -1)
                    {
                        tabPos = iter.GetIndex();
                    }
                    if (c > 255)
                    {
                        is8Bit = false;
                    }
                }

                TextLayout layout = null;
                float      xPen   = xPos;

                //	No Limit
                if (p_maxWidth == 0f)
                {
                    if (tabPos == -1)
                    {
                        layout = new TextLayout(iter);
                        yPen   = yPos + layout.GetAscent();
                        //	layout.draw(g2D, xPen, yPen);
                        //m_font);
                        //g2D.setPaint(m_paint);
                        //XFont d = new XFont(m_font, new XPdfFontOptions(PdfSharp.Pdf.PdfFontEncoding.Unicode, PdfSharp.Pdf.PdfFontEmbedding.Automatic));

                        //StringBuilder txt = new StringBuilder();
                        //txt.Append("\u202D")
                        //.Append(iter.GetText())
                        //.Append("\u202C");
                        //g2D.DrawString(

                        XPdfFontOptions options = new XPdfFontOptions(PdfSharp.Pdf.PdfFontEncoding.Unicode, PdfSharp.Pdf.PdfFontEmbedding.Always);

                        PdfSharp.Drawing.Layout.XTextFormatter tf = new PdfSharp.Drawing.Layout.XTextFormatter(g2D);

                        //XStringFormat sf = new XStringFormat();
                        //sf.Alignment = XStringAlignment.Near;

                        //tf.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;

                        //tf.DrawString(iter.GetText(), new XFont(m_font, options), new XSolidBrush(XColors.Black), (double)xPen, (double)yPen);
                        g2D.DrawString(iter.GetText(), new XFont(m_font, options), new XSolidBrush(XColors.Black), (double)xPen, (double)yPen, new XStringFormat()
                        {
                            Alignment = XStringAlignment.Near
                        });
                        //
                        yPos += layout.GetAscent() + layout.GetDescent() + layout.GetLeading();
                        if (width < layout.GetAdvance())
                        {
                            width = layout.GetAdvance();
                        }
                    }
                    else        //	we have a tab
                    {
                        LineBreakMeasurer measurer = new LineBreakMeasurer(iter);
                        layout = measurer.NextLayout(9999, tabPos);
                        float lineHeight_1 = layout.GetAscent() + layout.GetDescent() + layout.GetLeading();
                        yPen = yPos + layout.GetAscent();
                        g2D.DrawString(iter.GetText(), new XFont(m_font, new XPdfFontOptions(PdfSharp.Pdf.PdfFontEncoding.Unicode, PdfSharp.Pdf.PdfFontEmbedding.Always)), new XSolidBrush(XColors.Black), (double)xPen, (double)yPen);          //	first part before tab
                        xPen = GetTabPos(xPos, layout.GetAdvance());
                        float lineWidth = xPen - xPos;
                        layout = measurer.NextLayout(9999);//, iter.getEndIndex(), true);
                        float lineHeight_2 = layout.GetAscent() + layout.GetDescent() + layout.GetLeading();
                        //layout.draw(g2D, xPen, yPen);		//	second part after tab
                        //
                        yPos      += Math.Max(lineHeight_1, lineHeight_2);
                        lineWidth += layout.GetAdvance();
                        if (width < lineWidth)
                        {
                            width = lineWidth;
                        }
                    }
                    //	log.finest( "StringElement.paint - No Limit - " + location.x + "/" + yPos
                    //		+ " w=" + layout.getAdvance() + ",h=" + lineHeight + ", Bounds=" + layout.getBounds());
                }
                //	Size Limits
                else
                {
                    bool fastDraw = LayoutEngine.s_FASTDRAW;
                    if (fastDraw && !isView && !is8Bit)
                    {
                        fastDraw = false;
                    }
                    LineBreakMeasurer measurer = new LineBreakMeasurer(iter);
                    while (measurer.GetPosition() < iter.GetEndIndex())
                    {
                        if (tabPos == -1)
                        {
                            layout = measurer.NextLayout(p_maxWidth);
                            // use fastDraw if the string fits in one line
                            if (fastDraw && iter.GetEndIndex() != measurer.GetPosition())
                            {
                                fastDraw = false;
                            }
                        }
                        else    //	tab
                        {
                            fastDraw = false;
                            layout   = measurer.NextLayout(p_maxWidth, tabPos);
                        }
                        //	Line Height
                        float lineHeight = layout.GetAscent() + layout.GetDescent() + layout.GetLeading();
                        if (p_maxHeight == -1f && i == 0)               //	one line only
                        {
                            p_maxHeight = lineHeight;
                        }
                        //	If we have hight left over
                        if (p_maxHeight == 0f || (height + lineHeight) <= p_maxHeight)
                        {
                            yPen = (float)location.Y + height + layout.GetAscent();
                            //	Tab in Text
                            if (tabPos != -1)
                            {
                                layout.Draw(g2D, (double)xPen, (double)yPen);   //	first part before tab
                                xPen   = GetTabPos(xPos, layout.GetAdvance());
                                layout = measurer.NextLayout(p_width, iter.GetEndIndex());
                                tabPos = -1;    //	reset (just one tab)
                            }
                            else if ((X_AD_PrintFormatItem.FIELDALIGNMENTTYPE_TrailingRight.Equals(p_FieldAlignmentType) && layout.IsLeftToRight()) ||
                                     (X_AD_PrintFormatItem.FIELDALIGNMENTTYPE_LeadingLeft.Equals(p_FieldAlignmentType)) && !layout.IsLeftToRight())
                            {
                                xPen += p_maxWidth - layout.GetAdvance();
                            }
                            else if (X_AD_PrintFormatItem.FIELDALIGNMENTTYPE_Center.Equals(p_FieldAlignmentType))
                            {
                                xPen += (p_maxWidth - layout.GetAdvance()) / 2;
                            }
                            else if (X_AD_PrintFormatItem.FIELDALIGNMENTTYPE_Block.Equals(p_FieldAlignmentType) && measurer.GetPosition() < iter.GetEndIndex())
                            {
                                //layout = layout.getJustifiedLayout(p_maxWidth);
                                fastDraw = false;
                            }
                            if (fastDraw)
                            {
                                //g2D.setFont(m_font);
                                //g2D.setPaint(m_paint);
                                g2D.DrawString(iter.GetText(), new XFont(m_font, new XPdfFontOptions(PdfSharp.Pdf.PdfFontEncoding.Unicode, PdfSharp.Pdf.PdfFontEmbedding.Always)), new XSolidBrush(XColors.Black), (double)xPen, (double)yPen - 7);
                            }
                            else
                            {
                                layout.Draw(g2D, (double)xPen, (double)yPen);
                            }
                            height += lineHeight;
                            //	log.finest( "StringElement.paint - Limit - " + xPen + "/" + yPen
                            //		+ " w=" + layout.getAdvance() + ",h=" + lineHeight + ", Align=" + p_FieldAlignmentType + ", Max w=" + p_maxWidth + ",h=" + p_maxHeight + ", Bounds=" + layout.getBounds());
                        }
                    }
                    width = p_maxWidth;
                } //	size limits
            }     //	for all strings
            if (m_check != null)
            {
                int x = (int)(location.X + width + 1);
                int y = (int)(location.Y);
                //g2D.DrawImage((bool)m_check ? LayoutEngine.IMAGE_TRUE : LayoutEngine.IMAGE_FALSE, x, y);
            }
        }